@@ -48,49 +48,27 @@ hid_gamepad_report_t gp;
4848bool printed_blank = false ;
4949
5050void setup () {
51- if (!TinyUSBDevice.isInitialized ()) {
52- TinyUSBDevice.begin (0 );
53- }
5451 Serial.begin (115200 );
55- // Setup HID
56- usb_hid.setPollInterval (2 );
57- usb_hid.setReportDescriptor (desc_hid_report, sizeof (desc_hid_report));
58- usb_hid.begin ();
59-
60- // If already enumerated, additional class driver begin() e.g msc, hid, midi won't take effect until re-enumeration
61- if (TinyUSBDevice.mounted ()) {
62- TinyUSBDevice.detach ();
63- delay (10 );
64- TinyUSBDevice.attach ();
65- }
66- }
67-
68- #if defined(ARDUINO_ARCH_RP2040)
69- // --------------------------------------------------------------------+
70- // For RP2040 use both core0 for device stack, core1 for host stack
71- // --------------------------------------------------------------------//
72-
73- // ------------- Core0 -------------//
74- void loop () {
75- }
7652
77- // ------------- Core1 -------------//
78- void setup1 () {
7953 // configure pio-usb: defined in usbh_helper.h
8054 rp2040_configure_pio_usb ();
8155
8256 // run host stack on controller (rhport) 1
8357 // Note: For rp2040 pico-pio-usb, calling USBHost.begin() on core1 will have most of the
8458 // host bit-banging processing works done in core1 to free up core0 for other works
8559 USBHost.begin (1 );
60+ delay (3000 );
61+ Serial.print (" USB D+ Pin:" );
62+ Serial.println (PIN_USB_HOST_DP);
63+ Serial.print (" USB 5V Pin:" );
64+ Serial.println (PIN_5V_EN);
8665}
8766
88- void loop1 () {
67+ void loop () {
8968 USBHost.task ();
9069 Serial.flush ();
9170
9271}
93- #endif
9472
9573// --------------------------------------------------------------------+
9674// HID Host Callback Functions
@@ -112,16 +90,15 @@ void tuh_hid_umount_cb(uint8_t dev_addr, uint8_t instance)
11290 Serial.printf (" HID device unmounted (address %d, instance %d)\n " , dev_addr, instance);
11391}
11492
115-
11693void tuh_hid_report_received_cb (uint8_t dev_addr, uint8_t instance, uint8_t const * report, uint16_t len) {
11794
11895 if (report[BYTE_DPAD_LEFT_RIGHT] != DPAD_NEUTRAL ||
11996 report[BYTE_DPAD_UP_DOWN] != DPAD_NEUTRAL ||
12097 report[BYTE_ABXY_BUTTONS] != BUTTON_NEUTRAL ||
12198 report[BYTE_OTHER_BUTTONS] != BUTTON_MISC_NEUTRAL){
122-
99+
123100 printed_blank = false ;
124-
101+
125102 // debug print report data
126103 // Serial.print("Report data: ");
127104 // for (int i = 0; i < len; i++) {
0 commit comments