Skip to content

Commit 50840e4

Browse files
authored
fix(uart): idf 5.5 new gpio_iomux_* functions
1 parent 974cc0b commit 50840e4

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

cores/esp32/esp32-hal-uart.c

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -315,26 +315,25 @@ static bool _uartTrySetIomuxPin(uart_port_t uart_num, int io_num, uint32_t idx)
315315
if (upin->iomux_func == -1 || upin->default_gpio == -1 || upin->default_gpio != io_num) {
316316
return false;
317317
}
318-
319318
// Assign the correct function to the GPIO.
320319
assert(upin->iomux_func != -1);
321320
if (uart_num < SOC_UART_HP_NUM) {
322-
gpio_iomux_out(io_num, upin->iomux_func, false);
323-
// If the pin is input, we also have to redirect the signal, in order to bypass the GPIO matrix.
324321
if (upin->input) {
325-
gpio_iomux_in(io_num, upin->signal);
322+
gpio_iomux_input(io_num, upin->iomux_func, upin->signal);
323+
} else {
324+
gpio_iomux_output(io_num, upin->iomux_func);
326325
}
327326
}
328327
#if (SOC_UART_LP_NUM >= 1) && (SOC_RTCIO_PIN_COUNT >= 1)
329-
else {
330-
if (upin->input) {
331-
rtc_gpio_set_direction(io_num, RTC_GPIO_MODE_INPUT_ONLY);
332-
} else {
333-
rtc_gpio_set_direction(io_num, RTC_GPIO_MODE_OUTPUT_ONLY);
328+
else {
329+
if (upin->input) {
330+
rtc_gpio_set_direction(io_num, RTC_GPIO_MODE_INPUT_ONLY);
331+
} else {
332+
rtc_gpio_set_direction(io_num, RTC_GPIO_MODE_OUTPUT_ONLY);
333+
}
334+
rtc_gpio_init(io_num);
335+
rtc_gpio_iomux_func_sel(io_num, upin->iomux_func);
334336
}
335-
rtc_gpio_init(io_num);
336-
rtc_gpio_iomux_func_sel(io_num, upin->iomux_func);
337-
}
338337
#endif
339338
return true;
340339
}

0 commit comments

Comments
 (0)