mirror of
https://github.com/raspberrypi/pico-sdk.git
synced 2025-12-10 07:14:36 +01:00
Fix race in gpio_set_irq_enabled_with_callback
The order depends on whether you're enabling or disabling
This commit is contained in:
parent
b30caca4fd
commit
23bda885cb
1 changed files with 4 additions and 2 deletions
|
|
@ -196,9 +196,11 @@ void gpio_set_irq_enabled(uint gpio, uint32_t events, bool enabled) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void gpio_set_irq_enabled_with_callback(uint gpio, uint32_t events, bool enabled, gpio_irq_callback_t callback) {
|
void gpio_set_irq_enabled_with_callback(uint gpio, uint32_t events, bool enabled, gpio_irq_callback_t callback) {
|
||||||
// first set callback, then enable the interrupt
|
// when enabling, first set callback, then enable the interrupt
|
||||||
gpio_set_irq_callback(callback);
|
// when disabling, first disable the interrupt, then clear callback
|
||||||
|
if (enabled) gpio_set_irq_callback(callback);
|
||||||
gpio_set_irq_enabled(gpio, events, enabled);
|
gpio_set_irq_enabled(gpio, events, enabled);
|
||||||
|
if (!enabled) gpio_set_irq_callback(callback);
|
||||||
if (enabled) irq_set_enabled(IO_IRQ_BANK0, true);
|
if (enabled) irq_set_enabled(IO_IRQ_BANK0, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue