drivers/console: Fix flush data on uart_pipe_setup

This patch fixes drain of data left in UART Rx fifo.
uart_irq_tx_ready checks if Rx IRQ has been raised,
but because Rx IRQ is disabled this won't work even
if there are some data left in the UART buffers.
So simply uart_fifo_read is used to discard the data that
left in UART buffer.

Change-Id: I17f145ba58640650bafd3602412fc75229f39664
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
This commit is contained in:
Mariusz Skamra 2016-03-24 13:51:26 +01:00 committed by Johan Hedberg
parent 15dc9f326e
commit 4800266cc6

View file

@ -74,14 +74,14 @@ int uart_pipe_send(const uint8_t *data, int len)
static void uart_pipe_setup(struct device *uart)
{
uint8_t c;
uart_irq_rx_disable(uart);
uart_irq_tx_disable(uart);
/* Drain the fifo */
while (uart_irq_rx_ready(uart)) {
unsigned char c;
uart_fifo_read(uart, &c, 1);
while (uart_fifo_read(uart, &c, 1)) {
continue;
}
uart_irq_callback_set(uart, uart_pipe_isr);