Skip to content

Commit f9b42bc

Browse files
bjarki-andreasenMaureenHelm
authored andcommitted
drivers: serial: uart_stm32.c: RxDataFlush on async_rx_enable
When enabling async RX the first time after boot, there is an additional byte received with the first RX_DATA_RDY event, which seems to be caused by the RX data not being flushed before enabling the UART RX DMA. Adding a request to flush the RX data register before enabling the RX DMA, solves the issue. Signed-off-by: Bjarki Arge Andreasen <[email protected]>
1 parent 26fd55e commit f9b42bc

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

drivers/serial/uart_stm32.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1579,6 +1579,13 @@ static int uart_stm32_async_rx_enable(const struct device *dev,
15791579
return -EFAULT;
15801580
}
15811581

1582+
/* Flush RX data buffer */
1583+
#ifdef USART_SR_RXNE
1584+
LL_USART_ClearFlag_RXNE(config->usart);
1585+
#else
1586+
LL_USART_RequestRxDataFlush(config->usart);
1587+
#endif /* USART_SR_RXNE */
1588+
15821589
/* Enable RX DMA requests */
15831590
uart_stm32_dma_rx_enable(dev);
15841591

0 commit comments

Comments
 (0)