@@ -56,10 +56,8 @@ Adafruit_USBH_CDC SerialHost;
5656// --------------------------------------------------------------------+
5757
5858void setup () {
59- Serial1.begin (115200 );
60-
6159 Serial.begin (115200 );
62- while ( !Serial ) delay (10 ); // wait for native usb
60+ // while ( !Serial ) delay(10); // wait for native usb
6361
6462 Serial.println (" TinyUSB Host Serial Echo Example" );
6563}
@@ -89,7 +87,7 @@ void loop()
8987// --------------------------------------------------------------------+
9088
9189void setup1 () {
92- while ( !Serial ) delay (10 ); // wait for native usb
90+ // while ( !Serial ) delay(10); // wait for native usb
9391 Serial.println (" Core1 setup to run TinyUSB host with pio-usb" );
9492
9593 // Check for CPU frequency, must be multiple of 120Mhz for bit-banging USB
@@ -125,6 +123,8 @@ void setup1() {
125123 // Note: For rp2040 pico-pio-usb, calling USBHost.begin() on core1 will have most of the
126124 // host bit-banging processing works done in core1 to free up core0 for other works
127125 USBHost.begin (1 );
126+
127+ SerialHost.begin (115200 );
128128}
129129
130130void loop1 ()
@@ -140,23 +140,20 @@ void loop1()
140140// --------------------------------------------------------------------+
141141// TinyUSB Host callbacks
142142// --------------------------------------------------------------------+
143+ extern " C" {
143144
144145// Invoked when a device with CDC interface is mounted
145146// idx is index of cdc interface in the internal pool.
146147void tuh_cdc_mount_cb (uint8_t idx) {
147148 // bind SerialHost object to this interface index
148- SerialHost.setInterfaceIndex (idx);
149- SerialHost.begin (115200 );
150-
149+ SerialHost.mount (idx);
151150 Serial.println (" SerialHost is connected to a new CDC device" );
152151}
153152
154153// Invoked when a device with CDC interface is unmounted
155154void 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" );
162157}
158+
159+ }
0 commit comments