STM32 share EXTI can not work prope rly, need some fix below

"kontais" <kontais-Dw/[email protected]>
Newsgroups gmane.comp.hardware.microcontrollers.ethernut
Message-ID <---.ae------rS1ae$134f3b5b-f11a-4044-af19-fe4bf2cb8bb2@aliyun.com>

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) {
_______________________________________________
http://lists.egnite.de/mailman/listinfo/en-nut-discussion
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.