mbed library sources

Dependents:   frdm_kl05z_gpio_test

Fork of mbed-src by mbed official

Revision:
167:d5744491c362
Parent:
145:cfacfb0a9e19
Child:
174:8bb9f3a33240
--- a/targets/hal/TARGET_STM/TARGET_NUCLEO_F103RB/pinmap.c	Tue Apr 22 16:00:06 2014 +0100
+++ b/targets/hal/TARGET_STM/TARGET_NUCLEO_F103RB/pinmap.c	Wed Apr 23 11:00:08 2014 +0100
@@ -32,16 +32,18 @@
 #include "error.h"
 
 // Alternate-function mapping
-static const uint32_t AF_mapping[] = {
-  0,                      // 0 = No AF
-  GPIO_Remap_SPI1,        // 1
-  GPIO_Remap_I2C1,        // 2
-  GPIO_Remap_USART1,      // 3
-  GPIO_Remap_USART2,      // 4
-  GPIO_FullRemap_TIM2,    // 5
-  GPIO_FullRemap_TIM3,    // 6
-  GPIO_PartialRemap_TIM3, // 7
-  GPIO_Remap_I2C1         // 8
+#define AF_NUM (10)
+static const uint32_t AF_mapping[AF_NUM] = {
+  0,                        // 0 = No AF
+  GPIO_Remap_SPI1,          // 1
+  GPIO_Remap_I2C1,          // 2
+  GPIO_Remap_USART1,        // 3
+  GPIO_Remap_USART2,        // 4
+  GPIO_PartialRemap_USART3, // 5
+  GPIO_PartialRemap_TIM1,   // 6
+  GPIO_PartialRemap_TIM3,   // 7
+  GPIO_FullRemap_TIM2,      // 8
+  GPIO_FullRemap_TIM3       // 9
 };
 
 // Enable GPIO clock and return GPIO base address
@@ -93,7 +95,7 @@
 
     // Configure Alternate Function
     // Warning: Must be done before the GPIO is initialized
-    if (afnum > 0) {
+    if ((afnum > 0) && (afnum < AF_NUM)) {
         GPIO_PinRemapConfig(AF_mapping[afnum], ENABLE);
     }