esp8266-hal
esp8266-hal copied to clipboard
GPIO interrupt is not working as expected.
I have tried to set up a GPIO interrupt handler the following way:
#[interrupt(gpio)]
fn gpio_intr() {
// do something
}
#[entry]
fn main() -> ! {
enable_interrupt(InterruptType::GPIO);
// ...
}
Full code here: https://gist.github.com/m1el/41b2c1c210d92b45ff015483c9dd59d8
However, the chip hangs immediately upon receiving an interrupt.
With some help and reading the manuals, it was discovered that the interrupt routine is getting repeatedly called.
This happens because GPIO interrupt status is not getting cleared.
After adding (*target::GPIO::ptr()).gpio_status_w1tc.write(|w| w.bits(0xffff))
to the interrupt handler, the code works as expected.
Since interrupt_trampoline
clears interrupt status with xtensa_lx::interrupt::clear(mask)
, one would expect it to clear GPIO interrupt status as well.