Unverified Commit 22d7fc91 authored by Me No Dev's avatar Me No Dev Committed by GitHub

Enable USB Serial only if selected (#9294)

* Enable USB Serial only if selected

* fix examples

---------
Co-authored-by: default avatarRodrigo Garcia <rodrigo.garcia@espressif.com>
parent e3748c1d
...@@ -436,7 +436,7 @@ void HWCDC::setDebugOutput(bool en) ...@@ -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 // USBSerial is always available to be used
HWCDC HWCDCSerial; HWCDC HWCDCSerial;
#endif #endif
......
...@@ -102,7 +102,7 @@ public: ...@@ -102,7 +102,7 @@ public:
uint32_t baudRate(){return 115200;} 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 #ifndef HWCDC_SERIAL_IS_DEFINED
#define HWCDC_SERIAL_IS_DEFINED 1 #define HWCDC_SERIAL_IS_DEFINED 1
#endif #endif
......
...@@ -455,7 +455,7 @@ USBCDC::operator bool() const ...@@ -455,7 +455,7 @@ USBCDC::operator bool() const
return connected; 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 // USBSerial is always available to be used
USBCDC USBSerial(0); USBCDC USBSerial(0);
#endif #endif
......
...@@ -141,7 +141,7 @@ protected: ...@@ -141,7 +141,7 @@ protected:
}; };
#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 #ifndef USB_SERIAL_IS_DEFINED
#define USB_SERIAL_IS_DEFINED 1 #define USB_SERIAL_IS_DEFINED 1
#endif #endif
......
...@@ -18,6 +18,10 @@ void loop(){} ...@@ -18,6 +18,10 @@ void loop(){}
FirmwareMSC MSC_Update; FirmwareMSC MSC_Update;
#endif #endif
#if !ARDUINO_USB_CDC_ON_BOOT
USBCDC USBSerial;
#endif
USBHID HID; USBHID HID;
USBHIDKeyboard Keyboard; USBHIDKeyboard Keyboard;
USBHIDMouse Mouse; USBHIDMouse Mouse;
......
...@@ -65,7 +65,6 @@ void setup() { ...@@ -65,7 +65,6 @@ void setup() {
USB.onEvent(usbEventCallback); USB.onEvent(usbEventCallback);
MSC_Update.onEvent(usbEventCallback); MSC_Update.onEvent(usbEventCallback);
MSC_Update.begin(); MSC_Update.begin();
USBSerial.begin();
USB.begin(); USB.begin();
} }
......
...@@ -182,7 +182,6 @@ void setup() { ...@@ -182,7 +182,6 @@ void setup() {
MSC.onWrite(onWrite); MSC.onWrite(onWrite);
MSC.mediaPresent(true); MSC.mediaPresent(true);
MSC.begin(DISK_SECTOR_COUNT, DISK_SECTOR_SIZE); MSC.begin(DISK_SECTOR_COUNT, DISK_SECTOR_SIZE);
USBSerial.begin();
USB.begin(); USB.begin();
} }
......
...@@ -7,6 +7,10 @@ void loop(){} ...@@ -7,6 +7,10 @@ void loop(){}
#else #else
#include "USB.h" #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){ static void usbEventCallback(void* arg, esp_event_base_t event_base, int32_t event_id, void* event_data){
if(event_base == ARDUINO_USB_EVENTS){ if(event_base == ARDUINO_USB_EVENTS){
arduino_usb_event_data_t * data = (arduino_usb_event_data_t*)event_data; arduino_usb_event_data_t * data = (arduino_usb_event_data_t*)event_data;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment