Port UART reset fix from ESP-IDF (#1408)

This commit is contained in:
chemicstry 2018-07-03 18:54:08 +03:00 committed by Me No Dev
parent 8b01b9e187
commit 12ca9e8b52

View File

@ -315,11 +315,14 @@ void uartFlush(uart_t* uart)
UART_MUTEX_LOCK(); UART_MUTEX_LOCK();
while(uart->dev->status.txfifo_cnt); while(uart->dev->status.txfifo_cnt);
uart->dev->conf0.txfifo_rst = 1; //Due to hardware issue, we can not use fifo_rst to reset uart fifo.
uart->dev->conf0.txfifo_rst = 0; //See description about UART_TXFIFO_RST and UART_RXFIFO_RST in <<esp32_technical_reference_manual>> v2.6 or later.
// we read the data out and make `fifo_len == 0 && rd_addr == wr_addr`.
while(uart->dev->status.rxfifo_cnt != 0 || (uart->dev->mem_rx_status.wr_addr != uart->dev->mem_rx_status.rd_addr)) {
READ_PERI_REG(UART_FIFO_REG(uart->num));
}
uart->dev->conf0.rxfifo_rst = 1;
uart->dev->conf0.rxfifo_rst = 0;
UART_MUTEX_UNLOCK(); UART_MUTEX_UNLOCK();
} }