mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
Merge branch 'bugfix/fix_uart_tx_bug_when_using_ringbuffer_for_v3.1' into 'release/v3.1'
driver(uart): Fixed uart tx_empty interrupt wdt timeout bug for release/v3.1 See merge request idf/esp-idf!2934
This commit is contained in:
commit
d88b705562
@ -45,4 +45,22 @@ TEST_CASE("test uart get baud-rate","[uart]")
|
||||
TEST_ASSERT(UART_TOLERANCE_CHECK(baud_rate1, (1.0 + TOLERANCE)*UART_BAUD_11520, (1.0 - TOLERANCE)*UART_BAUD_11520))
|
||||
TEST_ASSERT(UART_TOLERANCE_CHECK(baud_rate2, (1.0 + TOLERANCE)*UART_BAUD_115200, (1.0 - TOLERANCE)*UART_BAUD_115200))
|
||||
ESP_LOGI(UART_TAG, "get baud-rate test passed ....\n");
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("test uart tx data with break","[uart]")
|
||||
{
|
||||
const int buf_len = 200;
|
||||
const int send_len = 128;
|
||||
const int brk_len = 10;
|
||||
char *psend = (char *)malloc(buf_len);
|
||||
TEST_ASSERT( psend != NULL);
|
||||
memset(psend, '0', buf_len);
|
||||
uart_config(UART_BAUD_115200, false);
|
||||
printf("Uart%d send %d bytes with break\n", UART_NUM1, send_len);
|
||||
uart_write_bytes_with_break(UART_NUM1, (const char *)psend, send_len, brk_len);
|
||||
uart_wait_tx_done(UART_NUM1, (portTickType)portMAX_DELAY);
|
||||
//If the code is running here, it means the test passed, otherwise it will crash due to the interrupt wdt timeout.
|
||||
printf("Send data with break test passed\n");
|
||||
free(psend);
|
||||
}
|
||||
|
||||
|
@ -755,7 +755,6 @@ static void uart_rx_intr_handler_default(void *param)
|
||||
p_uart->tx_ptr = NULL;
|
||||
p_uart->tx_len_tot = p_uart->tx_head->tx_data.size;
|
||||
if(p_uart->tx_head->type == UART_DATA_BREAK) {
|
||||
p_uart->tx_len_tot = p_uart->tx_head->tx_data.size;
|
||||
p_uart->tx_brk_flg = 1;
|
||||
p_uart->tx_brk_len = p_uart->tx_head->tx_data.brk_len;
|
||||
}
|
||||
@ -795,7 +794,7 @@ static void uart_rx_intr_handler_default(void *param)
|
||||
p_uart->tx_ptr = NULL;
|
||||
//Sending item done, now we need to send break if there is a record.
|
||||
//Set TX break signal after FIFO is empty
|
||||
if(p_uart->tx_brk_flg == 1 && p_uart->tx_len_tot == 0) {
|
||||
if(p_uart->tx_len_tot == 0 && p_uart->tx_brk_flg == 1) {
|
||||
UART_ENTER_CRITICAL_ISR(&uart_spinlock[uart_num]);
|
||||
uart_reg->int_ena.tx_brk_done = 0;
|
||||
uart_reg->idle_conf.tx_brk_num = p_uart->tx_brk_len;
|
||||
@ -804,6 +803,8 @@ static void uart_rx_intr_handler_default(void *param)
|
||||
uart_reg->int_ena.tx_brk_done = 1;
|
||||
UART_EXIT_CRITICAL_ISR(&uart_spinlock[uart_num]);
|
||||
p_uart->tx_waiting_brk = 1;
|
||||
//do not enable TX empty interrupt
|
||||
en_tx_flg = false;
|
||||
} else {
|
||||
//enable TX empty interrupt
|
||||
en_tx_flg = true;
|
||||
|
Loading…
Reference in New Issue
Block a user