@@ -317,13 +317,24 @@ static bool _uartTrySetIomuxPin(uart_port_t uart_num, int io_num, uint32_t idx)
317
317
}
318
318
319
319
// 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
+ }
321
324
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
322
332
gpio_iomux_out (io_num , upin -> iomux_func , false);
323
333
// If the pin is input, we also have to redirect the signal, in order to bypass the GPIO matrix.
324
334
if (upin -> input ) {
325
335
gpio_iomux_in (io_num , upin -> signal );
326
336
}
337
+ #endif
327
338
}
328
339
#if (SOC_UART_LP_NUM >= 1 ) && (SOC_RTCIO_PIN_COUNT >= 1 )
329
340
else {
@@ -1276,11 +1287,11 @@ bool uartSetClockSource(uint8_t uartNum, uart_sclk_t clkSrc) {
1276
1287
#if SOC_UART_LP_NUM >= 1
1277
1288
if (uart -> num >= SOC_UART_HP_NUM ) {
1278
1289
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 ;
1280
1291
#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 ;
1282
1293
#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 ;
1284
1295
#endif
1285
1296
case UART_SCLK_DEFAULT :
1286
1297
default : uart -> _uart_clock_source = LP_UART_SCLK_DEFAULT ;
0 commit comments