Question, how to listen to GPIO interrupt
Simonrazer opened this issue · comments
Hi! I want to listen to a Rising edge of a GPIO pin. I think I understand how to enable the interrupt:
let mut btn = Pin::new(Port::A, 0, PinMode::Input); btn.enable_interrupt(gpio::Edge::Rising);
But I can't figure out how to listen to it. As it seems, the macro used in the example demands a varient of pac::Interrupt
, but there is no variant present for GPIO pins. What am I missing?
Any help is greatly appreciated!
Check the GPIO example: https://github.com/David-OConnor/stm32-hal/blob/main/examples/gpio.rs
Bottom line is the interrupt names are EXTIx
etc, with some grouped. So for PA0 like you mentioned, its EXTI0
.
#[interrupt]
fn EXTI0() {
free(|cs| {
// Clear the interrupt flag, to prevent continous firing.
gpio::clear_exti_interrupt(0);
// etc
});
}