Zakaria ElQotbi / mbed-src

Fork of mbed-src by mbed official

Revision:
84:f54042cbc282
Parent:
80:66393a7b209d
Child:
145:cfacfb0a9e19
--- a/targets/hal/TARGET_STM/TARGET_NUCLEO_F103RB/pinmap.c	Fri Jan 31 10:15:06 2014 +0000
+++ b/targets/hal/TARGET_STM/TARGET_NUCLEO_F103RB/pinmap.c	Mon Feb 03 09:30:05 2014 +0000
@@ -43,7 +43,6 @@
   GPIO_Remap_I2C1         // 8
 };
 
-// Not an API function
 // Enable GPIO clock and return GPIO base address
 uint32_t Set_GPIO_Clock(uint32_t port_idx) {
     uint32_t gpio_add = 0;
@@ -75,9 +74,6 @@
  * Configure pin (input, output, alternate function or analog) + output speed + AF
  */
 void pin_function(PinName pin, int data) {
-    GPIO_TypeDef *gpio;
-    GPIO_InitTypeDef GPIO_InitStructure;
-  
     if (pin == NC) return;
 
     // Get the pin informations
@@ -89,7 +85,7 @@
 
     // Enable GPIO clock
     uint32_t gpio_add = Set_GPIO_Clock(port_index);
-    gpio = (GPIO_TypeDef *)gpio_add;
+    GPIO_TypeDef *gpio = (GPIO_TypeDef *)gpio_add;
 
     // Enable AFIO clock
     RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE);
@@ -101,6 +97,7 @@
     }
   
     // Configure GPIO
+    GPIO_InitTypeDef GPIO_InitStructure;
     GPIO_InitStructure.GPIO_Pin   = (uint16_t)(1 << pin_index);
     GPIO_InitStructure.GPIO_Mode  = (GPIOMode_TypeDef)mode;
     GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
@@ -120,9 +117,8 @@
  * Configure pin pull-up/pull-down
  */
 void pin_mode(PinName pin, PinMode mode) {
-    GPIO_TypeDef *gpio;
     GPIO_InitTypeDef GPIO_InitStructure;
-
+    
     if (pin == NC) return;
 
     uint32_t port_index = STM_PORT(pin);
@@ -130,7 +126,7 @@
 
     // Enable GPIO clock
     uint32_t gpio_add = Set_GPIO_Clock(port_index);
-    gpio = (GPIO_TypeDef *)gpio_add;
+    GPIO_TypeDef *gpio = (GPIO_TypeDef *)gpio_add;
   
     // Configure open-drain and pull-up/down
     switch (mode) {