Advertisement
nis

main.c for stm32/example/00-enable-led

nis
Jan 26th, 2012
419
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.73 KB | None | 0 0
  1. /**
  2.  * Main code of firmware
  3.  */
  4. #include "stm32f10x.h"
  5. /* General defines */
  6. #define LED_PORT GPIOC
  7. #define LED_BLUE (1 << 8)
  8. #define LED_GREEN (1 << 9)
  9. void main();
  10. /* provided by linker script */
  11. extern unsigned long _estack;
  12. /* Reset handler */
  13. void Reset_Handler(void) {
  14.     main();
  15. }
  16. /* Table of Cortex vectors */
  17. void *vector_table[] __attribute__ ((section(".vectors"))) = {
  18.     &_estack,
  19.     Reset_Handler,
  20. };
  21. /* Main function */
  22. void main(void) {
  23.     /* setup i/o port */
  24.     RCC->APB2ENR |= RCC_APB2ENR_IOPCEN;
  25.     LED_PORT->CRH |= GPIO_CRH_MODE8_0 | GPIO_CRH_MODE9_0;
  26.     LED_PORT->CRH &= ~(GPIO_CRH_CNF8 | GPIO_CRH_CNF9);
  27.     /* enable led */
  28.     LED_PORT->ODR = LED_BLUE | LED_GREEN;
  29.     /* infinity loop */
  30.     while (1);
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement