From 3d9d52de873817ad7dc5f8e921d7218960e65cbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Th=C3=A9baudeau?= Date: Thu, 9 Apr 2015 00:55:04 +0200 Subject: [PATCH] cc2538: gpio: Fix missed interrupts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Only the interrupt flags that have been handled must be cleared. Otherwise, if a new interrupt occurs after the interrupt statuses are read and before they are cleared, then it is discarded without having been handled. This issue was particularly likely with two interrupt trigger conditions occurring on different pins of the same port in a short period of time. Signed-off-by: Benoît Thébaudeau --- cpu/cc2538/dev/gpio.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/cpu/cc2538/dev/gpio.c b/cpu/cc2538/dev/gpio.c index cce0c6b22..eb561c757 100644 --- a/cpu/cc2538/dev/gpio.c +++ b/cpu/cc2538/dev/gpio.c @@ -86,18 +86,20 @@ static void gpio_port_isr(uint8_t port) { uint32_t base; + uint8_t int_status, power_up_int_status; lpm_exit(); ENERGEST_ON(ENERGEST_TYPE_IRQ); base = GPIO_PORT_TO_BASE(port); + int_status = GPIO_GET_MASKED_INT_STATUS(base); + power_up_int_status = GPIO_GET_POWER_UP_INT_STATUS(port); - notify(GPIO_GET_MASKED_INT_STATUS(base) | GPIO_GET_POWER_UP_INT_STATUS(port), - port); + notify(int_status | power_up_int_status, port); - GPIO_CLEAR_INTERRUPT(base, 0xFF); - GPIO_CLEAR_POWER_UP_INTERRUPT(port, 0xFF); + GPIO_CLEAR_INTERRUPT(base, int_status); + GPIO_CLEAR_POWER_UP_INTERRUPT(port, power_up_int_status); ENERGEST_OFF(ENERGEST_TYPE_IRQ); }