add support for Metro rp2350, remove unused usb hid device handling, remove device name from folder.
This commit is contained in:
parent
3f0ed86c37
commit
74b401d622
5 changed files with 28 additions and 31 deletions
|
|
@ -48,34 +48,8 @@ hid_gamepad_report_t gp;
|
||||||
bool printed_blank = false;
|
bool printed_blank = false;
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
if (!TinyUSBDevice.isInitialized()) {
|
|
||||||
TinyUSBDevice.begin(0);
|
|
||||||
}
|
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
// Setup HID
|
|
||||||
usb_hid.setPollInterval(2);
|
|
||||||
usb_hid.setReportDescriptor(desc_hid_report, sizeof(desc_hid_report));
|
|
||||||
usb_hid.begin();
|
|
||||||
|
|
||||||
// If already enumerated, additional class driver begin() e.g msc, hid, midi won't take effect until re-enumeration
|
|
||||||
if (TinyUSBDevice.mounted()) {
|
|
||||||
TinyUSBDevice.detach();
|
|
||||||
delay(10);
|
|
||||||
TinyUSBDevice.attach();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(ARDUINO_ARCH_RP2040)
|
|
||||||
//--------------------------------------------------------------------+
|
|
||||||
// For RP2040 use both core0 for device stack, core1 for host stack
|
|
||||||
//--------------------------------------------------------------------//
|
|
||||||
|
|
||||||
//------------- Core0 -------------//
|
|
||||||
void loop() {
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------- Core1 -------------//
|
|
||||||
void setup1() {
|
|
||||||
// configure pio-usb: defined in usbh_helper.h
|
// configure pio-usb: defined in usbh_helper.h
|
||||||
rp2040_configure_pio_usb();
|
rp2040_configure_pio_usb();
|
||||||
|
|
||||||
|
|
@ -83,14 +57,18 @@ void setup1() {
|
||||||
// Note: For rp2040 pico-pio-usb, calling USBHost.begin() on core1 will have most of the
|
// Note: For rp2040 pico-pio-usb, calling USBHost.begin() on core1 will have most of the
|
||||||
// host bit-banging processing works done in core1 to free up core0 for other works
|
// host bit-banging processing works done in core1 to free up core0 for other works
|
||||||
USBHost.begin(1);
|
USBHost.begin(1);
|
||||||
|
delay(3000);
|
||||||
|
Serial.print("USB D+ Pin:");
|
||||||
|
Serial.println(PIN_USB_HOST_DP);
|
||||||
|
Serial.print("USB 5V Pin:");
|
||||||
|
Serial.println(PIN_5V_EN);
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop1() {
|
void loop() {
|
||||||
USBHost.task();
|
USBHost.task();
|
||||||
Serial.flush();
|
Serial.flush();
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// HID Host Callback Functions
|
// HID Host Callback Functions
|
||||||
|
|
@ -112,7 +90,6 @@ void tuh_hid_umount_cb(uint8_t dev_addr, uint8_t instance)
|
||||||
Serial.printf("HID device unmounted (address %d, instance %d)\n", dev_addr, instance);
|
Serial.printf("HID device unmounted (address %d, instance %d)\n", dev_addr, instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void tuh_hid_report_received_cb(uint8_t dev_addr, uint8_t instance, uint8_t const* report, uint16_t len) {
|
void tuh_hid_report_received_cb(uint8_t dev_addr, uint8_t instance, uint8_t const* report, uint16_t len) {
|
||||||
|
|
||||||
if (report[BYTE_DPAD_LEFT_RIGHT] != DPAD_NEUTRAL ||
|
if (report[BYTE_DPAD_LEFT_RIGHT] != DPAD_NEUTRAL ||
|
||||||
|
|
@ -35,6 +35,26 @@
|
||||||
#endif
|
#endif
|
||||||
#endif // ARDUINO_ARCH_RP2040
|
#endif // ARDUINO_ARCH_RP2040
|
||||||
|
|
||||||
|
#ifdef ARDUINO_ARCH_RP2350
|
||||||
|
|
||||||
|
// pio-usb is required for rp2040 host
|
||||||
|
#include "pio_usb.h"
|
||||||
|
|
||||||
|
// Pin D+ for host, D- = D+ + 1
|
||||||
|
#ifndef PIN_USB_HOST_DP
|
||||||
|
#define PIN_USB_HOST_DP 32
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Pin for enabling Host VBUS. comment out if not used
|
||||||
|
#ifndef PIN_5V_EN
|
||||||
|
#define PIN_5V_EN 29
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef PIN_5V_EN_STATE
|
||||||
|
#define PIN_5V_EN_STATE 1
|
||||||
|
#endif
|
||||||
|
#endif // ARDUINO_ARCH_RP2350
|
||||||
|
|
||||||
#include "Adafruit_TinyUSB.h"
|
#include "Adafruit_TinyUSB.h"
|
||||||
|
|
||||||
#if defined(CFG_TUH_MAX3421) && CFG_TUH_MAX3421
|
#if defined(CFG_TUH_MAX3421) && CFG_TUH_MAX3421
|
||||||
Loading…
Reference in a new issue