File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments