Skip to content

Commit 86041dd

Browse files
committed
Merge pull request #923 from mazgch/master
enable the additional uart 7&8 of the STM32F439 in the mbed sdk/api
2 parents ca4aaa2 + 1641dd7 commit 86041dd

File tree

3 files changed

+59
-3
lines changed

3 files changed

+59
-3
lines changed

libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32F4/TARGET_UBLOX_C029/PeripheralNames.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@ typedef enum {
5353
UART_3 = (int)USART3_BASE,
5454
UART_4 = (int)UART4_BASE,
5555
UART_5 = (int)UART5_BASE,
56-
UART_6 = (int)USART6_BASE
56+
UART_6 = (int)USART6_BASE,
57+
UART_7 = (int)UART7_BASE,
58+
UART_8 = (int)UART8_BASE
5759
} UARTName;
5860

5961
#define STDIO_UART_TX PD_8

libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32F4/TARGET_UBLOX_C029/PeripheralPins.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,12 +133,14 @@ const PinMap PinMap_PWM[] = {
133133
const PinMap PinMap_UART_TX[] = {
134134
{PA_9, UART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)},
135135
{PD_8, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)},
136+
{PF_7, UART_7, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART7)},
136137
{NC, NC, 0}
137138
};
138139

139140
const PinMap PinMap_UART_RX[] = {
140141
{PA_10, UART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)},
141142
{PD_9, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)},
143+
{PF_6, UART_7, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART7)},
142144
{NC, NC, 0}
143145
};
144146

libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32F4/serial_api.c

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@
3737
#include <string.h>
3838
#include "PeripheralPins.h"
3939

40-
#define UART_NUM (6)
40+
#define UART_NUM (8)
4141

42-
static uint32_t serial_irq_ids[UART_NUM] = {0, 0, 0, 0, 0, 0};
42+
static uint32_t serial_irq_ids[UART_NUM] = {0, 0, 0, 0, 0, 0, 0, 0};
4343

4444
static uart_irq_handler irq_handler;
4545

@@ -111,6 +111,18 @@ void serial_init(serial_t *obj, PinName tx, PinName rx)
111111
__USART6_CLK_ENABLE();
112112
obj->index = 5;
113113
break;
114+
#if defined(UART7_BASE)
115+
case UART_7:
116+
__UART7_CLK_ENABLE();
117+
obj->index = 6;
118+
break;
119+
#endif
120+
#if defined(UART8_BASE)
121+
case UART_8:
122+
__UART8_CLK_ENABLE();
123+
obj->index = 7;
124+
break;
125+
#endif
114126
}
115127

116128
// Configure the UART pins
@@ -181,6 +193,20 @@ void serial_free(serial_t *obj)
181193
__USART6_RELEASE_RESET();
182194
__USART6_CLK_DISABLE();
183195
break;
196+
#if defined(UART7_BASE)
197+
case UART_7:
198+
__UART7_FORCE_RESET();
199+
__UART7_RELEASE_RESET();
200+
__UART7_CLK_DISABLE();
201+
break;
202+
#endif
203+
#if defined(UART8_BASE)
204+
case UART_8:
205+
__UART8_FORCE_RESET();
206+
__UART8_RELEASE_RESET();
207+
__UART8_CLK_DISABLE();
208+
break;
209+
#endif
184210
}
185211
// Configure GPIOs
186212
pin_function(obj->pin_tx, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, 0));
@@ -281,6 +307,20 @@ static void uart6_irq(void)
281307
uart_irq(UART_6, 5);
282308
}
283309

310+
#if defined(UART7_BASE)
311+
static void uart7_irq(void)
312+
{
313+
uart_irq(UART_7, 6);
314+
}
315+
#endif
316+
317+
#if defined(UART8_BASE)
318+
static void uart8_irq(void)
319+
{
320+
uart_irq(UART_8, 7);
321+
}
322+
#endif
323+
284324
void serial_irq_handler(serial_t *obj, uart_irq_handler handler, uint32_t id)
285325
{
286326
irq_handler = handler;
@@ -326,6 +366,18 @@ void serial_irq_set(serial_t *obj, SerialIrq irq, uint32_t enable)
326366
irq_n = USART6_IRQn;
327367
vector = (uint32_t)&uart6_irq;
328368
break;
369+
#if defined(UART7_BASE)
370+
case UART_7:
371+
irq_n = UART7_IRQn;
372+
vector = (uint32_t)&uart7_irq;
373+
break;
374+
#endif
375+
#if defined(UART8_BASE)
376+
case UART_8:
377+
irq_n = UART8_IRQn;
378+
vector = (uint32_t)&uart8_irq;
379+
break;
380+
#endif
329381
}
330382

331383
if (enable) {

0 commit comments

Comments
 (0)