[UART] UART fifo_cnt does not indicate the data length in FIFO correctly
Description
When software uses DPORT to read UART fifo_cnt, and such operation is interrupted, then fifo_cnt will decrement by 1 erroneously.
Workarounds
When using DPort to read fifo, calculate the real count based on the FIFO read and write offset address. For example:
if (wr_addr > rd_addr) {
len = wr_addr - rd_addr;
} else if (wr_addr < rd_addr){
len = (wr_addr + 128) - rd_addr;
} else {
len = fifo_cnt > 0 ? 128 : 0;
}
In the above code snippet, wr_addr
represents the FIFO write offset address, rd_addr
represents the FIFO read offset address, fifo_cnt
represents the number of valid bytes in the FIFO, len
represents the correct number of valid bytes after calculation.
Solution
No fix scheduled.