@@ -48,49 +48,27 @@ hid_gamepad_report_t gp;
48
48
bool printed_blank = false ;
49
49
50
50
void setup () {
51
- if (!TinyUSBDevice.isInitialized ()) {
52
- TinyUSBDevice.begin (0 );
53
- }
54
51
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
- }
76
52
77
- // ------------- Core1 -------------//
78
- void setup1 () {
79
53
// configure pio-usb: defined in usbh_helper.h
80
54
rp2040_configure_pio_usb ();
81
55
82
56
// run host stack on controller (rhport) 1
83
57
// Note: For rp2040 pico-pio-usb, calling USBHost.begin() on core1 will have most of the
84
58
// host bit-banging processing works done in core1 to free up core0 for other works
85
59
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);
86
65
}
87
66
88
- void loop1 () {
67
+ void loop () {
89
68
USBHost.task ();
90
69
Serial.flush ();
91
70
92
71
}
93
- #endif
94
72
95
73
// --------------------------------------------------------------------+
96
74
// HID Host Callback Functions
@@ -112,16 +90,15 @@ void tuh_hid_umount_cb(uint8_t dev_addr, uint8_t instance)
112
90
Serial.printf (" HID device unmounted (address %d, instance %d)\n " , dev_addr, instance);
113
91
}
114
92
115
-
116
93
void tuh_hid_report_received_cb (uint8_t dev_addr, uint8_t instance, uint8_t const * report, uint16_t len) {
117
94
118
95
if (report[BYTE_DPAD_LEFT_RIGHT] != DPAD_NEUTRAL ||
119
96
report[BYTE_DPAD_UP_DOWN] != DPAD_NEUTRAL ||
120
97
report[BYTE_ABXY_BUTTONS] != BUTTON_NEUTRAL ||
121
98
report[BYTE_OTHER_BUTTONS] != BUTTON_MISC_NEUTRAL){
122
-
99
+
123
100
printed_blank = false ;
124
-
101
+
125
102
// debug print report data
126
103
// Serial.print("Report data: ");
127
104
// for (int i = 0; i < len; i++) {
0 commit comments