From 4800266cc652a70572255affa14dd93846d701c3 Mon Sep 17 00:00:00 2001 From: Mariusz Skamra Date: Thu, 24 Mar 2016 13:51:26 +0100 Subject: 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 --- drivers/console/uart_pipe.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers/console/uart_pipe.c') diff --git a/drivers/console/uart_pipe.c b/drivers/console/uart_pipe.c index c8c89ae22..4b6b2bdc1 100644 --- a/drivers/console/uart_pipe.c +++ b/drivers/console/uart_pipe.c @@ -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); -- cgit v1.2.3