Advertisement
blackswords

Main template STM32

May 20th, 2012
281
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.54 KB | None | 0 0
  1. #include "stm32f10x.h"
  2.  
  3. #define PIN GPIO_Pin_0
  4. #define PORT GPIOB
  5.  
  6. void delay() {
  7.  
  8.     int i;
  9.     for (i = 0; i < 10000; i++);
  10.  
  11. }
  12.  
  13. int main() {
  14.  
  15.     GPIO_InitTypeDef GPIO_InitStructure;
  16.  
  17.     GPIO_InitStructure.GPIO_Pin = PIN;
  18.     GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  19.     GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
  20.     GPIO_Init(PORT, &GPIO_InitStructure);
  21.  
  22.     while (1) {
  23.  
  24.         GPIO_SetBits(PORT, PIN);
  25.         delay();
  26.         GPIO_ResetBits(PORT, PIN);
  27.         delay();
  28.  
  29.     }
  30.  
  31.     return 0;
  32.  
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement