serial: stm32: Give H/W a chance to set the TXE bit on transfer

It is possible to evaluate the TXE bit *before* H/W has had the
opportunity to detect that data is being processed.  Therefore
we should hold off on any evaluation until TXE has initially been
set.

Change-Id: Iff26bfbe3ab419734003bf81a4cb357de83908e7
Signed-off-by: Lee Jones <lee.jones@linaro.org>
This commit is contained in:
Lee Jones 2017-02-16 11:36:40 +00:00
commit 49c2858d94

View file

@ -101,6 +101,13 @@ static int uart_stm32_fifo_fill(struct device *dev, const uint8_t *tx_data,
#else
LL_USART_TransmitData8(UartHandle->Instance, tx_data[num_tx++]);
#endif
/*
* Wait for H/W to set TXE flag, or else it will be evaluated
* again at the top of this loop *before* H/W has chance to
* initially detect that data is being processed.
*/
while (!__HAL_UART_GET_FLAG(UartHandle, UART_FLAG_TXE))
;
}
return num_tx;