forked from platformio/platformio-core
Reorganize examples with STM32 and new frameworks
This commit is contained in:
49
examples/stm32/stm32-spl-blink/src/main.c
Normal file
49
examples/stm32/stm32-spl-blink/src/main.c
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user