Merge branch 'bugfix/fix_fifo_cnt_bug_v3.3' into 'release/v3.3'

bugfix(uart): fix esp32 uart fifo_cnt bug(backport v3.3)

See merge request espressif/esp-idf!9042
This commit is contained in:
Michael (XIAO Xufeng) 2020-06-18 01:43:04 +08:00
commit 2aaf254d44

View file

@ -865,6 +865,17 @@ static void uart_rx_intr_handler_default(void *param)
|| (uart_intr_status & UART_AT_CMD_CHAR_DET_INT_ST_M)
) {
rx_fifo_len = uart_reg->status.rxfifo_cnt;
typeof(uart_reg->mem_rx_status) rx_status = uart_reg->mem_rx_status;
// When using DPort to read fifo, fifo_cnt is not credible, we need to calculate the real cnt based on the fifo read and write pointer.
// When using AHB to read FIFO, we can use fifo_cnt to indicate the data length in fifo.
if (rx_status.wr_addr > rx_status.rd_addr) {
rx_fifo_len = rx_status.wr_addr - rx_status.rd_addr;
} else if (rx_status.wr_addr < rx_status.rd_addr) {
rx_fifo_len = (rx_status.wr_addr + 128) - rx_status.rd_addr;
} else {
rx_fifo_len = rx_fifo_len > 0 ? 128 : 0;
}
if(pat_flg == 1) {
uart_intr_status |= UART_AT_CMD_CHAR_DET_INT_ST_M;
pat_flg = 0;