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 3c93de7

Browse files
authoredOct 24, 2024··
feat(uart): allows the board pins_arduino.h to define other uart pins
1 parent ec64369 commit 3c93de7

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed
 

‎cores/esp32/HardwareSerial.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,8 +349,34 @@ void HardwareSerial::begin(unsigned long baud, uint32_t config, int8_t rxPin, in
349349
#endif
350350
}
351351
break;
352+
#endif
353+
#if SOC_UART_HP_NUM > 3 // may save some flash bytes...
354+
case UART_NUM_3:
355+
if (rxPin < 0 && txPin < 0) {
356+
// do not change RX2/TX2 if it has already been set before
357+
#ifdef RX3
358+
rxPin = _rxPin < 0 ? (int8_t)RX3 : _rxPin;
359+
#endif
360+
#ifdef TX3
361+
txPin = _txPin < 0 ? (int8_t)TX3 : _txPin;
362+
#endif
363+
}
364+
break;
352365
#endif
353366
}
367+
#if SOC_UART_HP_NUM > 4 // may save some flash bytes...
368+
case UART_NUM_4:
369+
if (rxPin < 0 && txPin < 0) {
370+
// do not change RX2/TX2 if it has already been set before
371+
#ifdef RX4
372+
rxPin = _rxPin < 0 ? (int8_t)RX4 : _rxPin;
373+
#endif
374+
#ifdef TX4
375+
txPin = _txPin < 0 ? (int8_t)TX4 : _txPin;
376+
#endif
377+
}
378+
break;
379+
#endif
354380
}
355381

356382
// if no RX/TX pins are defined, it will not start the UART driver

0 commit comments

Comments
 (0)
Please sign in to comment.