Skip to content

Commit 9bcc486

Browse files
authored
Merge pull request #14976 from world-direct/feature/target_stm32f1
Add more uarts for STM32F103xG
2 parents 4dd08c4 + 727daf9 commit 9bcc486

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

targets/TARGET_STM/TARGET_STM32F1/serial_device.c

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,11 @@
3232

3333
#include "serial_api_hal.h"
3434

35+
#if defined(TARGET_STM32F103xG)
36+
#define UART_NUM (5)
37+
#else
3538
#define UART_NUM (3)
39+
#endif
3640

3741
uint32_t serial_irq_ids[UART_NUM] = {0};
3842
UART_HandleTypeDef uart_handlers[UART_NUM];
@@ -94,6 +98,20 @@ static void uart3_irq(void)
9498
}
9599
#endif
96100

101+
#if defined(USART4_BASE)
102+
static void uart4_irq(void)
103+
{
104+
uart_irq(UART_4);
105+
}
106+
#endif
107+
108+
#if defined(USART5_BASE)
109+
static void uart5_irq(void)
110+
{
111+
uart_irq(UART_5);
112+
}
113+
#endif
114+
97115
void serial_irq_handler(serial_t *obj, uart_irq_handler handler, uint32_t id)
98116
{
99117
struct serial_s *obj_s = SERIAL_S(obj);
@@ -130,6 +148,20 @@ void serial_irq_set(serial_t *obj, SerialIrq irq, uint32_t enable)
130148
}
131149
#endif
132150

151+
#if defined(USART4_BASE)
152+
if (obj_s->uart == UART_4) {
153+
irq_n = USART4_IRQn;
154+
vector = (uint32_t)&uart4_irq;
155+
}
156+
#endif
157+
158+
#if defined(USART5_BASE)
159+
if (obj_s->uart == UART_5) {
160+
irq_n = USART5_IRQn;
161+
vector = (uint32_t)&uart5_irq;
162+
}
163+
#endif
164+
133165
if (enable) {
134166
if (irq == RxIrq) {
135167
__HAL_UART_ENABLE_IT(huart, UART_IT_RXNE);
@@ -302,6 +334,16 @@ static IRQn_Type serial_get_irq_n(UARTName uart_name)
302334
case UART_3:
303335
irq_n = USART3_IRQn;
304336
break;
337+
#endif
338+
#if defined(USART4_BASE)
339+
case UART_4:
340+
irq_n = USART4_IRQn;
341+
break;
342+
#endif
343+
#if defined(USART5_BASE)
344+
case UART_5:
345+
irq_n = USART5_IRQn;
346+
break;
305347
#endif
306348
default:
307349
irq_n = (IRQn_Type)0;

0 commit comments

Comments
 (0)