Created
December 17, 2018 16:32
-
-
Save bofh/0c20ed7c48a2d2745f3536c4037b8452 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let device = hal::stm32f30x::Peripherals::take().unwrap(); | |
let mut core = Peripherals::take().unwrap(); | |
// Configure PC13 as an input | |
device.RCC.ahbenr.modify(|_, w| w.iopcen().set_bit()); | |
device.GPIOC.moder.modify( | |
|_, w| w.moder13().input() | |
); | |
device.GPIOC.pupdr.modify(|_, w| unsafe { | |
w.pupdr13().bits(0b01) // Pull-up | |
}); | |
// Enable the EXTI13 interrupt | |
core.NVIC.enable( | |
stm32f30x::Interrupt::EXTI15_10, | |
); | |
// Connect GPIOC13 to EXTI13 | |
device.SYSCFG.exticr4.modify(|_, w| unsafe { | |
w.exti13().bits(0b010) | |
}); | |
// Enable interrupt on rise | |
device.EXTI.imr1.modify(|_, w| w.mr13().set_bit()); | |
device.EXTI.emr1.modify(|_, w| w.mr13().set_bit()); | |
device.EXTI.rtsr1.modify(|_, w| w.tr13().set_bit()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment