mbed library sources

Dependents:   bare

Fork of mbed-src by mbed official

Files at this revision

API Documentation at this revision

Comitter:
mbed_official
Date:
Fri Mar 14 10:00:07 2014 +0000
Parent:
117:e0a7df0a9a56
Child:
119:063a65f72629
Commit message:
Synchronized with git revision 7d88efe969a293d8fee496c7c1f902f359c40af8

Full URL: https://github.com/mbedmicro/mbed/commit/7d88efe969a293d8fee496c7c1f902f359c40af8/

Add additional peripherie for ST Nucleo L152 board

Changed in this revision

targets/hal/TARGET_STM/TARGET_NUCLEO_L152RE/PeripheralNames.h Show annotated file Show diff for this revision Revisions of this file
targets/hal/TARGET_STM/TARGET_NUCLEO_L152RE/i2c_api.c Show annotated file Show diff for this revision Revisions of this file
targets/hal/TARGET_STM/TARGET_NUCLEO_L152RE/serial_api.c Show annotated file Show diff for this revision Revisions of this file
targets/hal/TARGET_STM/TARGET_NUCLEO_L152RE/spi_api.c Show annotated file Show diff for this revision Revisions of this file
--- a/targets/hal/TARGET_STM/TARGET_NUCLEO_L152RE/PeripheralNames.h	Wed Mar 12 10:30:07 2014 +0000
+++ b/targets/hal/TARGET_STM/TARGET_NUCLEO_L152RE/PeripheralNames.h	Fri Mar 14 10:00:07 2014 +0000
@@ -47,7 +47,10 @@
 
 typedef enum {
     UART_1 = (int)USART1_BASE,  
-    UART_2 = (int)USART2_BASE
+    UART_2 = (int)USART2_BASE,
+    UART_3 = (int)USART3_BASE,
+    UART_4 = (int)UART4_BASE,
+    UART_5 = (int)UART5_BASE
 } UARTName;
 
 #define STDIO_UART_TX  PA_2
@@ -56,7 +59,8 @@
 
 typedef enum {
     SPI_1 = (int)SPI1_BASE,
-    SPI_2 = (int)SPI2_BASE
+    SPI_2 = (int)SPI2_BASE,
+    SPI_3 = (int)SPI3_BASE
 } SPIName;
 
 typedef enum {
--- a/targets/hal/TARGET_STM/TARGET_NUCLEO_L152RE/i2c_api.c	Wed Mar 12 10:30:07 2014 +0000
+++ b/targets/hal/TARGET_STM/TARGET_NUCLEO_L152RE/i2c_api.c	Fri Mar 14 10:00:07 2014 +0000
@@ -42,12 +42,16 @@
 #define LONG_TIMEOUT ((int)0x8000)
 
 static const PinMap PinMap_I2C_SDA[] = {
+    {PB_7,  I2C_1, STM_PIN_DATA(GPIO_Mode_AF, GPIO_OType_OD, GPIO_PuPd_UP, GPIO_AF_I2C1)},
     {PB_9,  I2C_1, STM_PIN_DATA(GPIO_Mode_AF, GPIO_OType_OD, GPIO_PuPd_UP, GPIO_AF_I2C1)},
+    {PB_11, I2C_2, STM_PIN_DATA(GPIO_Mode_AF, GPIO_OType_OD, GPIO_PuPd_UP, GPIO_AF_I2C2)},
     {NC,    NC,    0}
 };
 
 static const PinMap PinMap_I2C_SCL[] = {
+    {PB_6,  I2C_1, STM_PIN_DATA(GPIO_Mode_AF, GPIO_OType_OD, GPIO_PuPd_UP, GPIO_AF_I2C1)},
     {PB_8,  I2C_1, STM_PIN_DATA(GPIO_Mode_AF, GPIO_OType_OD, GPIO_PuPd_UP, GPIO_AF_I2C1)},
+    {PB_10, I2C_2, STM_PIN_DATA(GPIO_Mode_AF, GPIO_OType_OD, GPIO_PuPd_UP, GPIO_AF_I2C2)},
     {NC,    NC,    0}
 };
 
--- a/targets/hal/TARGET_STM/TARGET_NUCLEO_L152RE/serial_api.c	Wed Mar 12 10:30:07 2014 +0000
+++ b/targets/hal/TARGET_STM/TARGET_NUCLEO_L152RE/serial_api.c	Fri Mar 14 10:00:07 2014 +0000
@@ -35,17 +35,27 @@
 
 static const PinMap PinMap_UART_TX[] = {
     {PA_9,  UART_1, STM_PIN_DATA(GPIO_Mode_AF, GPIO_OType_PP, GPIO_PuPd_UP, GPIO_AF_USART1)},
+    {PB_6,  UART_1, STM_PIN_DATA(GPIO_Mode_AF, GPIO_OType_PP, GPIO_PuPd_UP, GPIO_AF_USART1)},
     {PA_2,  UART_2, STM_PIN_DATA(GPIO_Mode_AF, GPIO_OType_PP, GPIO_PuPd_UP, GPIO_AF_USART2)},
+    {PB_10, UART_3, STM_PIN_DATA(GPIO_Mode_AF, GPIO_OType_PP, GPIO_PuPd_UP, GPIO_AF_USART3)},
+    {PC_10, UART_4, STM_PIN_DATA(GPIO_Mode_AF, GPIO_OType_PP, GPIO_PuPd_UP, GPIO_AF_UART4)},       
+    //{PC_10, UART_3, STM_PIN_DATA(GPIO_Mode_AF, GPIO_OType_PP, GPIO_PuPd_UP, GPIO_AF_USART3)},       //The consructor will find UART4
+    {PC_12, UART_5, STM_PIN_DATA(GPIO_Mode_AF, GPIO_OType_PP, GPIO_PuPd_UP, GPIO_AF_UART5)},          //which share the same PIN
     {NC,    NC,     0}
 };
 
 static const PinMap PinMap_UART_RX[] = {
     {PA_10, UART_1, STM_PIN_DATA(GPIO_Mode_AF, GPIO_OType_PP, GPIO_PuPd_UP, GPIO_AF_USART1)},
+    {PB_7 , UART_1, STM_PIN_DATA(GPIO_Mode_AF, GPIO_OType_PP, GPIO_PuPd_UP, GPIO_AF_USART1)},
     {PA_3,  UART_2, STM_PIN_DATA(GPIO_Mode_AF, GPIO_OType_PP, GPIO_PuPd_UP, GPIO_AF_USART2)},
+    {PB_11, UART_3, STM_PIN_DATA(GPIO_Mode_AF, GPIO_OType_PP, GPIO_PuPd_UP, GPIO_AF_USART3)},
+    {PC_11, UART_4, STM_PIN_DATA(GPIO_Mode_AF, GPIO_OType_PP, GPIO_PuPd_UP, GPIO_AF_UART4)},
+    //{PC_11, UART_3, STM_PIN_DATA(GPIO_Mode_AF, GPIO_OType_PP, GPIO_PuPd_UP, GPIO_AF_USART3)},
+    {PC_2 , UART_5, STM_PIN_DATA(GPIO_Mode_AF, GPIO_OType_PP, GPIO_PuPd_UP, GPIO_AF_UART5)},
     {NC,    NC,     0}
 };
 
-#define UART_NUM (2)
+#define UART_NUM (5)
 
 static uint32_t serial_irq_ids[UART_NUM] = {0};
 
@@ -90,6 +100,16 @@
     if (obj->uart == UART_2) {
         RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2, ENABLE); 
     }
+     if (obj->uart == UART_3) {
+        RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART3, ENABLE); 
+    }
+     if (obj->uart == UART_4) {
+        RCC_APB1PeriphClockCmd(RCC_APB1Periph_UART4, ENABLE); 
+    }
+     if (obj->uart == UART_5) {
+        RCC_APB1PeriphClockCmd(RCC_APB1Periph_UART5, ENABLE); 
+    }
+    
             
     // Configure the UART pins
     pinmap_pinout(tx, PinMap_UART_TX);
@@ -108,6 +128,9 @@
     // The index is used by irq
     if (obj->uart == UART_1) obj->index = 0;
     if (obj->uart == UART_2) obj->index = 1;
+    if (obj->uart == UART_3) obj->index = 2;
+    if (obj->uart == UART_4) obj->index = 3;
+    if (obj->uart == UART_5) obj->index = 4;
     
     // For stdio management
     if (obj->uart == STDIO_UART) {
@@ -178,6 +201,9 @@
 
 static void uart1_irq(void) {uart_irq((USART_TypeDef*)UART_1, 0);}
 static void uart2_irq(void) {uart_irq((USART_TypeDef*)UART_2, 1);}
+static void uart3_irq(void) {uart_irq((USART_TypeDef*)UART_3, 2);}
+static void uart4_irq(void) {uart_irq((USART_TypeDef*)UART_4, 3);}
+static void uart5_irq(void) {uart_irq((USART_TypeDef*)UART_5, 4);}
 
 void serial_irq_handler(serial_t *obj, uart_irq_handler handler, uint32_t id) {
     irq_handler = handler;
@@ -199,6 +225,22 @@
       vector = (uint32_t)&uart2_irq;
     }
     
+    if (obj->uart == UART_3) {
+      irq_n = USART3_IRQn;
+      vector = (uint32_t)&uart3_irq;
+    }
+    
+    if (obj->uart == UART_4) {
+      irq_n = UART4_IRQn;
+      vector = (uint32_t)&uart4_irq;
+    }
+    
+    if (obj->uart == UART_5) {
+      irq_n = UART5_IRQn;
+      vector = (uint32_t)&uart5_irq;
+    }
+    
+    
     if (enable) {
       
         if (irq == RxIrq) {
--- a/targets/hal/TARGET_STM/TARGET_NUCLEO_L152RE/spi_api.c	Wed Mar 12 10:30:07 2014 +0000
+++ b/targets/hal/TARGET_STM/TARGET_NUCLEO_L152RE/spi_api.c	Fri Mar 14 10:00:07 2014 +0000
@@ -39,25 +39,41 @@
 static const PinMap PinMap_SPI_MOSI[] = {
     {PA_7,  SPI_1, STM_PIN_DATA(GPIO_Mode_AF, GPIO_OType_PP, GPIO_PuPd_UP, GPIO_AF_SPI1)}, 
     {PA_12, SPI_1, STM_PIN_DATA(GPIO_Mode_AF, GPIO_OType_PP, GPIO_PuPd_UP, GPIO_AF_SPI1)}, // REMAP
+    {PB_4,  SPI_1, STM_PIN_DATA(GPIO_Mode_AF, GPIO_OType_PP, GPIO_PuPd_UP, GPIO_AF_SPI1)}, // REMAP2
+    {PB_15, SPI_2, STM_PIN_DATA(GPIO_Mode_AF, GPIO_OType_PP, GPIO_PuPd_UP, GPIO_AF_SPI2)}, 
+    {PB_5,  SPI_3, STM_PIN_DATA(GPIO_Mode_AF, GPIO_OType_PP, GPIO_PuPd_UP, GPIO_AF_SPI3)}, 
+    {PC_12, SPI_3, STM_PIN_DATA(GPIO_Mode_AF, GPIO_OType_PP, GPIO_PuPd_UP, GPIO_AF_SPI3)}, // REMAP
+    
     {NC,    NC,    0}
 };
 
 static const PinMap PinMap_SPI_MISO[] = {
     {PA_6,  SPI_1, STM_PIN_DATA(GPIO_Mode_AF, GPIO_OType_PP, GPIO_PuPd_UP, GPIO_AF_SPI1)}, 
     {PA_11, SPI_1, STM_PIN_DATA(GPIO_Mode_AF, GPIO_OType_PP, GPIO_PuPd_UP, GPIO_AF_SPI1)}, // REMAP
+    {PB_5,  SPI_1, STM_PIN_DATA(GPIO_Mode_AF, GPIO_OType_PP, GPIO_PuPd_UP, GPIO_AF_SPI1)}, // REMAP2
+    {PA_6,  SPI_1, STM_PIN_DATA(GPIO_Mode_AF, GPIO_OType_PP, GPIO_PuPd_UP, GPIO_AF_SPI1)},
+    {PB_14, SPI_2, STM_PIN_DATA(GPIO_Mode_AF, GPIO_OType_PP, GPIO_PuPd_UP, GPIO_AF_SPI2)},
+    {PB_4 , SPI_3, STM_PIN_DATA(GPIO_Mode_AF, GPIO_OType_PP, GPIO_PuPd_UP, GPIO_AF_SPI3)},
+    {PC_11, SPI_3, STM_PIN_DATA(GPIO_Mode_AF, GPIO_OType_PP, GPIO_PuPd_UP, GPIO_AF_SPI3)},
     {NC,    NC,    0}
 };
 
 static const PinMap PinMap_SPI_SCLK[] = {
     {PA_5,  SPI_1, STM_PIN_DATA(GPIO_Mode_AF, GPIO_OType_PP, GPIO_PuPd_UP, GPIO_AF_SPI1)}, 
     {PB_3,  SPI_1, STM_PIN_DATA(GPIO_Mode_AF, GPIO_OType_PP, GPIO_PuPd_UP, GPIO_AF_SPI1)}, // REMAP
+    {PB_13, SPI_2, STM_PIN_DATA(GPIO_Mode_AF, GPIO_OType_PP, GPIO_PuPd_UP, GPIO_AF_SPI2)},
+    {PB_3,  SPI_3, STM_PIN_DATA(GPIO_Mode_AF, GPIO_OType_PP, GPIO_PuPd_UP, GPIO_AF_SPI3)},
+    {PC_10, SPI_3, STM_PIN_DATA(GPIO_Mode_AF, GPIO_OType_PP, GPIO_PuPd_UP, GPIO_AF_SPI3)},
     {NC,    NC,    0}
 };
 
 // Only used in Slave mode
 static const PinMap PinMap_SPI_SSEL[] = {
     {PA_4,  SPI_1, STM_PIN_DATA(GPIO_Mode_AF, GPIO_OType_PP, GPIO_PuPd_UP, GPIO_AF_SPI1)}, 
-    {PA_15,  SPI_1, STM_PIN_DATA(GPIO_Mode_AF, GPIO_OType_PP, GPIO_PuPd_UP, GPIO_AF_SPI1)}, // REMAP
+    {PA_15, SPI_1, STM_PIN_DATA(GPIO_Mode_AF, GPIO_OType_PP, GPIO_PuPd_UP, GPIO_AF_SPI1)}, // REMAP
+    {PB_12, SPI_2, STM_PIN_DATA(GPIO_Mode_AF, GPIO_OType_PP, GPIO_PuPd_UP, GPIO_AF_SPI2)},
+    {PA_4 , SPI_3, STM_PIN_DATA(GPIO_Mode_AF, GPIO_OType_PP, GPIO_PuPd_UP, GPIO_AF_SPI3)},
+    {PA_15, SPI_3, STM_PIN_DATA(GPIO_Mode_AF, GPIO_OType_PP, GPIO_PuPd_UP, GPIO_AF_SPI3)}, 
     {NC,    NC,    0}
 };
 
@@ -104,6 +120,9 @@
     if (obj->spi == SPI_2) {
         RCC_APB1PeriphClockCmd(RCC_APB1Periph_SPI2, ENABLE); 
     }
+    if (obj->spi == SPI_3) {
+        RCC_APB1PeriphClockCmd(RCC_APB1Periph_SPI3, ENABLE); 
+    }
     
     // Configure the SPI pins
     pinmap_pinout(mosi, PinMap_SPI_MOSI);