Skip to content
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

STM32G4 : enable UART ASYNC #15269

Merged
merged 2 commits into from
Apr 26, 2022
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
2 changes: 2 additions & 0 deletions targets/TARGET_STM/TARGET_STM32G4/PeripheralNames.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ typedef enum {
UART_1 = (int)USART1_BASE,
UART_2 = (int)USART2_BASE,
UART_3 = (int)USART3_BASE,
#if defined UART4_BASE
UART_4 = (int)UART4_BASE,
#endif
#if defined UART5_BASE
UART_5 = (int)UART5_BASE,
#endif
Expand Down
41 changes: 32 additions & 9 deletions targets/TARGET_STM/TARGET_STM32G4/serial_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,13 @@

#include "serial_api_hal.h"

#if defined (STM32GBK1CB)
#define UART_NUM (4)
#elif defined (STM32G431xx) || defined (STM32G441xx)
#define UART_NUM (5)
#else
#define UART_NUM (6)

#endif

uint32_t serial_irq_ids[UART_NUM] = {0};
UART_HandleTypeDef uart_handlers[UART_NUM];
Expand Down Expand Up @@ -80,13 +85,20 @@ static void uart3_irq(void)
}
#endif

#if defined(USART4_BASE)
#if defined(UART4_BASE)
static void uart4_irq(void)
{
uart_irq(UART_4);
}
#endif

#if defined(UART5_BASE)
static void uart5_irq(void)
{
uart_irq(UART_5);
}
#endif

#if defined(LPUART1_BASE)
static void lpuart1_irq(void)
{
Expand Down Expand Up @@ -130,13 +142,20 @@ void serial_irq_set(serial_t *obj, SerialIrq irq, uint32_t enable)
}
#endif

#if defined(USART4_BASE)
#if defined(UART4_BASE)
if (obj_s->uart == UART_4) {
irq_n = USART3_4_LPUART1_IRQn;
irq_n = UART4_IRQn;
vector = (uint32_t)&uart4_irq;
}
#endif

#if defined(UART5_BASE)
if (obj_s->uart == UART_5) {
irq_n = UART5_IRQn;
vector = (uint32_t)&uart5_irq;
}
#endif

#if defined(LPUART1_BASE)
if (obj_s->uart == LPUART_1) {
irq_n = LPUART1_IRQn;
Expand Down Expand Up @@ -318,18 +337,22 @@ static IRQn_Type serial_get_irq_n(UARTName uart_name)
#endif
#if defined(USART3_BASE)
case UART_3:
irq_n = USART3_4_LPUART1_IRQn;
irq_n = USART3_IRQn;
break;
#endif
#if defined(USART4_BASE)
#if defined(UART4_BASE)
case UART_4:
irq_n = USART3_4_LPUART1_IRQn;
irq_n = UART4_IRQn;
break;
#endif
#if defined(UART5_BASE)
case UART_5:
irq_n = UART5_IRQn;
break;
#endif

#if defined(LPUART1_BASE)
case LPUART_1:
irq_n = USART3_4_LPUART1_IRQn;
irq_n = LPUART1_IRQn;
break;
#endif
default:
Expand Down
1 change: 1 addition & 0 deletions targets/targets.json
Original file line number Diff line number Diff line change
Expand Up @@ -2973,6 +2973,7 @@
"ANALOGOUT",
"FLASH",
"MPU",
"SERIAL_ASYNCH",
"TRNG",
"CAN"
]
Expand Down