Skip to content

Enable USB Serial only if selected #9294

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion cores/esp32/HWCDC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ void HWCDC::setDebugOutput(bool en)
}
}

#if ARDUINO_USB_MODE // Hardware JTAG CDC selected
#if ARDUINO_USB_MODE && ARDUINO_USB_CDC_ON_BOOT // Hardware JTAG CDC selected
// USBSerial is always available to be used
HWCDC HWCDCSerial;
#endif
Expand Down
2 changes: 1 addition & 1 deletion cores/esp32/HWCDC.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class HWCDC: public Stream
uint32_t baudRate(){return 115200;}

};
#if ARDUINO_USB_MODE // Hardware JTAG CDC selected
#if ARDUINO_USB_MODE && ARDUINO_USB_CDC_ON_BOOT // Hardware JTAG CDC selected
#ifndef HWCDC_SERIAL_IS_DEFINED
#define HWCDC_SERIAL_IS_DEFINED 1
#endif
Expand Down
2 changes: 1 addition & 1 deletion cores/esp32/USBCDC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ USBCDC::operator bool() const
return connected;
}

#if !ARDUINO_USB_MODE // Native USB CDC selected
#if !ARDUINO_USB_MODE && ARDUINO_USB_CDC_ON_BOOT // Native USB CDC selected
// USBSerial is always available to be used
USBCDC USBSerial(0);
#endif
Expand Down
2 changes: 1 addition & 1 deletion cores/esp32/USBCDC.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ class USBCDC: public Stream

};

#if !ARDUINO_USB_MODE // Native USB CDC selected
#if !ARDUINO_USB_MODE && ARDUINO_USB_CDC_ON_BOOT // Native USB CDC selected
#ifndef USB_SERIAL_IS_DEFINED
#define USB_SERIAL_IS_DEFINED 1
#endif
Expand Down
4 changes: 4 additions & 0 deletions libraries/USB/examples/CompositeDevice/CompositeDevice.ino
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ void loop(){}
FirmwareMSC MSC_Update;
#endif

#if !ARDUINO_USB_CDC_ON_BOOT
USBCDC USBSerial;
#endif

USBHID HID;
USBHIDKeyboard Keyboard;
USBHIDMouse Mouse;
Expand Down
1 change: 0 additions & 1 deletion libraries/USB/examples/FirmwareMSC/FirmwareMSC.ino
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ void setup() {
USB.onEvent(usbEventCallback);
MSC_Update.onEvent(usbEventCallback);
MSC_Update.begin();
USBSerial.begin();
USB.begin();
}

Expand Down
1 change: 0 additions & 1 deletion libraries/USB/examples/USBMSC/USBMSC.ino
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,6 @@ void setup() {
MSC.onWrite(onWrite);
MSC.mediaPresent(true);
MSC.begin(DISK_SECTOR_COUNT, DISK_SECTOR_SIZE);
USBSerial.begin();
USB.begin();
}

Expand Down
4 changes: 4 additions & 0 deletions libraries/USB/examples/USBSerial/USBSerial.ino
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ void loop(){}
#else
#include "USB.h"

#if !ARDUINO_USB_CDC_ON_BOOT
USBCDC USBSerial;
#endif

static void usbEventCallback(void* arg, esp_event_base_t event_base, int32_t event_id, void* event_data){
if(event_base == ARDUINO_USB_EVENTS){
arduino_usb_event_data_t * data = (arduino_usb_event_data_t*)event_data;
Expand Down