diff --git a/cores/esp32/HardwareSerial.cpp b/cores/esp32/HardwareSerial.cpp index 2e1f2701e9a..c82cbb43d3b 100644 --- a/cores/esp32/HardwareSerial.cpp +++ b/cores/esp32/HardwareSerial.cpp @@ -24,16 +24,13 @@ #endif void serialEvent(void) __attribute__((weak)); -void serialEvent(void) {} #if SOC_UART_NUM > 1 void serialEvent1(void) __attribute__((weak)); -void serialEvent1(void) {} #endif /* SOC_UART_NUM > 1 */ #if SOC_UART_NUM > 2 void serialEvent2(void) __attribute__((weak)); -void serialEvent2(void) {} #endif /* SOC_UART_NUM > 2 */ #if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_SERIAL) @@ -48,37 +45,35 @@ HardwareSerial Serial2(2); #if HWCDC_SERIAL_IS_DEFINED == 1 // Hardware JTAG CDC Event extern void HWCDCSerialEvent(void) __attribute__((weak)); -void HWCDCSerialEvent(void) {} #endif #if USB_SERIAL_IS_DEFINED == 1 // Native USB CDC Event // Used by Hardware Serial for USB CDC events extern void USBSerialEvent(void) __attribute__((weak)); -void USBSerialEvent(void) {} #endif void serialEventRun(void) { #if HWCDC_SERIAL_IS_DEFINED == 1 // Hardware JTAG CDC Event - if (HWCDCSerial.available()) { + if (HWCDCSerialEvent && HWCDCSerial.available()) { HWCDCSerialEvent(); } #endif #if USB_SERIAL_IS_DEFINED == 1 // Native USB CDC Event - if (USBSerial.available()) { + if (USBSerialEvent && USBSerial.available()) { USBSerialEvent(); } #endif // UART0 is default serialEvent() - if (Serial0.available()) { + if (serialEvent && Serial0.available()) { serialEvent(); } #if SOC_UART_NUM > 1 - if (Serial1.available()) { + if (serialEvent1 && Serial1.available()) { serialEvent1(); } #endif #if SOC_UART_NUM > 2 - if (Serial2.available()) { + if (serialEvent2 && Serial2.available()) { serialEvent2(); } #endif