From cea91306de343c87d6209b72256889e699e7b576 Mon Sep 17 00:00:00 2001 From: Laurent MEUNIER Date: Fri, 30 Jun 2017 09:52:45 +0200 Subject: [PATCH] STM32: Raise error in case of spurious interrupt In case we've run through the entire GPIOs loop, withouth finding a matching interrupt, we're in the case of a spurious interrupt, let's raise an error to track it down. --- targets/TARGET_STM/gpio_irq_api.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/targets/TARGET_STM/gpio_irq_api.c b/targets/TARGET_STM/gpio_irq_api.c index 1ae8111ffc..fd37f2cbe0 100644 --- a/targets/TARGET_STM/gpio_irq_api.c +++ b/targets/TARGET_STM/gpio_irq_api.c @@ -90,8 +90,9 @@ static void handle_interrupt_in(uint32_t irq_index, uint32_t max_num_pin_line) if (__HAL_GPIO_EXTI_GET_FLAG(pin) != RESET) { __HAL_GPIO_EXTI_CLEAR_FLAG(pin); - if (gpio_channel->channel_ids[gpio_idx] == 0) + if (gpio_channel->channel_ids[gpio_idx] == 0) { continue; + } // Check which edge has generated the irq if ((gpio->IDR & pin) == 0) { @@ -99,9 +100,11 @@ static void handle_interrupt_in(uint32_t irq_index, uint32_t max_num_pin_line) } else { irq_handler(gpio_channel->channel_ids[gpio_idx], IRQ_RISE); } + return; } } } + error("Unexpected Spurious interrupt, index %d\r\n", irq_index); }