From 1641dd7e8d32192c322872dfd265e5998771c7c3 Mon Sep 17 00:00:00 2001 From: mazgch Date: Fri, 20 Feb 2015 13:38:11 +0100 Subject: [PATCH] enable the additional uart 7&8 of the STM32F439 --- .../TARGET_UBLOX_C029/PeripheralNames.h | 4 +- .../TARGET_UBLOX_C029/PeripheralPins.c | 2 + .../TARGET_STM/TARGET_STM32F4/serial_api.c | 56 ++++++++++++++++++- 3 files changed, 59 insertions(+), 3 deletions(-) diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32F4/TARGET_UBLOX_C029/PeripheralNames.h b/libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32F4/TARGET_UBLOX_C029/PeripheralNames.h index c2de03ab09..47f03095d0 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32F4/TARGET_UBLOX_C029/PeripheralNames.h +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32F4/TARGET_UBLOX_C029/PeripheralNames.h @@ -53,7 +53,9 @@ typedef enum { UART_3 = (int)USART3_BASE, UART_4 = (int)UART4_BASE, UART_5 = (int)UART5_BASE, - UART_6 = (int)USART6_BASE + UART_6 = (int)USART6_BASE, + UART_7 = (int)UART7_BASE, + UART_8 = (int)UART8_BASE } UARTName; #define STDIO_UART_TX PD_8 diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32F4/TARGET_UBLOX_C029/PeripheralPins.c b/libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32F4/TARGET_UBLOX_C029/PeripheralPins.c index b139dafcc6..63720ea40b 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32F4/TARGET_UBLOX_C029/PeripheralPins.c +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32F4/TARGET_UBLOX_C029/PeripheralPins.c @@ -133,12 +133,14 @@ const PinMap PinMap_PWM[] = { const PinMap PinMap_UART_TX[] = { {PA_9, UART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, {PD_8, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + {PF_7, UART_7, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART7)}, {NC, NC, 0} }; const PinMap PinMap_UART_RX[] = { {PA_10, UART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, {PD_9, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + {PF_6, UART_7, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART7)}, {NC, NC, 0} }; diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32F4/serial_api.c b/libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32F4/serial_api.c index 3a8535bf5f..c89d1e5302 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32F4/serial_api.c +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32F4/serial_api.c @@ -37,9 +37,9 @@ #include #include "PeripheralPins.h" -#define UART_NUM (6) +#define UART_NUM (8) -static uint32_t serial_irq_ids[UART_NUM] = {0, 0, 0, 0, 0, 0}; +static uint32_t serial_irq_ids[UART_NUM] = {0, 0, 0, 0, 0, 0, 0, 0}; static uart_irq_handler irq_handler; @@ -111,6 +111,18 @@ void serial_init(serial_t *obj, PinName tx, PinName rx) __USART6_CLK_ENABLE(); obj->index = 5; break; +#if defined(UART7_BASE) + case UART_7: + __UART7_CLK_ENABLE(); + obj->index = 6; + break; +#endif +#if defined(UART8_BASE) + case UART_8: + __UART8_CLK_ENABLE(); + obj->index = 7; + break; +#endif } // Configure the UART pins @@ -181,6 +193,20 @@ void serial_free(serial_t *obj) __USART6_RELEASE_RESET(); __USART6_CLK_DISABLE(); break; +#if defined(UART7_BASE) + case UART_7: + __UART7_FORCE_RESET(); + __UART7_RELEASE_RESET(); + __UART7_CLK_DISABLE(); + break; +#endif +#if defined(UART8_BASE) + case UART_8: + __UART8_FORCE_RESET(); + __UART8_RELEASE_RESET(); + __UART8_CLK_DISABLE(); + break; +#endif } // Configure GPIOs pin_function(obj->pin_tx, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, 0)); @@ -281,6 +307,20 @@ static void uart6_irq(void) uart_irq(UART_6, 5); } +#if defined(UART7_BASE) +static void uart7_irq(void) +{ + uart_irq(UART_7, 6); +} +#endif + +#if defined(UART8_BASE) +static void uart8_irq(void) +{ + uart_irq(UART_8, 7); +} +#endif + void serial_irq_handler(serial_t *obj, uart_irq_handler handler, uint32_t id) { irq_handler = handler; @@ -326,6 +366,18 @@ void serial_irq_set(serial_t *obj, SerialIrq irq, uint32_t enable) irq_n = USART6_IRQn; vector = (uint32_t)&uart6_irq; break; +#if defined(UART7_BASE) + case UART_7: + irq_n = UART7_IRQn; + vector = (uint32_t)&uart7_irq; + break; +#endif +#if defined(UART8_BASE) + case UART_8: + irq_n = UART8_IRQn; + vector = (uint32_t)&uart8_irq; + break; +#endif } if (enable) {