Advertisement
Guest User

Untitled

a guest
Oct 24th, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. #include "stm32f4xx.h"
  2. #include "stm32f4xx_gpio.h"
  3. #include "stm32f4xx_rcc.h"
  4.  
  5. void init()
  6. {
  7. GPIO_InitTypeDef GPIO_InitStruct;
  8. RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);
  9.  
  10. GPIO_InitStruct.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2;
  11. GPIO_InitStruct.GPIO_Mode = GPIO_Mode_OUT; // we want the pins to be an output
  12. GPIO_InitStruct.GPIO_Speed = GPIO_Speed_100MHz; // this sets the GPIO modules clock speed
  13. GPIO_InitStruct.GPIO_OType = GPIO_OType_PP; // this sets the pin type to push / pull (as opposed to open drain)
  14. GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_NOPULL; // this sets the pullup / pulldown resistors to be inactive
  15. GPIO_Init(GPIOA, &GPIO_InitStruct);
  16. }
  17.  
  18.  
  19.  
  20. void blink()
  21. {
  22. GPIOA->ODR++;
  23. }
  24.  
  25. void main()
  26. {
  27. init();
  28. while(1)
  29. {
  30. blink();
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement