14
14
any of the ports will be echoed to the all ports.
15
15
16
16
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.
18
18
*/
19
19
20
20
#include < Adafruit_TinyUSB.h>
21
21
22
22
#define LED LED_BUILTIN
23
23
24
- /*
25
- Create extra USB Serial Ports. "Serial" is already created.
26
- */
24
+ // Create extra USB Serial Ports. "Serial" is already created.
27
25
Adafruit_USBD_CDC USBSer1;
28
- Adafruit_USBD_CDC USBSer2;
29
26
30
27
void setup () {
31
28
pinMode (LED, OUTPUT);
32
29
33
30
// start up all of the USB Vitual ports, and wait for them to enumerate.
34
31
Serial.begin (115200 );
35
32
USBSer1.begin (115200 );
36
- USBSer2.begin (115200 );
37
33
38
- while (!Serial || !USBSer1 || !USBSer2 ) {
34
+ while (!Serial || !USBSer1) {
39
35
if (Serial) {
40
36
Serial.println (" Waiting for other USB ports" );
41
37
}
38
+
42
39
if (USBSer1) {
43
40
USBSer1.println (" Waiting for other USB ports" );
44
41
}
45
- if (USBSer2) {
46
- USBSer2.println (" Waiting for other USB ports" );
47
- }
42
+
48
43
delay (1000 );
49
44
}
50
45
51
46
Serial.print (" You are port 0\n\r\n 0> " );
52
47
USBSer1.print (" You are port 1\n\r\n 1> " );
53
- USBSer2.print (" You are port 2\n\r\n 2> " );
54
48
}
55
49
56
50
int LEDstate = 0 ;
@@ -68,11 +62,6 @@ void loop() {
68
62
printAll (ch);
69
63
}
70
64
71
- ch = USBSer2.read ();
72
- if (ch > 0 ) {
73
- printAll (ch);
74
- }
75
-
76
65
if (delay_without_delaying (500 )) {
77
66
LEDstate = !LEDstate;
78
67
digitalWrite (LED, LEDstate);
@@ -81,14 +70,11 @@ void loop() {
81
70
82
71
// print to all CDC ports
83
72
void printAll (int ch) {
84
- // print as it is
85
- Serial.write (ch);
86
-
87
73
// always lower case
88
- USBSer1 .write (tolower (ch));
74
+ Serial .write (tolower (ch));
89
75
90
76
// always upper case
91
- USBSer2 .write (toupper (ch));
77
+ USBSer1 .write (toupper (ch));
92
78
}
93
79
94
80
// Helper: non-blocking "delay" alternative.
0 commit comments