golemparts/rppal

Syncronous Interrupt hanging

jhaubrich opened this issue · 2 comments

I'm interacting with an ADC that has a busy signal while it does conversion. I block while the busy pin is high:

let mut busy = Gpio::new()?.get(GPIO_BUSY)?.into_input_pullup();

loop {
    start_conversion();
    while busy.is_high() { /* block while we wait for conversion to finish */}
    ...
    read_data();
}

This gets me the basic functionality, but I wanted to use an interrupt on that pin instead. I set it up like so:

let mut busy = Gpio::new()?.get(GPIO_BUSY)?.into_input_pullup();
busy.set_interrupt(gpio::Trigger::FallingEdge);

loop {
    start_conversion();
    busy.poll_interrupt(false, None);
    ...
    read_data();
}

🤔 Am I doing this right or is this a bug?

The error was mine. I was spending too much time between start_conversion() and detecting the busy pin for a falling edge. The edge was falling before we got there.

Great library! So fast. So easy to use.

Thanks for the compliment! Glad to hear you found the cause of the issue.