if(res == pdTRUE) {
UART_ENTER_CRITICAL(&uart_spinlock[uart_num]);
p_uart_obj[uart_num]->rx_buffered_len += p_uart_obj[uart_num]->rx_stash_len;
- UART_EXIT_CRITICAL(&uart_spinlock[uart_num]);
p_uart_obj[uart_num]->rx_buffer_full_flg = false;
+ UART_EXIT_CRITICAL(&uart_spinlock[uart_num]);
uart_enable_rx_intr(p_uart_obj[uart_num]->uart_num);
}
}
}
data = (uint8_t*) xRingbufferReceive(p_uart->rx_ring_buf, &size, (portTickType) 0);
if(data == NULL) {
+ if( p_uart_obj[uart_num]->rx_buffered_len != 0 ) {
+ ESP_LOGE(UART_TAG, "rx_buffered_len error");
+ p_uart_obj[uart_num]->rx_buffered_len = 0;
+ }
+ //We also need to clear the `rx_buffer_full_flg` here.
+ UART_ENTER_CRITICAL(&uart_spinlock[uart_num]);
+ p_uart_obj[uart_num]->rx_buffer_full_flg = false;
+ UART_EXIT_CRITICAL(&uart_spinlock[uart_num]);
break;
}
UART_ENTER_CRITICAL(&uart_spinlock[uart_num]);
if(res == pdTRUE) {
UART_ENTER_CRITICAL(&uart_spinlock[uart_num]);
p_uart_obj[uart_num]->rx_buffered_len += p_uart_obj[uart_num]->rx_stash_len;
- UART_EXIT_CRITICAL(&uart_spinlock[uart_num]);
p_uart_obj[uart_num]->rx_buffer_full_flg = false;
+ UART_EXIT_CRITICAL(&uart_spinlock[uart_num]);
}
}
}