mirror of
https://github.com/italicsjenga/rp-hal-boards.git
synced 2025-01-11 13:01:30 +11:00
GPIO IRQ example: add check for interrupt source (#401)
This commit is contained in:
parent
96552b28c5
commit
c7acafda3c
|
@ -174,7 +174,9 @@ fn IO_IRQ_BANK0() {
|
||||||
// these will be of type `&mut LedPin` and `&mut ButtonPin`, so we don't have
|
// these will be of type `&mut LedPin` and `&mut ButtonPin`, so we don't have
|
||||||
// to move them back into the static after we use them
|
// to move them back into the static after we use them
|
||||||
let (led, button) = gpios;
|
let (led, button) = gpios;
|
||||||
|
// Check if the interrupt source is from the pushbutton going from high-to-low.
|
||||||
|
// Note: this will always be true in this example, as that is the only enabled GPIO interrupt source
|
||||||
|
if button.interrupt_status(EdgeLow) {
|
||||||
// toggle can't fail, but the embedded-hal traits always allow for it
|
// toggle can't fail, but the embedded-hal traits always allow for it
|
||||||
// we can discard the return value by assigning it to an unnamed variable
|
// we can discard the return value by assigning it to an unnamed variable
|
||||||
let _ = led.toggle();
|
let _ = led.toggle();
|
||||||
|
@ -183,6 +185,7 @@ fn IO_IRQ_BANK0() {
|
||||||
// Do that now so we don't immediately jump back to this interrupt handler.
|
// Do that now so we don't immediately jump back to this interrupt handler.
|
||||||
button.clear_interrupt(EdgeLow);
|
button.clear_interrupt(EdgeLow);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// End of file
|
// End of file
|
||||||
|
|
Loading…
Reference in a new issue