Skip to content

Commit 24cae73

Browse files
committed
reduce number of cdc instance in example from 3 to 2
1 parent cfc7405 commit 24cae73

File tree

1 file changed

+7
-21
lines changed

1 file changed

+7
-21
lines changed

examples/CDC/cdc_multi/cdc_multi.ino

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,43 +14,37 @@
1414
any of the ports will be echoed to the all ports.
1515
1616
The max number of CDC ports (CFG_TUD_CDC) has to be changed to at
17-
least 3, changed in the core tusb_config.h file.
17+
least 2, changed in the core tusb_config.h file.
1818
*/
1919

2020
#include <Adafruit_TinyUSB.h>
2121

2222
#define LED LED_BUILTIN
2323

24-
/*
25-
Create extra USB Serial Ports. "Serial" is already created.
26-
*/
24+
// Create extra USB Serial Ports. "Serial" is already created.
2725
Adafruit_USBD_CDC USBSer1;
28-
Adafruit_USBD_CDC USBSer2;
2926

3027
void setup() {
3128
pinMode(LED, OUTPUT);
3229

3330
// start up all of the USB Vitual ports, and wait for them to enumerate.
3431
Serial.begin(115200);
3532
USBSer1.begin(115200);
36-
USBSer2.begin(115200);
3733

38-
while (!Serial || !USBSer1 || !USBSer2) {
34+
while (!Serial || !USBSer1) {
3935
if (Serial) {
4036
Serial.println("Waiting for other USB ports");
4137
}
38+
4239
if (USBSer1) {
4340
USBSer1.println("Waiting for other USB ports");
4441
}
45-
if (USBSer2) {
46-
USBSer2.println("Waiting for other USB ports");
47-
}
42+
4843
delay(1000);
4944
}
5045

5146
Serial.print("You are port 0\n\r\n0> ");
5247
USBSer1.print("You are port 1\n\r\n1> ");
53-
USBSer2.print("You are port 2\n\r\n2> ");
5448
}
5549

5650
int LEDstate = 0;
@@ -68,11 +62,6 @@ void loop() {
6862
printAll(ch);
6963
}
7064

71-
ch = USBSer2.read();
72-
if (ch > 0) {
73-
printAll(ch);
74-
}
75-
7665
if (delay_without_delaying(500)) {
7766
LEDstate = !LEDstate;
7867
digitalWrite(LED, LEDstate);
@@ -81,14 +70,11 @@ void loop() {
8170

8271
// print to all CDC ports
8372
void printAll(int ch) {
84-
// print as it is
85-
Serial.write(ch);
86-
8773
// always lower case
88-
USBSer1.write(tolower(ch));
74+
Serial.write(tolower(ch));
8975

9076
// always upper case
91-
USBSer2.write(toupper(ch));
77+
USBSer1.write(toupper(ch));
9278
}
9379

9480
// Helper: non-blocking "delay" alternative.

0 commit comments

Comments
 (0)