[En-Nut-Discussion] STM32 share EXTI can not work properly, need some fix below

kontais kontais at aliyun.com
Sun Sep 20 06:03:28 CEST 2015



Index: E:/ethernut-code/nut/arch/cm3/dev/stm/stm32_gpioirq.c
===================================================================
--- E:/ethernut-code/nut/arch/cm3/dev/stm/stm32_gpioirq.c (revision 6130)
+++ E:/ethernut-code/nut/arch/cm3/dev/stm/stm32_gpioirq.c (working copy)
@@ -125,7 +125,7 @@
 GPIO_SIGNAL *GpioCreateIrqHandler(nutgpio_port_t port, nutgpio_pin_t bit, void (*handler) (void *), void *arg)
 {
     GPIO_SIGNAL *sig;
-    int port_nr = (port & 0x3fff) >> 10;
+    int port_nr = (port-GPIOA_BASE) >> 10;
     sig = malloc(sizeof(GPIO_SIGNAL));
     if (sig) {
         int rc;
@@ -248,18 +248,20 @@
         GPIO_SIGNAL *sig_chain;
         sig_chain = isrhandler->ir_arg;
         while (sig_chain) {
-            if(sig_chain->ios_pin != bit) {
-                /* Pin is not already mapped */
-                if (0 == sig_chain->sig_next) {
-                    /* we have a free slot*/
-                    /* Clear any pending interrupts and mask */
-                    EXTI->PR   =  (1 << bit);
-                    EXTI->IMR &= ~(1 << bit);
-                    sig_chain->sig_next = sig;
-                    rc = 0;
-                    break;
-                }
+            /* Pin is already mapped */
+            if (sig_chain->ios_pin == bit) {
+                break;
             }
+            /* Last one */
+            if (sig_chain->sig_next == NULL) {
+                /* Clear any pending interrupts and mask */
+                EXTI->PR   =  (1 << bit);
+                EXTI->IMR &= ~(1 << bit);
+                sig_chain->sig_next = sig;
+                rc = 0;
+                break;
+            }
+            sig_chain = sig_chain->sig_next;
         }
     }
     if (0 == rc) {


More information about the En-Nut-Discussion mailing list