Guest User

Untitled

a guest
Dec 17th, 2018
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. let device = hal::stm32f30x::Peripherals::take().unwrap();
  2. let mut core = Peripherals::take().unwrap();
  3.  
  4. // Configure PC13 as an input
  5. device.RCC.ahbenr.modify(|_, w| w.iopcen().set_bit());
  6. device.GPIOC.moder.modify(
  7. |_, w| w.moder13().input()
  8. );
  9. device.GPIOC.pupdr.modify(|_, w| unsafe {
  10. w.pupdr13().bits(0b01) // Pull-up
  11. });
  12. // Enable the EXTI13 interrupt
  13. core.NVIC.enable(
  14. stm32f30x::Interrupt::EXTI15_10,
  15. );
  16. // Connect GPIOC13 to EXTI13
  17. device.SYSCFG.exticr4.modify(|_, w| unsafe {
  18. w.exti13().bits(0b010)
  19. });
  20. // Enable interrupt on rise
  21. device.EXTI.imr1.modify(|_, w| w.mr13().set_bit());
  22. device.EXTI.emr1.modify(|_, w| w.mr13().set_bit());
  23. device.EXTI.rtsr1.modify(|_, w| w.tr13().set_bit());
Add Comment
Please, Sign In to add comment