esp-rs / esp-idf-svc

Type-Safe Rust Wrappers for various ESP-IDF services (WiFi, Network, Httpd, Logging, etc.)
https://docs.esp-rs.org/esp-idf-svc/
Apache License 2.0
333 stars 183 forks source link

Counting pin interrupts no longer possible with 0.47.3? #325

Closed sirhcel closed 1 year ago

sirhcel commented 1 year ago

Upgrading esp-idf-svc from an older release from spring this year to 0.47.3 breaks my attempt for counting edges on a GPIO pin. With the RMT peripheral being used for driving LEDs, I counted edges on an ESP32-C3 using an interrupt handler as follows:

static GPIO3_EDGES: AtomicU32 = AtomicU32::new(0);
let mut gpio3 = PinDriver::input(pins.gpio3)?;
gpio3.set_interrupt_type(InterruptType::AnyEdge)?;
unsafe {
    gpio3.subscribe(move || {
        GPIO3_EDGES.fetch_add(1, Ordering::Relaxed);
    })?
};

Enabling this interrupt from "main" and re-enabling it from the interrupt handler does not work out as I can't share the PinDriver mutably by reference between them. Moving it to the handler prevents enabling the interrupt from "main".

If and if yes, how is this supposed to work with esp-idf-svc 0.47.3?

sirhcel commented 1 year ago

Wrongfully created this issue in the wrong project. Sorry! It should have been https://github.com/esp-rs/esp-idf-hal/issues/349 from the start.