I've tested two scenarios using a hardware loopback to test UART functionality. The double buffer approach does not work as expected.
SDK version 1.6.1
CONFIG_SERIAL=y
CONFIG_UART_ASYNC_API=y
- Single buffer works as expected:
- Setup a buffer of X bytes
- Enable UART RX, get UART_RX_BUF_REQUEST event and ignore it.
- Transmit X-1 bytes.
- Get UART_TX_DONE event
- I successfully get an UART_RX_RDY event after X-1 bytes are received.
- Double buffer does not work as expected example 1
- Setup two buffers of X bytes
- Enable UART RX with buffer_1
- Get UART_RX_BUF_REQUEST event and pass in buffer_2
- Transmit X-1 bytes (less than one buffer's worth)
- Get UART_TX_DONE event
- Then, nothing! - Here I'm expecting UART_RX_RDY event to signify no more characters have come in.
- Double buffer does not work as expected example 2
- Setup two buffers of X bytes
- Enable UART RX with buffer_1
- Get UART_RX_BUF_REQUEST event and pass in buffer_2
- Transmit X+1 bytes.
- Get UART_RX_RDY
UART_RX_BUF_RELEASED (buffer_1)
UART_RX_BUF_REQUEST-> pass in buffer_1 back in - Get UART_TX_DONE event
- Then, nothing! - Here I'm expecting another UART_RX_RDY event to signify no more characters have come in.
What might I be doing wrong? I can confirm the data is in the buffers as expected through the debug watch window.