Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of mbed-src by
Revision 165:46e3636d4af7, committed 2014-04-22
- Comitter:
- mbed_official
- Date:
- Tue Apr 22 15:00:07 2014 +0100
- Parent:
- 164:90c6009cba07
- Child:
- 166:cb4253f91ada
- Commit message:
- Synchronized with git revision 14ad8773c432d34f478954f00a97bfef2aa40439
Full URL: https://github.com/mbedmicro/mbed/commit/14ad8773c432d34f478954f00a97bfef2aa40439/
Update serial_api.c
Changed in this revision
--- a/targets/hal/TARGET_STM/TARGET_DISCO_F100RB/PeripheralNames.h Tue Apr 22 14:45:07 2014 +0100 +++ b/targets/hal/TARGET_STM/TARGET_DISCO_F100RB/PeripheralNames.h Tue Apr 22 15:00:07 2014 +0100 @@ -43,7 +43,8 @@ typedef enum { UART_1 = (int)USART1_BASE, - UART_2 = (int)USART2_BASE + UART_2 = (int)USART2_BASE, + UART_3 = (int)USART3_BASE } UARTName; #define STDIO_UART_TX PA_2
--- a/targets/hal/TARGET_STM/TARGET_DISCO_F100RB/serial_api.c Tue Apr 22 14:45:07 2014 +0100 +++ b/targets/hal/TARGET_STM/TARGET_DISCO_F100RB/serial_api.c Tue Apr 22 15:00:07 2014 +0100 @@ -34,20 +34,22 @@ #include <string.h> static const PinMap PinMap_UART_TX[] = { - {PA_9, UART_1, STM_PIN_DATA(GPIO_Mode_AF_PP, 0)}, - {PA_2, UART_2, STM_PIN_DATA(GPIO_Mode_AF_PP, 0)}, - {NC, NC, 0} + {PA_9, UART_1, STM_PIN_DATA(GPIO_Mode_AF_PP, 0)}, + {PA_2, UART_2, STM_PIN_DATA(GPIO_Mode_AF_PP, 0)}, + {PB_10, UART_3, STM_PIN_DATA(GPIO_Mode_AF_PP, 0)}, + {NC, NC, 0} }; static const PinMap PinMap_UART_RX[] = { - {PA_10, UART_1, STM_PIN_DATA(GPIO_Mode_IN_FLOATING, 0)}, - {PA_3, UART_2, STM_PIN_DATA(GPIO_Mode_IN_FLOATING, 0)}, - {NC, NC, 0} + {PA_10, UART_1, STM_PIN_DATA(GPIO_Mode_IN_FLOATING, 0)}, + {PA_3, UART_2, STM_PIN_DATA(GPIO_Mode_IN_FLOATING, 0)}, + {PB_11, UART_3, STM_PIN_DATA(GPIO_Mode_IN_FLOATING, 0)}, + {NC, NC, 0} }; -#define UART_NUM (2) +#define UART_NUM (3) -static uint32_t serial_irq_ids[UART_NUM] = {0}; +static uint32_t serial_irq_ids[UART_NUM] = {0,0,0}; static uart_irq_handler irq_handler; @@ -86,9 +88,10 @@ // Enable USART clock if (obj->uart == UART_1) { RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE); - } - if (obj->uart == UART_2) { - RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2, ENABLE); + } else if (obj->uart == UART_2 ) { + RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2, ENABLE); + } else if (obj->uart == UART_3 ) { + RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART3, ENABLE); } // Configure the UART pins @@ -106,6 +109,7 @@ // 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; // For stdio management if (obj->uart == STDIO_UART) { @@ -176,6 +180,7 @@ 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);} void serial_irq_handler(serial_t *obj, uart_irq_handler handler, uint32_t id) { irq_handler = handler; @@ -196,7 +201,12 @@ irq_n = USART2_IRQn; vector = (uint32_t)&uart2_irq; } - + + if (obj->uart == UART_3) { + irq_n = USART3_IRQn; + vector = (uint32_t)&uart3_irq; + } + if (enable) { if (irq == RxIrq) {