Merge branch 'bugfix/fix_modbus_rs485_rts_en_fail_v40' into 'release/v4.0'

Bugfix/fix modbus rs485 rts en fail (backport v4.0)

See merge request espressif/esp-idf!14472
This commit is contained in:
Michael (XIAO Xufeng) 2021-09-10 17:43:56 +00:00
commit fb0c3e8016
2 changed files with 5 additions and 4 deletions

View File

@ -1094,8 +1094,9 @@ 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); xSemaphoreGive(p_uart_obj[uart_num]->tx_mux);
return ESP_OK; return ESP_OK;
} }
uart_enable_intr_mask(uart_num, UART_TX_DONE_INT_ENA_M); UART_ENTER_CRITICAL_ISR(&uart_spinlock[uart_num]);
SET_PERI_REG_MASK(UART_INT_ENA_REG(uart_num), UART_TX_DONE_INT_ENA_M);
UART_EXIT_CRITICAL_ISR(&uart_spinlock[uart_num]);
TickType_t ticks_end = xTaskGetTickCount(); TickType_t ticks_end = xTaskGetTickCount();
if (ticks_end - ticks_start > ticks_to_wait) { if (ticks_end - ticks_start > ticks_to_wait) {
ticks_to_wait = 0; ticks_to_wait = 0;
@ -1105,7 +1106,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 //take 2nd tx_done_sem, wait given from ISR
res = xSemaphoreTake(p_uart_obj[uart_num]->tx_done_sem, (portTickType)ticks_to_wait); res = xSemaphoreTake(p_uart_obj[uart_num]->tx_done_sem, (portTickType)ticks_to_wait);
if(res == pdFALSE) { if(res == pdFALSE) {
uart_disable_intr_mask(uart_num, UART_TX_DONE_INT_ENA_M); // The TX_DONE interrupt will be disabled in ISR
xSemaphoreGive(p_uart_obj[uart_num]->tx_mux); xSemaphoreGive(p_uart_obj[uart_num]->tx_mux);
return ESP_ERR_TIMEOUT; return ESP_ERR_TIMEOUT;
} }

View File

@ -62,7 +62,7 @@
// Set buffer size for transmission // Set buffer size for transmission
#define MB_SERIAL_BUF_SIZE (CONFIG_FMB_SERIAL_BUF_SIZE) #define MB_SERIAL_BUF_SIZE (CONFIG_FMB_SERIAL_BUF_SIZE)
#define MB_SERIAL_TX_TOUT_MS (100) #define MB_SERIAL_TX_TOUT_MS (2200)
#define MB_SERIAL_TX_TOUT_TICKS pdMS_TO_TICKS(MB_SERIAL_TX_TOUT_MS) // timeout for transmission #define MB_SERIAL_TX_TOUT_TICKS pdMS_TO_TICKS(MB_SERIAL_TX_TOUT_MS) // timeout for transmission
/* ----------------------- Static variables ---------------------------------*/ /* ----------------------- Static variables ---------------------------------*/