Skip to content

Commit 3816873

Browse files
authored
fix(uart): make it compatible with IDF 5.3
1 parent 000336b commit 3816873

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

cores/esp32/esp32-hal-uart.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,12 @@ static esp_err_t _uartInternalSetPin(uart_port_t uart_num, int tx_io_num, int rx
389389
#endif
390390
if (tx_rx_same_io || !_uartTrySetIomuxPin(uart_num, rx_io_num, SOC_UART_RX_PIN_IDX)) {
391391
if (uart_num < SOC_UART_HP_NUM) {
392+
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 4, 0)
392393
gpio_input_enable(rx_io_num);
394+
#else
395+
gpio_func_sel(rx_io_num, PIN_FUNC_GPIO);
396+
gpio_ll_input_enable(&GPIO, rx_io_num);
397+
#endif
393398
esp_rom_gpio_connect_in_signal(rx_io_num, UART_PERIPH_SIGNAL(uart_num, SOC_UART_RX_PIN_IDX), 0);
394399
}
395400
#if SOC_LP_GPIO_MATRIX_SUPPORTED
@@ -422,8 +427,14 @@ static esp_err_t _uartInternalSetPin(uart_port_t uart_num, int tx_io_num, int rx
422427

423428
if (cts_io_num >= 0 && !_uartTrySetIomuxPin(uart_num, cts_io_num, SOC_UART_CTS_PIN_IDX)) {
424429
if (uart_num < SOC_UART_HP_NUM) {
430+
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 4, 0)
425431
gpio_pullup_en(cts_io_num);
426432
gpio_input_enable(cts_io_num);
433+
#else
434+
gpio_func_sel(cts_io_num, PIN_FUNC_GPIO);
435+
gpio_set_pull_mode(cts_io_num, GPIO_PULLUP_ONLY);
436+
gpio_set_direction(cts_io_num, GPIO_MODE_INPUT);
437+
#endif
427438
esp_rom_gpio_connect_in_signal(cts_io_num, UART_PERIPH_SIGNAL(uart_num, SOC_UART_CTS_PIN_IDX), 0);
428439
}
429440
#if SOC_LP_GPIO_MATRIX_SUPPORTED

0 commit comments

Comments
 (0)