Advertisement
Guest User

Untitled

a guest
Aug 4th, 2015
466
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.91 KB | None | 0 0
  1. #include "stm32f4xx.h"
  2.  
  3. #define USE_HAL_DRIVER
  4. #define HSE_VALUE 8000000
  5.  * LEDs
  6.  * RED PB8
  7.  * BLUE PC13
  8.  */
  9.  
  10. RCC_Configuration()
  11. {
  12.     /*
  13.      * Enables clock for GPIO A, B & C
  14.      */
  15.     RCC->AHB1ENR |= RCC_AHB1ENR_GPIOAEN;
  16.     RCC->AHB1ENR |= RCC_AHB1ENR_GPIOBEN;
  17.     RCC->AHB1ENR |= RCC_AHB1ENR_GPIOCEN;
  18. }
  19.  
  20. GPIO_Configuration(uint32_t Port,uint32_t Pin, uint32_t Mode)
  21. {
  22.     /*
  23.      * Configures the GPIO port & pin to the desired Mode
  24.      */
  25.     GPIO_InitTypeDef GPIO_init;
  26.  
  27.     GPIO_init.Pin = Pin;
  28.     GPIO_init.Mode = Mode;
  29.     GPIO_init.Speed = GPIO_SPEED_FAST;
  30.     GPIO_init.Pull = GPIO_PULLUP;
  31.  
  32.     HAL_GPIO_Init(Port,&GPIO_init);
  33. }
  34.  
  35. void main ()
  36. {
  37.  
  38.  
  39. // enable port
  40. RCC_Configuration();
  41. // init led
  42. GPIO_Configuration(GPIOC,GPIO_PIN_13,GPIO_MODE_OUTPUT_PP);
  43.  
  44.   while (1)
  45.     {
  46.              // Toggle led
  47.               HAL_GPIO_TogglePin(GPIOC,GPIO_PIN_13);
  48.                 // waste time
  49.              for (i = 0; i < 500000; i++);
  50.     }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement