From 5268ba70a0dbc8e38f8f9bc3a5daf371b9fdccb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?book=E8=AF=97=E6=84=8F?= Date: Mon, 10 Jan 2022 22:24:24 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A5=E5=85=85uart=E9=A9=B1=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- drivers/drv_usart.c | 41 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 37 insertions(+), 4 deletions(-) diff --git a/drivers/drv_usart.c b/drivers/drv_usart.c index 58018b3..af2563a 100644 --- a/drivers/drv_usart.c +++ b/drivers/drv_usart.c @@ -2,8 +2,8 @@ * @Description: * @Date: 2022-01-10 17:36:06 * @LastEditors: CK.Zh - * @LastEditTime: 2022-01-10 19:53:36 - * @FilePath: /motion_ec_rtt/drivers/drv_usart.c + * @LastEditTime: 2022-01-10 22:04:13 + * @FilePath: /motion_ec/drivers/drv_usart.c */ /* * @@ -23,8 +23,8 @@ #ifdef BSP_USING_UART #if !defined(BSP_USING_UART0) && !defined(BSP_USING_UART1) && !defined(BSP_USING_UART2) && \ - !defined(BSP_USING_UART3) - #error "Please define at least one BSP_USING_UARTx" + !defined(BSP_USING_UART3) && !defined(BSP_USING_LPUART0) && !defined(BSP_USING_LPUART1) + #error "Please define at least one BSP_USING_UARTx or BSP_USING_LPUARTx" /* this driver can be disabled at menuconfig -> RT-Thread Components -> Device Drivers */ #endif @@ -42,6 +42,12 @@ enum #ifdef BSP_USING_UART3 UART3_INDEX, #endif +#ifdef BSP_USING_LPUART0 + LPUART0_INDEX, +#endif +#ifdef BSP_USING_LPUART1 + LPUART1_INDEX, +#endif }; static struct hc_uart_cfg uart_cfg[] = @@ -287,6 +293,33 @@ void Uart3_IRQHandler(void) } #endif /* BSP_USING_UART3 */ +#if defined(BSP_USING_LPUART0) +void LpUart0_IRQHandler(void) +{ + /* enter interrupt */ + rt_interrupt_enter(); + + rt_hw_uart_isr(&(uart_drv[LPUART0_INDEX].serial_device)); + + /* leave interrupt */ + rt_interrupt_leave(); +} +#endif /* BSP_USING_LPUART0 */ + +#if defined(BSP_USING_LPUART1) +void LpUart1_IRQHandler(void) +{ + /* enter interrupt */ + rt_interrupt_enter(); + + rt_hw_uart_isr(&(uart_drv[LPUART1_INDEX].serial_device)); + + /* leave interrupt */ + rt_interrupt_leave(); +} +#endif /* BSP_USING_LPUART1 */ + + int rt_hw_uart_init(void) { struct serial_configure cfg = RT_SERIAL_CONFIG_DEFAULT;