mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
bugfix(uart): fix esp32 uart fifo_cnt bug
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.
This commit is contained in:
parent
695ad84654
commit
f75088d40d
@ -885,6 +885,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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user