mbed SDK library sources

Fork of mbed-src by mbed official

Development branch of the mbed library sources. This library is kept in synch with the latest changes from the mbed SDK and it is not guaranteed to work.

If you are looking for a stable and tested release, please import one of the official mbed library releases:

Import librarymbed

The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Revision:
76:aeb1df146756
Parent:
70:c1fbde68b492
Child:
84:f54042cbc282
--- a/targets/hal/TARGET_STM/TARGET_NUCLEO_F103RB/port_api.c	Mon Jan 27 13:30:06 2014 +0000
+++ b/targets/hal/TARGET_STM/TARGET_NUCLEO_F103RB/port_api.c	Mon Jan 27 14:30:07 2014 +0000
@@ -30,9 +30,12 @@
 #include "port_api.h"
 #include "pinmap.h"
 #include "gpio_api.h"
+#include "error.h"
 
 #if DEVICE_PORTIN || DEVICE_PORTOUT
 
+extern uint32_t Set_GPIO_Clock(uint32_t port_idx);
+
 // high nibble = port number (0=A, 1=B, 2=C, 3=D, 4=E, 5=F, ...)
 // low nibble  = pin number
 PinName port_pin(PortName port, int pin_n) {
@@ -40,14 +43,13 @@
 }
 
 void port_init(port_t *obj, PortName port, int mask, PinDirection dir) {
-
+    GPIO_TypeDef *gpio;
+  
     uint32_t port_index = (uint32_t)port; // (0=A, 1=B, 2=C, 3=D, 4=E, 5=F, ...)
 
     // Enable GPIO clock
-    RCC_APB2PeriphClockCmd((RCC_APB2Periph_GPIOA << port_index), ENABLE);
-
-    // Get GPIO structure base address
-    GPIO_TypeDef *gpio = (GPIO_TypeDef *)(GPIOA_BASE + (port_index << 10));
+    uint32_t gpio_add = Set_GPIO_Clock(port_index);
+    gpio = (GPIO_TypeDef *)gpio_add;
 
     // Fill PORT object structure for future use
     obj->port      = port;