Skip to content

Commit 12ca9e8

Browse files
chemicstryme-no-dev
authored andcommitted
Port UART reset fix from ESP-IDF (espressif#1408)
1 parent 8b01b9e commit 12ca9e8

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

Diff for: cores/esp32/esp32-hal-uart.c

+7-4
Original file line numberDiff line numberDiff line change
@@ -315,11 +315,14 @@ void uartFlush(uart_t* uart)
315315
UART_MUTEX_LOCK();
316316
while(uart->dev->status.txfifo_cnt);
317317

318-
uart->dev->conf0.txfifo_rst = 1;
319-
uart->dev->conf0.txfifo_rst = 0;
318+
//Due to hardware issue, we can not use fifo_rst to reset uart fifo.
319+
//See description about UART_TXFIFO_RST and UART_RXFIFO_RST in <<esp32_technical_reference_manual>> v2.6 or later.
320+
321+
// we read the data out and make `fifo_len == 0 && rd_addr == wr_addr`.
322+
while(uart->dev->status.rxfifo_cnt != 0 || (uart->dev->mem_rx_status.wr_addr != uart->dev->mem_rx_status.rd_addr)) {
323+
READ_PERI_REG(UART_FIFO_REG(uart->num));
324+
}
320325

321-
uart->dev->conf0.rxfifo_rst = 1;
322-
uart->dev->conf0.rxfifo_rst = 0;
323326
UART_MUTEX_UNLOCK();
324327
}
325328

0 commit comments

Comments
 (0)