forked from platformio/platformio-core
49 lines
895 B
C
49 lines
895 B
C
#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;
|
|
} |