mbed library sources

Dependents:   frdm_kl05z_gpio_test

Fork of mbed-src by mbed official

Revision:
216:577900467c9e
Parent:
156:38b9eb24e1d1
Child:
250:a49055e7a707
--- a/targets/hal/TARGET_STM/TARGET_NUCLEO_F030R8/gpio_irq_api.c	Tue May 27 08:30:06 2014 +0100
+++ b/targets/hal/TARGET_STM/TARGET_NUCLEO_F030R8/gpio_irq_api.c	Tue May 27 10:00:08 2014 +0100
@@ -53,26 +53,30 @@
     uint32_t pin = (uint32_t)(1 << channel_pin[irq_index]);
 
     // Clear interrupt flag
-    if (EXTI_GetITStatus(pin) != RESET)
-    {
+    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  {
+    } 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);}
-static void gpio_irq1(void) {handle_interrupt_in(1);}
-static void gpio_irq2(void) {handle_interrupt_in(2);}
+static void gpio_irq0(void) {
+    handle_interrupt_in(0);
+}
+static void gpio_irq1(void) {
+    handle_interrupt_in(1);
+}
+static void gpio_irq2(void) {
+    handle_interrupt_in(2);
+}
 
 extern uint32_t Set_GPIO_Clock(uint32_t port_idx);
 
@@ -91,18 +95,15 @@
         irq_n = EXTI0_1_IRQn;
         vector = (uint32_t)&gpio_irq0;
         irq_index = 0;
-    }
-    else if ((pin_index == 2) || (pin_index == 3)) {
+    } 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)) {
+    } else if ((pin_index > 3) && (pin_index < 16)) {
         irq_n = EXTI4_15_IRQn;
         vector = (uint32_t)&gpio_irq2;
         irq_index = 2;
-    }
-    else {
+    } else {
         error("InterruptIn error: pin not supported.\n");
         return -1;
     }
@@ -112,25 +113,25 @@
 
     // Enable SYSCFG clock
     RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);
-    
+
     // Connect EXTI line to pin
     SYSCFG_EXTILineConfig(port_index, pin_index);
 
     // Configure EXTI line
-    EXTI_InitTypeDef EXTI_InitStructure;    
+    EXTI_InitTypeDef EXTI_InitStructure;
     EXTI_InitStructure.EXTI_Line = (uint32_t)(1 << pin_index);
     EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
     EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling;
     EXTI_InitStructure.EXTI_LineCmd = ENABLE;
     EXTI_Init(&EXTI_InitStructure);
-    
+
     // Enable and set EXTI interrupt to the lowest priority
     NVIC_InitTypeDef NVIC_InitStructure;
     NVIC_InitStructure.NVIC_IRQChannel = irq_n;
     NVIC_InitStructure.NVIC_IRQChannelPriority = 0;
     NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
     NVIC_Init(&NVIC_InitStructure);
-  
+
     NVIC_SetVector(irq_n, vector);
     NVIC_EnableIRQ(irq_n);
 
@@ -141,9 +142,9 @@
     channel_ids[irq_index] = id;
     channel_gpio[irq_index] = gpio_add;
     channel_pin[irq_index] = pin_index;
-    
-    irq_handler = handler; 
-  
+
+    irq_handler = handler;
+
     return 0;
 }
 
@@ -154,47 +155,44 @@
     // Disable EXTI line
     EXTI_InitTypeDef EXTI_InitStructure;
     EXTI_StructInit(&EXTI_InitStructure);
-    EXTI_Init(&EXTI_InitStructure);  
+    EXTI_Init(&EXTI_InitStructure);
     obj->event = EDGE_NONE;
 }
 
 void gpio_irq_set(gpio_irq_t *obj, gpio_irq_event event, uint32_t enable) {
     EXTI_InitTypeDef EXTI_InitStructure;
-    
+
     uint32_t pin_index = channel_pin[obj->irq_index];
 
     EXTI_InitStructure.EXTI_Line = (uint32_t)(1 << pin_index);
     EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
-    
+
     if (event == IRQ_RISE) {
         if ((obj->event == EDGE_FALL) || (obj->event == EDGE_BOTH)) {
             EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising_Falling;
             obj->event = EDGE_BOTH;
-        }
-        else { // NONE or RISE
+        } else { // NONE or RISE
             EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising;
             obj->event = EDGE_RISE;
         }
     }
-    
+
     if (event == IRQ_FALL) {
         if ((obj->event == EDGE_RISE) || (obj->event == EDGE_BOTH)) {
             EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising_Falling;
             obj->event = EDGE_BOTH;
-        }
-        else { // NONE or FALL
+        } else { // NONE or FALL
             EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling;
             obj->event = EDGE_FALL;
         }
     }
-    
+
     if (enable) {
         EXTI_InitStructure.EXTI_LineCmd = ENABLE;
-    }
-    else {
+    } else {
         EXTI_InitStructure.EXTI_LineCmd = DISABLE;
     }
-    
+
     EXTI_Init(&EXTI_InitStructure);
 }