summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2015-01-27 09:15:43 -0600
committerGregory Nutt <gnutt@nuttx.org>2015-01-27 09:15:43 -0600
commitfaf1b92fa77f7fa1b86d4d663f65552a015b12a7 (patch)
treeadadf4a4fc4f4ca7691e32639ad2180f0f7c516d
parent5385c01ea871ef1e992f9f2bce709f081adeaf20 (diff)
downloadnuttx-faf1b92fa77f7fa1b86d4d663f65552a015b12a7.tar.gz
nuttx-faf1b92fa77f7fa1b86d4d663f65552a015b12a7.tar.bz2
nuttx-faf1b92fa77f7fa1b86d4d663f65552a015b12a7.zip
Disabling any of EXTI 5-9 interrupts was disabling interrupts for all EXTI 5-9. Same issue with EXTI 10-15. From Jussi Kivilinna.
-rw-r--r--nuttx/arch/arm/src/stm32/stm32_exti_gpio.c38
1 files changed, 31 insertions, 7 deletions
diff --git a/nuttx/arch/arm/src/stm32/stm32_exti_gpio.c b/nuttx/arch/arm/src/stm32/stm32_exti_gpio.c
index f897691ef..ebf9d61dc 100644
--- a/nuttx/arch/arm/src/stm32/stm32_exti_gpio.c
+++ b/nuttx/arch/arm/src/stm32/stm32_exti_gpio.c
@@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/stm32/stm32_exti_gpio.c
*
- * Copyright (C) 2009, 2011-2012 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2009, 2011-2012, 2015 Gregory Nutt. All rights reserved.
* Copyright (C) 2011 Uros Platise. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
* Uros Platise <uros.platise@isotel.eu>
@@ -245,12 +245,17 @@ xcpt_t stm32_gpiosetevent(uint32_t pinset, bool risingedge, bool fallingedge,
int irq;
xcpt_t handler;
xcpt_t oldhandler = NULL;
+ int nshared;
+ xcpt_t *shared_cbs;
+ int i;
/* Select the interrupt handler for this EXTI pin */
if (pin < 5)
{
- irq = pin + STM32_IRQ_EXTI0;
+ irq = pin + STM32_IRQ_EXTI0;
+ nshared = 1;
+ shared_cbs = &stm32_exti_callbacks[pin];
switch (pin)
{
case 0:
@@ -276,13 +281,17 @@ xcpt_t stm32_gpiosetevent(uint32_t pinset, bool risingedge, bool fallingedge,
}
else if (pin < 10)
{
- irq = STM32_IRQ_EXTI95;
- handler = stm32_exti95_isr;
+ irq = STM32_IRQ_EXTI95;
+ handler = stm32_exti95_isr;
+ shared_cbs = &stm32_exti_callbacks[5];
+ nshared = 5;
}
else
{
- irq = STM32_IRQ_EXTI1510;
- handler = stm32_exti1510_isr;
+ irq = STM32_IRQ_EXTI1510;
+ handler = stm32_exti1510_isr;
+ shared_cbs = &stm32_exti_callbacks[10];
+ nshared = 6;
}
/* Get the previous GPIO IRQ handler; Save the new IRQ handler. */
@@ -299,7 +308,22 @@ xcpt_t stm32_gpiosetevent(uint32_t pinset, bool risingedge, bool fallingedge,
}
else
{
- up_disable_irq(irq);
+ /* Only disable IRQ if shared handler does not have any active
+ * callbacks.
+ */
+
+ for (i = 0; i < nshared; i++)
+ {
+ if (shared_cbs[i] != NULL)
+ {
+ break;
+ }
+ }
+
+ if (i == nshared)
+ {
+ up_disable_irq(irq);
+ }
}
/* Configure GPIO, enable EXTI line enabled if event or interrupt is