driver(uart):Fix the bug that uart buffer_full flag is true all the time.
This commit is contained in:
parent
af2cb3ba8b
commit
33b99caf50
|
@ -1159,8 +1159,8 @@ int uart_read_bytes(uart_port_t uart_num, uint8_t* buf, uint32_t length, TickTyp
|
||||||
if(res == pdTRUE) {
|
if(res == pdTRUE) {
|
||||||
UART_ENTER_CRITICAL(&uart_spinlock[uart_num]);
|
UART_ENTER_CRITICAL(&uart_spinlock[uart_num]);
|
||||||
p_uart_obj[uart_num]->rx_buffered_len += p_uart_obj[uart_num]->rx_stash_len;
|
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;
|
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);
|
uart_enable_rx_intr(p_uart_obj[uart_num]->uart_num);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1205,6 +1205,14 @@ esp_err_t uart_flush_input(uart_port_t uart_num)
|
||||||
}
|
}
|
||||||
data = (uint8_t*) xRingbufferReceive(p_uart->rx_ring_buf, &size, (portTickType) 0);
|
data = (uint8_t*) xRingbufferReceive(p_uart->rx_ring_buf, &size, (portTickType) 0);
|
||||||
if(data == NULL) {
|
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;
|
break;
|
||||||
}
|
}
|
||||||
UART_ENTER_CRITICAL(&uart_spinlock[uart_num]);
|
UART_ENTER_CRITICAL(&uart_spinlock[uart_num]);
|
||||||
|
@ -1217,8 +1225,8 @@ esp_err_t uart_flush_input(uart_port_t uart_num)
|
||||||
if(res == pdTRUE) {
|
if(res == pdTRUE) {
|
||||||
UART_ENTER_CRITICAL(&uart_spinlock[uart_num]);
|
UART_ENTER_CRITICAL(&uart_spinlock[uart_num]);
|
||||||
p_uart_obj[uart_num]->rx_buffered_len += p_uart_obj[uart_num]->rx_stash_len;
|
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;
|
p_uart_obj[uart_num]->rx_buffer_full_flg = false;
|
||||||
|
UART_EXIT_CRITICAL(&uart_spinlock[uart_num]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue