Created
January 18, 2018 08:38
-
-
Save chomy/81b68222af7254b998e3b33f796046c6 to your computer and use it in GitHub Desktop.
LED blink for Nucleo STM32F103
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
#include "stm32f10x.h" | |
#pragma GCC diagnostic push | |
#pragma GCC diagnostic ignored "-Wunused-parameter" | |
#pragma GCC diagnostic ignored "-Wmissing-declarations" | |
#pragma GCC diagnostic ignored "-Wreturn-type" | |
int | |
main(int argc, char* argv[]) | |
{ | |
volatile int i = 0; | |
volatile int flag = 0; | |
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE); | |
GPIO_InitTypeDef pin_PA5; | |
pin_PA5.GPIO_Pin = GPIO_Pin_5; | |
pin_PA5.GPIO_Mode = GPIO_Mode_Out_PP; | |
pin_PA5.GPIO_Speed = GPIO_Speed_50MHz; | |
GPIO_Init(GPIOA, &pin_PA5); | |
while (1){ | |
i = i+1; | |
if(i < 1000000){ | |
continue; | |
} | |
i = 0; | |
if(flag == 0){ | |
GPIO_SetBits(GPIOA, GPIO_Pin_5); | |
flag = 1; | |
}else{ | |
GPIO_ResetBits(GPIOA, GPIO_Pin_5); | |
flag = 0; | |
} | |
} | |
} | |
#pragma GCC diagnostic pop |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment