From b2190fd703cb343415d81926bd76aadacdb824e5 Mon Sep 17 00:00:00 2001 From: Andrea Campanella Date: Tue, 21 Dec 2021 16:09:15 +0000 Subject: [PATCH] drivers: serial: stm32: Add Line Break Detection The current driver doesn't handle the LBD flag, this leads uart_stm32_err_check to return always true if a Line Break is detected. This PR adds Line Break Detection and the related flag clearing, F0 series it's excluded from the changes. Fixes zephyrproject-rtos#41339 Signed-off-by: Andrea Campanella --- drivers/serial/uart_stm32.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/serial/uart_stm32.c b/drivers/serial/uart_stm32.c index 7f4cd1026e7..e387602fd0a 100644 --- a/drivers/serial/uart_stm32.c +++ b/drivers/serial/uart_stm32.c @@ -586,6 +586,16 @@ static int uart_stm32_err_check(const struct device *dev) err |= UART_ERROR_FRAMING; } +#if !defined(CONFIG_SOC_SERIES_STM32F0X) || defined(USART_LIN_SUPPORT) + if (LL_USART_IsActiveFlag_LBD(UartInstance)) { + err |= UART_BREAK; + } + + if (err & UART_BREAK) { + LL_USART_ClearFlag_LBD(UartInstance); + } +#endif + if (err & UART_ERROR_OVERRUN) { LL_USART_ClearFlag_ORE(UartInstance); } @@ -597,7 +607,6 @@ static int uart_stm32_err_check(const struct device *dev) if (err & UART_ERROR_FRAMING) { LL_USART_ClearFlag_FE(UartInstance); } - /* Clear noise error as well, * it is not represented by the errors enum */