Skip to content
Snippets Groups Projects
Unverified Commit 86aab81c authored by Mr. Jake's avatar Mr. Jake Committed by GitHub
Browse files

IRQ enabling guard (when no callback set) (#1504)

parent 74b9ea4d
No related branches found
No related tags found
No related merge requests found
......@@ -174,6 +174,13 @@ static void _gpio_set_irq_enabled(uint gpio, uint32_t events, bool enabled, io_i
}
void gpio_set_irq_enabled(uint gpio, uint32_t events, bool enabled) {
// either this call disables the interrupt
// or callback should already be set (raw or using gpio_set_irq_callback)
// this protects against enabling the interrupt without callback set
assert(!enabled
|| (raw_irq_mask[get_core_num()] & (1u<<gpio))
|| callbacks[get_core_num()]);
// Separate mask/force/status per-core, so check which core called, and
// set the relevant IRQ controls.
io_irq_ctrl_hw_t *irq_ctrl_base = get_core_num() ?
......@@ -182,8 +189,9 @@ 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) {
gpio_set_irq_enabled(gpio, events, enabled);
// first set callback, then enable the interrupt
gpio_set_irq_callback(callback);
gpio_set_irq_enabled(gpio, events, enabled);
if (enabled) irq_set_enabled(IO_IRQ_BANK0, true);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment