Skip to content

Commit 7caaafa

Browse files
authored
Merge pull request #1881 from uestczyh222/f4-uart
[Bsp][stm32f4xx-hal]更新串口宏
2 parents 57303c1 + bcfba03 commit 7caaafa

File tree

2 files changed

+26
-21
lines changed

2 files changed

+26
-21
lines changed

bsp/stm32f4xx-HAL/Kconfig

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -297,20 +297,24 @@ config RT_HSE_VALUE
297297
config RT_HSE_HCLK
298298
int "System Clock Value"
299299
default 84000000
300-
config RT_USING_UART1
300+
config BSP_USING_UART1
301301
bool "Using UART1"
302+
select RT_USING_SERIAL
302303
default y
303304

304-
config RT_USING_UART2
305+
config BSP_USING_UART2
305306
bool "Using UART2"
307+
select RT_USING_SERIAL
306308
default n
307309

308-
config RT_USING_UART3
310+
config BSP_USING_UART3
309311
bool "Using UART3"
312+
select RT_USING_SERIAL
310313
default n
311314

312-
config RT_USING_UART6
315+
config BSP_USING_UART6
313316
bool "Using UART6"
317+
select RT_USING_SERIAL
314318
default n
315319

316320
if RT_USING_CAN

bsp/stm32f4xx-HAL/drivers/drv_usart.c

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ static const struct rt_uart_ops drv_uart_ops =
147147
drv_getc,
148148
};
149149

150-
#if defined(RT_USING_UART1)
150+
#if defined(BSP_USING_UART1)
151151
/* UART1 device driver structure */
152152
static struct drv_uart uart1;
153153
struct rt_serial_device serial1;
@@ -168,9 +168,9 @@ void USART1_IRQHandler(void)
168168
/* leave interrupt */
169169
rt_interrupt_leave();
170170
}
171-
#endif /* RT_USING_UART1 */
171+
#endif /* BSP_USING_UART1 */
172172

173-
#if defined(RT_USING_UART2)
173+
#if defined(BSP_USING_UART2)
174174
/* UART2 device driver structure */
175175
static struct drv_uart uart2;
176176
struct rt_serial_device serial2;
@@ -191,9 +191,9 @@ void USART2_IRQHandler(void)
191191
/* leave interrupt */
192192
rt_interrupt_leave();
193193
}
194-
#endif /* RT_USING_UART2 */
194+
#endif /* BSP_USING_UART2 */
195195

196-
#if defined(RT_USING_UART3)
196+
#if defined(BSP_USING_UART3)
197197
/* UART3 device driver structure */
198198
static struct drv_uart uart3;
199199
struct rt_serial_device serial3;
@@ -214,9 +214,9 @@ void USART3_IRQHandler(void)
214214
/* leave interrupt */
215215
rt_interrupt_leave();
216216
}
217-
#endif /* RT_USING_UART3 */
217+
#endif /* BSP_USING_UART3 */
218218

219-
#if defined(RT_USING_UART6)
219+
#if defined(BSP_USING_UART6)
220220
/* UART6 device driver structure */
221221
static struct drv_uart uart6;
222222
struct rt_serial_device serial6;
@@ -237,7 +237,7 @@ void USART6_IRQHandler(void)
237237
/* leave interrupt */
238238
rt_interrupt_leave();
239239
}
240-
#endif /* RT_USING_UART6 */
240+
#endif /* BSP_USING_UART6 */
241241

242242
/**
243243
* @brief UART MSP Initialization
@@ -365,7 +365,7 @@ int hw_usart_init(void)
365365
{
366366
struct drv_uart *uart;
367367
struct serial_configure config = RT_SERIAL_CONFIG_DEFAULT;
368-
#ifdef RT_USING_UART1
368+
#ifdef BSP_USING_UART1
369369
uart = &uart1;
370370
uart->UartHandle.Instance = USART1;
371371
uart->irq = USART1_IRQn;
@@ -375,8 +375,8 @@ int hw_usart_init(void)
375375
rt_hw_serial_register(&serial1, "uart1",
376376
RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX,
377377
uart);
378-
#endif /* RT_USING_UART1 */
379-
#ifdef RT_USING_UART2
378+
#endif /* BSP_USING_UART1 */
379+
#ifdef BSP_USING_UART2
380380
uart = &uart2;
381381
uart->UartHandle.Instance = USART2;
382382
uart->irq = USART2_IRQn;
@@ -386,8 +386,8 @@ int hw_usart_init(void)
386386
rt_hw_serial_register(&serial2, "uart2",
387387
RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX,
388388
uart);
389-
#endif /* RT_USING_UART2 */
390-
#ifdef RT_USING_UART3
389+
#endif /* BSP_USING_UART2 */
390+
#ifdef BSP_USING_UART3
391391
uart = &uart3;
392392
uart->UartHandle.Instance = USART3;
393393
uart->irq = USART3_IRQn;
@@ -397,18 +397,19 @@ int hw_usart_init(void)
397397
rt_hw_serial_register(&serial3, "uart3",
398398
RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX,
399399
uart);
400-
#endif /* RT_USING_UART3 */
401-
#ifdef RT_USING_UART6
400+
#endif /* BSP_USING_UART3 */
401+
#ifdef BSP_USING_UART6
402402
uart = &uart6;
403403
uart->UartHandle.Instance = USART6;
404404
uart->irq = USART6_IRQn;
405405
serial6.ops = &drv_uart_ops;
406406
serial6.config = config;
407-
/* register UART2 device */
407+
/* register UART6 device */
408408
rt_hw_serial_register(&serial6, "uart6",
409409
RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX,
410410
uart);
411-
#endif /* RT_USING_UART6 */
411+
#endif /* BSP_USING_UART6 */
412+
412413
return 0;
413414
}
414415
INIT_BOARD_EXPORT(hw_usart_init);

0 commit comments

Comments
 (0)