drivers/serial: Move head/tail pointer reset to uart_recvchars_dma since dma may be still transferring in the background.

This commit is contained in:
Xiang Xiao
2018-08-26 10:03:30 -06:00
committed by Gregory Nutt
parent 4465cccdbd
commit 9e922873d4
2 changed files with 21 additions and 26 deletions
+14 -1
View File
@@ -199,8 +199,21 @@ void uart_recvchars_dma(FAR uart_dev_t *dev)
unsigned int watermark;
#endif
bool is_full;
int nexthead = rxbuf->head + 1;
int nexthead;
/* If RX buffer is empty move tail and head to zero position */
if (rxbuf->head == rxbuf->tail)
{
rxbuf->head = 0;
rxbuf->head = 0;
}
/* Get the next head index and check if there is room to adding another
* byte to the buffer.
*/
nexthead = rxbuf->head + 1;
if (nexthead >= rxbuf->size)
{
nexthead = 0;