Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit a97e7ab

Browse files
authoredOct 24, 2024··
fix(uart): no uart2,3,4 esp32-p4 pins check
1 parent 8d73687 commit a97e7ab

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed
 

‎cores/esp32/HardwareSerial.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,14 +341,25 @@ void HardwareSerial::begin(unsigned long baud, uint32_t config, int8_t rxPin, in
341341
case UART_NUM_2:
342342
if (rxPin < 0 && txPin < 0) {
343343
// do not change RX2/TX2 if it has already been set before
344+
#ifdef RX2
344345
rxPin = _rxPin < 0 ? (int8_t)RX2 : _rxPin;
346+
#endif
347+
#ifdef TX2
345348
txPin = _txPin < 0 ? (int8_t)TX2 : _txPin;
349+
#endif
346350
}
347351
break;
348352
#endif
349353
}
350354
}
351355

356+
// if no RX/TX pins are defined, it will not start the UART driver
357+
if (rxPin < 0 && txPin < 0) {
358+
log_e("No RX/TX pins defined. Please set RX/TX pins.");
359+
HSERIAL_MUTEX_UNLOCK();
360+
return;
361+
}
362+
352363
// IDF UART driver keeps Pin setting on restarting. Negative Pin number will keep it unmodified.
353364
// it will detach previous UART attached pins
354365

0 commit comments

Comments
 (0)
Please sign in to comment.