|
15 | 15 | * |
16 | 16 | * Requirement: |
17 | 17 | * The max number of CDC ports (CFG_TUD_CDC) has to be changed to at least 2. |
18 | | - * Config file is located in Adafruit_TinyUSB_Arduino/src/arduino/ports/platform/tusb_config_platform.h |
19 | | - * where platform is one of: esp32, nrf, rp2040, samd |
| 18 | + * Config file is located in Adafruit_TinyUSB_Arduino/src/arduino/ports/{platform}/tusb_config_{platform}.h |
| 19 | + * where platform is one of: nrf, rp2040, samd |
| 20 | + * |
| 21 | + * NOTE: Currnetly multiple CDCs on ESP32-Sx is not yet supported. |
| 22 | + * An PR to update core/esp32/USBCDC and/or pre-built libusb are needed. |
| 23 | + * We would implement this later when we could. |
20 | 24 | */ |
21 | 25 |
|
22 | 26 | #include <Adafruit_TinyUSB.h> |
23 | 27 |
|
24 | 28 | #define LED LED_BUILTIN |
25 | 29 |
|
26 | | -// Create extra USB Serial Ports. "Serial" is already created. |
27 | | -Adafruit_USBD_CDC USBSer1; |
| 30 | +// Create 2nd instance of CDC Ports. |
| 31 | +#ifdef ARDUINO_ARCH_ESP32 |
| 32 | + #error "Currnetly multiple CDCs on ESP32-Sx is not yet supported. An PR to update core/esp32/USBCDC and/or pre-built libusb are needed." |
| 33 | + // for ESP32, we need to specify instance number when declaring object |
| 34 | + Adafruit_USBD_CDC USBSer1(1); |
| 35 | +#else |
| 36 | + Adafruit_USBD_CDC USBSer1; |
| 37 | +#endif |
28 | 38 |
|
29 | 39 | void setup() { |
30 | 40 | pinMode(LED, OUTPUT); |
31 | 41 |
|
32 | | - // start up all of the USB Vitual ports, and wait for them to enumerate. |
33 | 42 | Serial.begin(115200); |
| 43 | + |
| 44 | + // check to see if multiple CDCs are enabled |
| 45 | + if ( CFG_TUD_CDC < 2 ) { |
| 46 | + digitalWrite(LED, HIGH); // LED on for error indicator |
| 47 | + |
| 48 | + while(1) { |
| 49 | + Serial.printf("CFG_TUD_CDC must be at least 2, current value is %u\n", CFG_TUD_CDC); |
| 50 | + Serial.println(" Config file is located in Adafruit_TinyUSB_Arduino/src/arduino/ports/{platform}/tusb_config_{platform}.h"); |
| 51 | + Serial.println(" where platform is one of: nrf, rp2040, samd"); |
| 52 | + delay(1000); |
| 53 | + } |
| 54 | + } |
| 55 | + |
| 56 | + // initialize 2nd CDC interface |
34 | 57 | USBSer1.begin(115200); |
35 | 58 |
|
36 | 59 | while (!Serial || !USBSer1) { |
|
0 commit comments