From fb4f1333d256f524ae340a4413f81efecd73fd58 Mon Sep 17 00:00:00 2001 From: me-no-dev Date: Thu, 6 Oct 2016 16:31:28 +0300 Subject: [PATCH] Fix UART writeBuf and flush --- cores/esp32/esp32-hal-uart.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/cores/esp32/esp32-hal-uart.c b/cores/esp32/esp32-hal-uart.c index 6739dd2a..fc018241 100644 --- a/cores/esp32/esp32-hal-uart.c +++ b/cores/esp32/esp32-hal-uart.c @@ -170,9 +170,11 @@ void uartWrite(uart_t* uart, uint8_t c) void uartWriteBuf(uart_t* uart, const uint8_t * data, size_t len) { - while(len && uart->dev->status.rxfifo_cnt < 0x7F) { - uart->dev->fifo.rw_byte = *data++; - len--; + while(len) { + while(len && uart->dev->status.txfifo_cnt < 0x7F) { + uart->dev->fifo.rw_byte = *data++; + len--; + } } } @@ -189,8 +191,8 @@ void uartFlush(uart_t* uart) } if(uart->txEnabled) { - tmp |= UART_TXFIFO_RST; while(uart->dev->status.txfifo_cnt); + tmp |= UART_TXFIFO_RST; } uart->dev->conf0.val |= (tmp);