Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 81d2cbc

Browse files
fix(uart): Add missing HP UARTs for ESP32-P4 (#10447)
* fix(uart): Add missing HP UARTs for ESP32-P4 * fix(comment): Fix macro in comment * fix(uart): Fix macro guard
1 parent 774f275 commit 81d2cbc

File tree

3 files changed

+66
-4
lines changed

3 files changed

+66
-4
lines changed

‎cores/esp32/HardwareSerial.cpp

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,19 @@ void serialEvent(void) __attribute__((weak));
2727

2828
#if SOC_UART_HP_NUM > 1
2929
void serialEvent1(void) __attribute__((weak));
30-
#endif /* SOC_UART_NUM > 1 */
30+
#endif /* SOC_UART_HP_NUM > 1 */
3131

3232
#if SOC_UART_HP_NUM > 2
3333
void serialEvent2(void) __attribute__((weak));
34-
#endif /* SOC_UART_NUM > 2 */
34+
#endif /* SOC_UART_HP_NUM > 2 */
35+
36+
#if SOC_UART_HP_NUM > 3
37+
void serialEvent3(void) __attribute__((weak));
38+
#endif /* SOC_UART_HP_NUM > 3 */
39+
40+
#if SOC_UART_HP_NUM > 4
41+
void serialEvent4(void) __attribute__((weak));
42+
#endif /* SOC_UART_HP_NUM > 4 */
3543

3644
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_SERIAL)
3745
// There is always Seria0 for UART0
@@ -42,6 +50,12 @@ HardwareSerial Serial1(1);
4250
#if SOC_UART_HP_NUM > 2
4351
HardwareSerial Serial2(2);
4452
#endif
53+
#if SOC_UART_HP_NUM > 3
54+
HardwareSerial Serial3(3);
55+
#endif
56+
#if SOC_UART_HP_NUM > 4
57+
HardwareSerial Serial4(4);
58+
#endif
4559

4660
#if HWCDC_SERIAL_IS_DEFINED == 1 // Hardware JTAG CDC Event
4761
extern void HWCDCSerialEvent(void) __attribute__((weak));
@@ -67,16 +81,26 @@ void serialEventRun(void) {
6781
if (serialEvent && Serial0.available()) {
6882
serialEvent();
6983
}
70-
#if SOC_UART_NUM > 1
84+
#if SOC_UART_HP_NUM > 1
7185
if (serialEvent1 && Serial1.available()) {
7286
serialEvent1();
7387
}
7488
#endif
75-
#if SOC_UART_NUM > 2
89+
#if SOC_UART_HP_NUM > 2
7690
if (serialEvent2 && Serial2.available()) {
7791
serialEvent2();
7892
}
7993
#endif
94+
#if SOC_UART_HP_NUM > 3
95+
if (serialEvent3 && Serial3.available()) {
96+
serialEvent3();
97+
}
98+
#endif
99+
#if SOC_UART_HP_NUM > 4
100+
if (serialEvent4 && Serial4.available()) {
101+
serialEvent4();
102+
}
103+
#endif
80104
}
81105
#endif
82106

‎cores/esp32/HardwareSerial.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,12 @@ extern HardwareSerial Serial1;
375375
#if SOC_UART_HP_NUM > 2
376376
extern HardwareSerial Serial2;
377377
#endif
378+
#if SOC_UART_HP_NUM > 3
379+
extern HardwareSerial Serial3;
380+
#endif
381+
#if SOC_UART_HP_NUM > 4
382+
extern HardwareSerial Serial4;
383+
#endif
378384
#endif //!defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_SERIAL)
379385

380386
#endif // HardwareSerial_h

‎cores/esp32/esp32-hal-uart.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@ static uart_t _uart_bus_array[] = {
6767
#if SOC_UART_HP_NUM > 2
6868
{2, false, 0, NULL, -1, -1, -1, -1, 0, 0, 0, 0, false, 0},
6969
#endif
70+
#if SOC_UART_HP_NUM > 3
71+
{3, false, 0, NULL, -1, -1, -1, -1, 0, 0, 0, 0, false, 0},
72+
#endif
73+
#if SOC_UART_HP_NUM > 4
74+
{4, false, 0, NULL, -1, -1, -1, -1, 0, 0, 0, 0, false, 0},
75+
#endif
7076
};
7177

7278
#else
@@ -87,6 +93,12 @@ static uart_t _uart_bus_array[] = {
8793
#if SOC_UART_HP_NUM > 2
8894
{NULL, 2, false, 0, NULL, -1, -1, -1, -1, 0, 0, 0, 0, false, 0},
8995
#endif
96+
#if SOC_UART_HP_NUM > 3
97+
{NULL, 3, false, 0, NULL, -1, -1, -1, -1, 0, 0, 0, 0, false, 0},
98+
#endif
99+
#if SOC_UART_HP_NUM > 4
100+
{NULL, 4, false, 0, NULL, -1, -1, -1, -1, 0, 0, 0, 0, false, 0},
101+
#endif
90102
};
91103

92104
#endif
@@ -835,6 +847,20 @@ static void ARDUINO_ISR_ATTR uart2_write_char(char c) {
835847
}
836848
#endif
837849

850+
#if SOC_UART_HP_NUM > 3
851+
static void ARDUINO_ISR_ATTR uart3_write_char(char c) {
852+
while (uart_ll_get_txfifo_len(&UART3) == 0);
853+
uart_ll_write_txfifo(&UART3, (const uint8_t *)&c, 1);
854+
}
855+
#endif
856+
857+
#if SOC_UART_HP_NUM > 4
858+
static void ARDUINO_ISR_ATTR uart4_write_char(char c) {
859+
while (uart_ll_get_txfifo_len(&UART4) == 0);
860+
uart_ll_write_txfifo(&UART4, (const uint8_t *)&c, 1);
861+
}
862+
#endif
863+
838864
void uart_install_putc() {
839865
switch (s_uart_debug_nr) {
840866
case 0: ets_install_putc1((void (*)(char)) & uart0_write_char); break;
@@ -843,6 +869,12 @@ void uart_install_putc() {
843869
#endif
844870
#if SOC_UART_HP_NUM > 2
845871
case 2: ets_install_putc1((void (*)(char)) & uart2_write_char); break;
872+
#endif
873+
#if SOC_UART_HP_NUM > 3
874+
case 3: ets_install_putc1((void (*)(char)) & uart3_write_char); break;
875+
#endif
876+
#if SOC_UART_HP_NUM > 4
877+
case 4: ets_install_putc1((void (*)(char)) & uart4_write_char); break;
846878
#endif
847879
default: ets_install_putc1(NULL); break;
848880
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /