From f27eb1f03febcbf1f9e2c95e8e3fbf251ba6001c Mon Sep 17 00:00:00 2001 From: aleks Date: Wed, 21 Jul 2021 06:33:51 +0200 Subject: [PATCH] driver: uart fix the rts line assertion issue --- components/driver/uart.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/components/driver/uart.c b/components/driver/uart.c index bf21ac3f80..5919b314fe 100644 --- a/components/driver/uart.c +++ b/components/driver/uart.c @@ -794,6 +794,7 @@ static void UART_ISR_ATTR uart_rx_intr_handler_default(void *param) // Set RS485 RTS pin before transmission if the half duplex mode is enabled if (UART_IS_MODE_SET(uart_num, UART_MODE_RS485_HALF_DUPLEX)) { UART_ENTER_CRITICAL_ISR(&(uart_context[uart_num].spinlock)); + uart_hal_clr_intsts_mask(&(uart_context[uart_num].hal), UART_INTR_TX_DONE); uart_hal_set_rts(&(uart_context[uart_num].hal), 0); uart_hal_ena_intr_mask(&(uart_context[uart_num].hal), UART_INTR_TX_DONE); UART_EXIT_CRITICAL_ISR(&(uart_context[uart_num].spinlock)); @@ -1047,7 +1048,6 @@ esp_err_t uart_wait_tx_done(uart_port_t uart_num, TickType_t ticks_to_wait) xSemaphoreGive(p_uart_obj[uart_num]->tx_mux); return ESP_OK; } - uart_hal_clr_intsts_mask(&(uart_context[uart_num].hal), UART_INTR_TX_DONE); UART_ENTER_CRITICAL(&(uart_context[uart_num].spinlock)); uart_hal_ena_intr_mask(&(uart_context[uart_num].hal), UART_INTR_TX_DONE); UART_EXIT_CRITICAL(&(uart_context[uart_num].spinlock)); @@ -1061,9 +1061,7 @@ esp_err_t uart_wait_tx_done(uart_port_t uart_num, TickType_t ticks_to_wait) //take 2nd tx_done_sem, wait given from ISR res = xSemaphoreTake(p_uart_obj[uart_num]->tx_done_sem, (portTickType)ticks_to_wait); if(res == pdFALSE) { - UART_ENTER_CRITICAL(&(uart_context[uart_num].spinlock)); - uart_hal_disable_intr_mask(&(uart_context[uart_num].hal), UART_INTR_TX_DONE); - UART_EXIT_CRITICAL(&(uart_context[uart_num].spinlock)); + // The TX_DONE interrupt will be disabled in ISR xSemaphoreGive(p_uart_obj[uart_num]->tx_mux); return ESP_ERR_TIMEOUT; } @@ -1083,6 +1081,7 @@ int uart_tx_chars(uart_port_t uart_num, const char* buffer, uint32_t len) xSemaphoreTake(p_uart_obj[uart_num]->tx_mux, (portTickType)portMAX_DELAY); if (UART_IS_MODE_SET(uart_num, UART_MODE_RS485_HALF_DUPLEX)) { UART_ENTER_CRITICAL(&(uart_context[uart_num].spinlock)); + uart_hal_clr_intsts_mask(&(uart_context[uart_num].hal), UART_INTR_TX_DONE); uart_hal_set_rts(&(uart_context[uart_num].hal), 0); uart_hal_ena_intr_mask(&(uart_context[uart_num].hal), UART_INTR_TX_DONE); UART_EXIT_CRITICAL(&(uart_context[uart_num].spinlock)); @@ -1128,6 +1127,7 @@ static int uart_tx_all(uart_port_t uart_num, const char* src, size_t size, bool uint32_t sent = 0; if (UART_IS_MODE_SET(uart_num, UART_MODE_RS485_HALF_DUPLEX)) { UART_ENTER_CRITICAL(&(uart_context[uart_num].spinlock)); + uart_hal_clr_intsts_mask(&(uart_context[uart_num].hal), UART_INTR_TX_DONE); uart_hal_set_rts(&(uart_context[uart_num].hal), 0); uart_hal_ena_intr_mask(&(uart_context[uart_num].hal), UART_INTR_TX_DONE); UART_EXIT_CRITICAL(&(uart_context[uart_num].spinlock)); -- 2.15.1.windows.2