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 <bjarki@arge-andreasen.me>
This commit is contained in:
Bjarki Arge Andreasen 2023-11-16 20:39:39 +01:00 committed by Maureen Helm
commit f9b42bc911

View file

@ -1579,6 +1579,13 @@ static int uart_stm32_async_rx_enable(const struct device *dev,
return -EFAULT;
}
/* Flush RX data buffer */
#ifdef USART_SR_RXNE
LL_USART_ClearFlag_RXNE(config->usart);
#else
LL_USART_RequestRxDataFlush(config->usart);
#endif /* USART_SR_RXNE */
/* Enable RX DMA requests */
uart_stm32_dma_rx_enable(dev);