Created
November 13, 2014 05:02
-
-
Save reportingsjr/6fddc9955963935377b2 to your computer and use it in GitHub Desktop.
STM32F100 test code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Thumb2 Newlib Toolchain example project | |
// Written by Elias Önal <EliasOenal@gmail.com>, released as public domain. | |
#include <stdio.h> | |
#include <stdint.h> | |
#include "stm32f10x_gpio.h" | |
#include "stm32f10x_rcc.h" | |
void delay(volatile unsigned int count); | |
int main(void) | |
{ | |
RCC->APB2ENR |= RCC_APB2ENR_IOPCEN; | |
// Configure pins | |
GPIO_InitTypeDef GPIOInit; | |
GPIOInit.GPIO_Pin = GPIO_Pin_8; | |
GPIOInit.GPIO_Speed = GPIO_Speed_2MHz; | |
GPIOInit.GPIO_Mode = GPIO_Mode_Out_PP; | |
GPIO_Init(GPIOC, &GPIOInit); | |
while (1) | |
{ | |
GPIO_SetBits(GPIOC, GPIO_Pin_8|GPIO_Pin_9); | |
delay(0x3FFFFF); | |
GPIO_ResetBits(GPIOC, GPIO_Pin_8|GPIO_Pin_9); | |
delay(0xFFFFFF); | |
} | |
} | |
// Do nothing, for a while (what a pun!) | |
void delay(volatile unsigned int count) | |
{ | |
while(count--) | |
{ | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment