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 <andrea.campanella@helvar.com>
diff --git a/drivers/serial/uart_stm32.c b/drivers/serial/uart_stm32.c
index 7f4cd10..e387602 100644
--- a/drivers/serial/uart_stm32.c
+++ b/drivers/serial/uart_stm32.c
@@ -586,6 +586,16 @@
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 @@
if (err & UART_ERROR_FRAMING) {
LL_USART_ClearFlag_FE(UartInstance);
}
-
/* Clear noise error as well,
* it is not represented by the errors enum
*/