Reorganize examples with STM32 and new frameworks

This commit is contained in:
Valeriy Koval
2015-02-03 14:43:27 +02:00
parent c402cc7c62
commit 423dc248bc
14 changed files with 488 additions and 1 deletions

View File

@@ -0,0 +1,49 @@
#include <stm32l1xx_gpio.h>
#include <stm32l1xx_rcc.h>
#include <misc.h>
/* timing is not guaranteed :) */
void simple_delay(uint32_t us)
{
/* simple delay loop */
while (us--) {
asm volatile ("nop");
}
}
/* system entry point */
int main(void)
{
/* gpio init struct */
GPIO_InitTypeDef gpio;
/* reset rcc */
RCC_DeInit();
/* enable clock to GPIOB */
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOB, ENABLE);
/* use pin 7 */
gpio.GPIO_Pin = GPIO_Pin_7;
/* mode: output */
gpio.GPIO_Mode = GPIO_Mode_OUT;
/* output type: push-pull */
gpio.GPIO_OType = GPIO_OType_PP;
/* apply configuration */
GPIO_Init(GPIOB, &gpio);
/* main program loop */
for (;;) {
/* set led on */
GPIO_SetBits(GPIOB, GPIO_Pin_7);
/* delay */
simple_delay(100000);
/* clear led */
GPIO_ResetBits(GPIOB, GPIO_Pin_7);
/* delay */
simple_delay(100000);
}
/* never reached */
return 0;
}