@@ -56,10 +56,8 @@ Adafruit_USBH_CDC SerialHost;
56
56
// --------------------------------------------------------------------+
57
57
58
58
void setup () {
59
- Serial1.begin (115200 );
60
-
61
59
Serial.begin (115200 );
62
- while ( !Serial ) delay (10 ); // wait for native usb
60
+ // while ( !Serial ) delay(10); // wait for native usb
63
61
64
62
Serial.println (" TinyUSB Host Serial Echo Example" );
65
63
}
@@ -89,7 +87,7 @@ void loop()
89
87
// --------------------------------------------------------------------+
90
88
91
89
void setup1 () {
92
- while ( !Serial ) delay (10 ); // wait for native usb
90
+ // while ( !Serial ) delay(10); // wait for native usb
93
91
Serial.println (" Core1 setup to run TinyUSB host with pio-usb" );
94
92
95
93
// Check for CPU frequency, must be multiple of 120Mhz for bit-banging USB
@@ -125,6 +123,8 @@ void setup1() {
125
123
// Note: For rp2040 pico-pio-usb, calling USBHost.begin() on core1 will have most of the
126
124
// host bit-banging processing works done in core1 to free up core0 for other works
127
125
USBHost.begin (1 );
126
+
127
+ SerialHost.begin (115200 );
128
128
}
129
129
130
130
void loop1 ()
@@ -140,23 +140,20 @@ void loop1()
140
140
// --------------------------------------------------------------------+
141
141
// TinyUSB Host callbacks
142
142
// --------------------------------------------------------------------+
143
+ extern " C" {
143
144
144
145
// Invoked when a device with CDC interface is mounted
145
146
// idx is index of cdc interface in the internal pool.
146
147
void tuh_cdc_mount_cb (uint8_t idx) {
147
148
// bind SerialHost object to this interface index
148
- SerialHost.setInterfaceIndex (idx);
149
- SerialHost.begin (115200 );
150
-
149
+ SerialHost.mount (idx);
151
150
Serial.println (" SerialHost is connected to a new CDC device" );
152
151
}
153
152
154
153
// Invoked when a device with CDC interface is unmounted
155
154
void tuh_cdc_umount_cb (uint8_t idx) {
156
- if (idx == SerialHost.getInterfaceIndex ()) {
157
- // unbind SerialHost if this interface is unmounted
158
- SerialHost.end ();
159
-
160
- Serial.println (" SerialHost is disconnected" );
161
- }
155
+ SerialHost.umount (idx);
156
+ Serial.println (" SerialHost is disconnected" );
162
157
}
158
+
159
+ }
0 commit comments