Skip to content

Commit 88b6bb0

Browse files
authored
Merge pull request #15269 from jeromecoutant/PR_G4_UART_ASYNC
STM32G4 : enable UART ASYNC
2 parents d17beb7 + 1985e77 commit 88b6bb0

File tree

3 files changed

+35
-9
lines changed

3 files changed

+35
-9
lines changed

targets/TARGET_STM/TARGET_STM32G4/PeripheralNames.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ typedef enum {
5151
UART_1 = (int)USART1_BASE,
5252
UART_2 = (int)USART2_BASE,
5353
UART_3 = (int)USART3_BASE,
54+
#if defined UART4_BASE
5455
UART_4 = (int)UART4_BASE,
56+
#endif
5557
#if defined UART5_BASE
5658
UART_5 = (int)UART5_BASE,
5759
#endif

targets/TARGET_STM/TARGET_STM32G4/serial_device.c

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,13 @@
1717

1818
#include "serial_api_hal.h"
1919

20+
#if defined (STM32GBK1CB)
21+
#define UART_NUM (4)
22+
#elif defined (STM32G431xx) || defined (STM32G441xx)
23+
#define UART_NUM (5)
24+
#else
2025
#define UART_NUM (6)
21-
26+
#endif
2227

2328
uint32_t serial_irq_ids[UART_NUM] = {0};
2429
UART_HandleTypeDef uart_handlers[UART_NUM];
@@ -80,13 +85,20 @@ static void uart3_irq(void)
8085
}
8186
#endif
8287

83-
#if defined(USART4_BASE)
88+
#if defined(UART4_BASE)
8489
static void uart4_irq(void)
8590
{
8691
uart_irq(UART_4);
8792
}
8893
#endif
8994

95+
#if defined(UART5_BASE)
96+
static void uart5_irq(void)
97+
{
98+
uart_irq(UART_5);
99+
}
100+
#endif
101+
90102
#if defined(LPUART1_BASE)
91103
static void lpuart1_irq(void)
92104
{
@@ -130,13 +142,20 @@ void serial_irq_set(serial_t *obj, SerialIrq irq, uint32_t enable)
130142
}
131143
#endif
132144

133-
#if defined(USART4_BASE)
145+
#if defined(UART4_BASE)
134146
if (obj_s->uart == UART_4) {
135-
irq_n = USART3_4_LPUART1_IRQn;
147+
irq_n = UART4_IRQn;
136148
vector = (uint32_t)&uart4_irq;
137149
}
138150
#endif
139151

152+
#if defined(UART5_BASE)
153+
if (obj_s->uart == UART_5) {
154+
irq_n = UART5_IRQn;
155+
vector = (uint32_t)&uart5_irq;
156+
}
157+
#endif
158+
140159
#if defined(LPUART1_BASE)
141160
if (obj_s->uart == LPUART_1) {
142161
irq_n = LPUART1_IRQn;
@@ -318,18 +337,22 @@ static IRQn_Type serial_get_irq_n(UARTName uart_name)
318337
#endif
319338
#if defined(USART3_BASE)
320339
case UART_3:
321-
irq_n = USART3_4_LPUART1_IRQn;
340+
irq_n = USART3_IRQn;
322341
break;
323342
#endif
324-
#if defined(USART4_BASE)
343+
#if defined(UART4_BASE)
325344
case UART_4:
326-
irq_n = USART3_4_LPUART1_IRQn;
345+
irq_n = UART4_IRQn;
346+
break;
347+
#endif
348+
#if defined(UART5_BASE)
349+
case UART_5:
350+
irq_n = UART5_IRQn;
327351
break;
328352
#endif
329-
330353
#if defined(LPUART1_BASE)
331354
case LPUART_1:
332-
irq_n = USART3_4_LPUART1_IRQn;
355+
irq_n = LPUART1_IRQn;
333356
break;
334357
#endif
335358
default:

targets/targets.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2973,6 +2973,7 @@
29732973
"ANALOGOUT",
29742974
"FLASH",
29752975
"MPU",
2976+
"SERIAL_ASYNCH",
29762977
"TRNG",
29772978
"CAN"
29782979
]

0 commit comments

Comments
 (0)