From 86aab81c47549b806da0cfb6fc00811e6bdc653d Mon Sep 17 00:00:00 2001 From: "Mr. Jake" Date: Sun, 7 Jul 2024 19:57:50 +0200 Subject: [PATCH] IRQ enabling guard (when no callback set) (#1504) --- src/rp2_common/hardware_gpio/gpio.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/rp2_common/hardware_gpio/gpio.c b/src/rp2_common/hardware_gpio/gpio.c index 4945738d..c16e3cdc 100644 --- a/src/rp2_common/hardware_gpio/gpio.c +++ b/src/rp2_common/hardware_gpio/gpio.c @@ -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<