Advertisement
Guest User

Untitled

a guest
Mar 29th, 2016
500
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. void set_system_clock(void)
  2. {
  3. rcc_clock_setup_hsi(&hsi_8mhz[CLOCK_64MHZ]);
  4. }
  5.  
  6. void setup_led_pins(void)
  7. {
  8. rcc_periph_clock_enable(RCC_GPIOE);
  9. gpio_mode_setup(GPIOE, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, GPIO8 | GPIO9 | GPIO10 | GPIO11 |
  10. GPIO12 | GPIO13 | GPIO14 | GPIO15);
  11. gpio_set(GPIOE, GPIO8 | GPIO9 | GPIO10 | GPIO11 |
  12. GPIO12 | GPIO13 | GPIO14 | GPIO15);
  13. }
  14.  
  15. int main()
  16. {
  17. _disable_interrupts();
  18. set_system_clock();
  19. setup_led_pins();
  20. rcc_periph_clock_enable(RCC_GPIOD);
  21. gpio_mode_setup(GPIOD, GPIO_MODE_INPUT, GPIO_PUPD_NONE, GPIO5);
  22.  
  23. exti_select_source(EXTI5, GPIOD);
  24. exti_set_trigger(EXTI5, EXTI_TRIGGER_RISING);
  25. exti_enable_request(EXTI5);
  26.  
  27. while(1)
  28. {
  29. if(exti_get_flag_status(EXTI5))
  30. {
  31. exti_reset_request(EXTI5);
  32. gpio_toggle(GPIOE, GPIO8);
  33. }
  34. }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement