mbed library sources

Fork of mbed-src by mbed official

Files at this revision

API Documentation at this revision

Comitter:
mbed_official
Date:
Tue Apr 22 13:45:07 2014 +0100
Parent:
162:937d965048d3
Child:
164:90c6009cba07
Commit message:
Synchronized with git revision 7b8a9ba0969dc98ff13a84ecb54b4111b92adfbf

Full URL: https://github.com/mbedmicro/mbed/commit/7b8a9ba0969dc98ff13a84ecb54b4111b92adfbf/

Changed in this revision

targets/hal/TARGET_STM/TARGET_DISCO_F100RB/gpio_irq_api.c Show annotated file Show diff for this revision Revisions of this file
--- a/targets/hal/TARGET_STM/TARGET_DISCO_F100RB/gpio_irq_api.c	Tue Apr 22 13:30:06 2014 +0100
+++ b/targets/hal/TARGET_STM/TARGET_DISCO_F100RB/gpio_irq_api.c	Tue Apr 22 13:45:07 2014 +0100
@@ -39,35 +39,40 @@
 #define EDGE_FALL (2)
 #define EDGE_BOTH (3)
 
-#define CHANNEL_NUM (7)
+#define CHANNEL_NUM (16)
 
-static uint32_t channel_ids[CHANNEL_NUM]  = {0, 0, 0, 0, 0, 0, 0};
-static uint32_t channel_gpio[CHANNEL_NUM] = {0, 0, 0, 0, 0, 0, 0};
-static uint32_t channel_pin[CHANNEL_NUM]  = {0, 0, 0, 0, 0, 0, 0};
+static uint32_t channel_ids[CHANNEL_NUM]  = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
+static uint32_t channel_gpio[CHANNEL_NUM] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
+static uint32_t channel_pin[CHANNEL_NUM]  = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
 
 static gpio_irq_handler irq_handler;
 
 static void handle_interrupt_in(uint32_t irq_index) {
-    // Retrieve the gpio and pin that generate the irq
-    GPIO_TypeDef *gpio = (GPIO_TypeDef *)(channel_gpio[irq_index]);
-    uint32_t pin = (uint32_t)(1 << channel_pin[irq_index]);
+	//if irq_index==5 loop exti 5 to 9
+	//if irq_index==10 loop exti 10 to 15
+	//else exti loop one irq_index
+	uint32_t to_irq_index=(irq_index==5)?9:((irq_index==10)?15:irq_index);
+    GPIO_TypeDef *gpio;
+    uint32_t pin;
+    do{
+      // Retrieve the gpio and pin that generate the irq
+      gpio = (GPIO_TypeDef *)(channel_gpio[irq_index]);
+      pin = (uint32_t)(1 << channel_pin[irq_index]);
+      // Clear interrupt flag
+      if (EXTI_GetITStatus(pin) != RESET)
+      {
+    	  EXTI_ClearITPendingBit(pin);
+		  if (channel_ids[irq_index] == 0) return;
+		  // Check which edge has generated the irq
+		  if ((gpio->IDR & pin) == 0) {
+			  irq_handler(channel_ids[irq_index], IRQ_FALL);
+		  } else {
+			  irq_handler(channel_ids[irq_index], IRQ_RISE);
+		  }
+      }
+    }while(irq_index++ < to_irq_index);
+}
 
-    // Clear interrupt flag
-    if (EXTI_GetITStatus(pin) != RESET)
-    {
-        EXTI_ClearITPendingBit(pin);
-    }
-    
-    if (channel_ids[irq_index] == 0) return;
-    
-    // Check which edge has generated the irq
-    if ((gpio->IDR & pin) == 0) {
-        irq_handler(channel_ids[irq_index], IRQ_FALL);
-    }
-    else  {
-        irq_handler(channel_ids[irq_index], IRQ_RISE);
-    }
-}
 
 // The irq_index is passed to the function
 static void gpio_irq0(void) {handle_interrupt_in(0);} // EXTI line 0
@@ -76,7 +81,7 @@
 static void gpio_irq3(void) {handle_interrupt_in(3);} // EXTI line 3
 static void gpio_irq4(void) {handle_interrupt_in(4);} // EXTI line 4
 static void gpio_irq5(void) {handle_interrupt_in(5);} // EXTI lines 5 to 9
-static void gpio_irq6(void) {handle_interrupt_in(6);} // EXTI lines 10 to 15
+static void gpio_irq6(void) {handle_interrupt_in(10);} // EXTI lines 10 to 15
 
 extern uint32_t Set_GPIO_Clock(uint32_t port_idx);
 
@@ -124,7 +129,7 @@
         case 9:
             irq_n = EXTI9_5_IRQn;
             vector = (uint32_t)&gpio_irq5;
-            irq_index = 5;
+            irq_index = pin_index;
             break;
         case 10:
         case 11:
@@ -134,13 +139,12 @@
         case 15:
             irq_n = EXTI15_10_IRQn;
             vector = (uint32_t)&gpio_irq6;
-            irq_index = 6;
+            irq_index = pin_index;
             break;
         default:
             error("InterruptIn error: pin not supported.\n");
             return -1;
     }
-
     // Enable GPIO clock
     uint32_t gpio_add = Set_GPIO_Clock(port_index);