Skip to content

Commit ce47271

Browse files
fix(uart): idf 5.5 new gpio_iomux_* functions (#11507)
* fix(uart): idf 5.5 new gpio_iomux_* functions * fix(uart): formatting and style * fix(uart): commentaries style fix * fix(uart): commentaries style fix * fix(uart): commentaries style fix * fix(uart): support to any idf 5.x version * fix(uart): changing assert in order to avoid reset * ci(pre-commit): Apply automatic fixes --------- Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
1 parent bcfa678 commit ce47271

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

cores/esp32/esp32-hal-uart.c

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -317,13 +317,24 @@ static bool _uartTrySetIomuxPin(uart_port_t uart_num, int io_num, uint32_t idx)
317317
}
318318

319319
// Assign the correct function to the GPIO.
320-
assert(upin->iomux_func != -1);
320+
if (upin->iomux_func == -1) {
321+
log_e("IO#%d has bad IOMUX internal information. Switching to GPIO Matrix UART function.", io_num);
322+
return false;
323+
}
321324
if (uart_num < SOC_UART_HP_NUM) {
325+
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 5, 0)
326+
if (upin->input) {
327+
gpio_iomux_input(io_num, upin->iomux_func, upin->signal);
328+
} else {
329+
gpio_iomux_output(io_num, upin->iomux_func);
330+
}
331+
#else
322332
gpio_iomux_out(io_num, upin->iomux_func, false);
323333
// If the pin is input, we also have to redirect the signal, in order to bypass the GPIO matrix.
324334
if (upin->input) {
325335
gpio_iomux_in(io_num, upin->signal);
326336
}
337+
#endif
327338
}
328339
#if (SOC_UART_LP_NUM >= 1) && (SOC_RTCIO_PIN_COUNT >= 1)
329340
else {
@@ -1276,11 +1287,11 @@ bool uartSetClockSource(uint8_t uartNum, uart_sclk_t clkSrc) {
12761287
#if SOC_UART_LP_NUM >= 1
12771288
if (uart->num >= SOC_UART_HP_NUM) {
12781289
switch (clkSrc) {
1279-
case UART_SCLK_XTAL: uart->_uart_clock_source = LP_UART_SCLK_XTAL_D2; break;
1290+
case UART_SCLK_XTAL: uart->_uart_clock_source = LP_UART_SCLK_XTAL_D2; break;
12801291
#if CONFIG_IDF_TARGET_ESP32C5
1281-
case UART_SCLK_RTC: uart->_uart_clock_source = LP_UART_SCLK_RC_FAST; break;
1292+
case UART_SCLK_RTC: uart->_uart_clock_source = LP_UART_SCLK_RC_FAST; break;
12821293
#else
1283-
case UART_SCLK_RTC: uart->_uart_clock_source = LP_UART_SCLK_LP_FAST; break;
1294+
case UART_SCLK_RTC: uart->_uart_clock_source = LP_UART_SCLK_LP_FAST; break;
12841295
#endif
12851296
case UART_SCLK_DEFAULT:
12861297
default: uart->_uart_clock_source = LP_UART_SCLK_DEFAULT;

0 commit comments

Comments
 (0)