Skip to content

enable the additional uart 7&8 of the STM32F439 in the mbed sdk/api #923

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 20, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}
};

Expand Down
56 changes: 54 additions & 2 deletions libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32F4/serial_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@
#include <string.h>
#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;

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down