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;