mbed library sources

Dependents:   frdm_kl05z_gpio_test

Fork of mbed-src by mbed official

Revision:
156:38b9eb24e1d1
Parent:
84:f54042cbc282
Child:
216:577900467c9e
--- a/targets/hal/TARGET_STM/TARGET_NUCLEO_F030R8/gpio_irq_api.c	Tue Apr 08 09:15:06 2014 +0100
+++ b/targets/hal/TARGET_STM/TARGET_NUCLEO_F030R8/gpio_irq_api.c	Fri Apr 11 00:30:06 2014 +0100
@@ -51,7 +51,7 @@
     // 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]);
-     
+
     // Clear interrupt flag
     if (EXTI_GetITStatus(pin) != RESET)
     {
@@ -87,25 +87,24 @@
     uint32_t pin_index  = STM_PIN(pin);
 
     // Select irq number and interrupt routine
-    switch (pin) {
-        case PC_13: // User button
-            irq_n = EXTI4_15_IRQn;
-            vector = (uint32_t)&gpio_irq0;
-            irq_index = 0;
-            break;
-        case PA_0:
-            irq_n = EXTI0_1_IRQn;
-            vector = (uint32_t)&gpio_irq1;
-            irq_index = 1;
-            break;
-        case PB_3:
-            irq_n = EXTI2_3_IRQn;
-            vector = (uint32_t)&gpio_irq2;
-            irq_index = 2;
-            break;
-        default:
-            error("This pin is not supported\n");
-            return -1;
+    if ((pin_index == 0) || (pin_index == 1)) {
+        irq_n = EXTI0_1_IRQn;
+        vector = (uint32_t)&gpio_irq0;
+        irq_index = 0;
+    }
+    else if ((pin_index == 2) || (pin_index == 3)) {
+        irq_n = EXTI2_3_IRQn;
+        vector = (uint32_t)&gpio_irq1;
+        irq_index = 1;
+    }
+    else if ((pin_index > 3) && (pin_index < 16)) {
+        irq_n = EXTI4_15_IRQn;
+        vector = (uint32_t)&gpio_irq2;
+        irq_index = 2;
+    }
+    else {
+        error("InterruptIn error: pin not supported.\n");
+        return -1;
     }
 
     // Enable GPIO clock