Skip to content

Commit 74b401d

Browse files
committed
add support for Metro rp2350, remove unused usb hid device handling, remove device name from folder.
1 parent 3f0ed86 commit 74b401d

File tree

5 files changed

+28
-31
lines changed

5 files changed

+28
-31
lines changed

USB_SNES_Gamepad/Arduino_USB_Host/snes_gamepad_simpletest/.metro_rp2350_usbhost_tinyusb.test.only

Whitespace-only changes.
Lines changed: 8 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -48,49 +48,27 @@ hid_gamepad_report_t gp;
4848
bool printed_blank = false;
4949

5050
void 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-
11693
void 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++) {
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,26 @@
3535
#endif
3636
#endif // ARDUINO_ARCH_RP2040
3737

38+
#ifdef ARDUINO_ARCH_RP2350
39+
40+
// pio-usb is required for rp2040 host
41+
#include "pio_usb.h"
42+
43+
// Pin D+ for host, D- = D+ + 1
44+
#ifndef PIN_USB_HOST_DP
45+
#define PIN_USB_HOST_DP 32
46+
#endif
47+
48+
// Pin for enabling Host VBUS. comment out if not used
49+
#ifndef PIN_5V_EN
50+
#define PIN_5V_EN 29
51+
#endif
52+
53+
#ifndef PIN_5V_EN_STATE
54+
#define PIN_5V_EN_STATE 1
55+
#endif
56+
#endif // ARDUINO_ARCH_RP2350
57+
3858
#include "Adafruit_TinyUSB.h"
3959

4060
#if defined(CFG_TUH_MAX3421) && CFG_TUH_MAX3421

0 commit comments

Comments
 (0)