Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 5 additions & 10 deletions cores/esp32/HardwareSerial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down
Loading