Advertisement
Guest User

Untitled

a guest
Sep 19th, 2019
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. #include <stm32f10x.h>
  2. #include <stm32f10x_gpio.h>
  3. #include <stm32f10x_rcc.h>
  4.  
  5.  
  6. #define RED_LED GPIO_Pin_3
  7.  
  8. int main(void)
  9. {
  10. RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE);
  11. GPIO_InitTypeDef LED;
  12.  
  13. LED.GPIO_Pin = RED_LED;
  14. LED.GPIO_Mode = GPIO_Mode_Out_PP;
  15. LED.GPIO_Speed = GPIO_Speed_2MHz;
  16.  
  17. GPIO_Init(GPIOB, &LED);
  18.  
  19. GPIO_SetBits(GPIOB, RED_LED);
  20. GPIO_ResetBits(GPIOB, RED_LED);
  21.  
  22. while(1)
  23. {
  24. GPIO_SetBits(GPIOB, RED_LED);
  25. for(int i = 0; i < 100; i++);
  26. GPIO_ResetBits(GPIOB, RED_LED);
  27. for(int i = 0; i < 100; i++);
  28. }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement