Skip to content

Commit 2b0b814

Browse files
authored
Merge pull request #346 from adafruit/support-featherwing-max3421
Support featherwing max3421
2 parents 22f5dac + 2ca4b90 commit 2b0b814

File tree

18 files changed

+136
-30
lines changed

18 files changed

+136
-30
lines changed

examples/DualRole/CDC/serial_host_bridge/usbh_helper.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,14 @@
3939

4040
#if defined(ARDUINO_METRO_ESP32S2)
4141
Adafruit_USBH_Host USBHost(&SPI, 15, 14);
42-
#else
43-
// Default use SPI and pin 10, 9 for CS and INT
42+
#elif defined(ARDUINO_ADAFRUIT_FEATHER_ESP32_V2)
43+
Adafruit_USBH_Host USBHost(&SPI, 27, 33);
44+
#elif defined(ARDUINO_METRO_ESP32S3) || defined(ADAFRUIT_METRO_M4_EXPRESS) || defined(ADAFRUIT_METRO_M0_EXPRESS)
45+
// For Metro shape CS and INT are pin 10, 9 (host shield default)
4446
Adafruit_USBH_Host USBHost(&SPI, 10, 9);
47+
#else
48+
// default to FeatherWing USB Host MAX3421E: CS and INT are pin D11, D10
49+
Adafruit_USBH_Host USBHost(&SPI, 11, 10);
4550
#endif
4651
#else
4752
// Native USB Host such as rp2040

examples/DualRole/HID/hid_device_report/usbh_helper.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,14 @@
3939

4040
#if defined(ARDUINO_METRO_ESP32S2)
4141
Adafruit_USBH_Host USBHost(&SPI, 15, 14);
42-
#else
43-
// Default use SPI and pin 10, 9 for CS and INT
42+
#elif defined(ARDUINO_ADAFRUIT_FEATHER_ESP32_V2)
43+
Adafruit_USBH_Host USBHost(&SPI, 27, 33);
44+
#elif defined(ARDUINO_METRO_ESP32S3) || defined(ADAFRUIT_METRO_M4_EXPRESS) || defined(ADAFRUIT_METRO_M0_EXPRESS)
45+
// For Metro shape CS and INT are pin 10, 9 (host shield default)
4446
Adafruit_USBH_Host USBHost(&SPI, 10, 9);
47+
#else
48+
// default to FeatherWing USB Host MAX3421E: CS and INT are pin D11, D10
49+
Adafruit_USBH_Host USBHost(&SPI, 11, 10);
4550
#endif
4651
#else
4752
// Native USB Host such as rp2040

examples/DualRole/HID/hid_mouse_log_filter/hid_mouse_log_filter.ino

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,13 @@ void setup() {
5757
Serial.begin(115200);
5858
usb_hid.begin();
5959

60-
#ifndef ARDUINO_ARCH_RP2040
60+
#if defined(CFG_TUH_MAX3421) && CFG_TUH_MAX3421
6161
// init host stack on controller (rhport) 1
6262
// For rp2040: this is called in core1's setup1()
6363
USBHost.begin(1);
64+
65+
// FeatherWing USB Host use MAX3421E's GPIO0 as VBUS enable (active high)
66+
USBHost.max3421_writeIOPINS1(0x01, false);
6467
#endif
6568

6669
//while ( !Serial ) delay(10); // wait for native usb

examples/DualRole/HID/hid_mouse_log_filter/usbh_helper.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,14 @@
3939

4040
#if defined(ARDUINO_METRO_ESP32S2)
4141
Adafruit_USBH_Host USBHost(&SPI, 15, 14);
42-
#else
43-
// Default use SPI and pin 10, 9 for CS and INT
42+
#elif defined(ARDUINO_ADAFRUIT_FEATHER_ESP32_V2)
43+
Adafruit_USBH_Host USBHost(&SPI, 27, 33);
44+
#elif defined(ARDUINO_METRO_ESP32S3) || defined(ADAFRUIT_METRO_M4_EXPRESS) || defined(ADAFRUIT_METRO_M0_EXPRESS)
45+
// For Metro shape CS and INT are pin 10, 9 (host shield default)
4446
Adafruit_USBH_Host USBHost(&SPI, 10, 9);
47+
#else
48+
// default to FeatherWing USB Host MAX3421E: CS and INT are pin D11, D10
49+
Adafruit_USBH_Host USBHost(&SPI, 11, 10);
4550
#endif
4651
#else
4752
// Native USB Host such as rp2040

examples/DualRole/HID/hid_mouse_tremor_filter/hid_mouse_tremor_filter.ino

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,13 @@ void setup() {
6868
coeffs[0] = butterworth_lowpass(CUTOFF_FREQUENCY, SAMPLING_FREQUENCY);
6969
coeffs[1] = butterworth_lowpass(CUTOFF_FREQUENCY, SAMPLING_FREQUENCY);
7070

71-
#ifndef ARDUINO_ARCH_RP2040
71+
#if defined(CFG_TUH_MAX3421) && CFG_TUH_MAX3421
7272
// init host stack on controller (rhport) 1
7373
// For rp2040: this is called in core1's setup1()
7474
USBHost.begin(1);
75+
76+
// FeatherWing USB Host use MAX3421E's GPIO0 as VBUS enable (active high)
77+
USBHost.max3421_writeIOPINS1(0x01, false);
7578
#endif
7679

7780
//while ( !Serial ) delay(10); // wait for native usb

examples/DualRole/HID/hid_mouse_tremor_filter/usbh_helper.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,14 @@
3939

4040
#if defined(ARDUINO_METRO_ESP32S2)
4141
Adafruit_USBH_Host USBHost(&SPI, 15, 14);
42-
#else
43-
// Default use SPI and pin 10, 9 for CS and INT
42+
#elif defined(ARDUINO_ADAFRUIT_FEATHER_ESP32_V2)
43+
Adafruit_USBH_Host USBHost(&SPI, 27, 33);
44+
#elif defined(ARDUINO_METRO_ESP32S3) || defined(ADAFRUIT_METRO_M4_EXPRESS) || defined(ADAFRUIT_METRO_M0_EXPRESS)
45+
// For Metro shape CS and INT are pin 10, 9 (host shield default)
4446
Adafruit_USBH_Host USBHost(&SPI, 10, 9);
47+
#else
48+
// default to FeatherWing USB Host MAX3421E: CS and INT are pin D11, D10
49+
Adafruit_USBH_Host USBHost(&SPI, 11, 10);
4550
#endif
4651
#else
4752
// Native USB Host such as rp2040

examples/DualRole/HID/hid_remapper/hid_remapper.ino

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,13 @@ void setup() {
5151
Serial.begin(115200);
5252
usb_hid.begin();
5353

54-
#ifndef ARDUINO_ARCH_RP2040
54+
#if defined(CFG_TUH_MAX3421) && CFG_TUH_MAX3421
5555
// init host stack on controller (rhport) 1
5656
// For rp2040: this is called in core1's setup1()
5757
USBHost.begin(1);
58+
59+
// FeatherWing USB Host use MAX3421E's GPIO0 as VBUS enable (active high)
60+
USBHost.max3421_writeIOPINS1(0x01, false);
5861
#endif
5962

6063
//while ( !Serial ) delay(10); // wait for native usb

examples/DualRole/HID/hid_remapper/usbh_helper.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,14 @@
3939

4040
#if defined(ARDUINO_METRO_ESP32S2)
4141
Adafruit_USBH_Host USBHost(&SPI, 15, 14);
42-
#else
43-
// Default use SPI and pin 10, 9 for CS and INT
42+
#elif defined(ARDUINO_ADAFRUIT_FEATHER_ESP32_V2)
43+
Adafruit_USBH_Host USBHost(&SPI, 27, 33);
44+
#elif defined(ARDUINO_METRO_ESP32S3) || defined(ADAFRUIT_METRO_M4_EXPRESS) || defined(ADAFRUIT_METRO_M0_EXPRESS)
45+
// For Metro shape CS and INT are pin 10, 9 (host shield default)
4446
Adafruit_USBH_Host USBHost(&SPI, 10, 9);
47+
#else
48+
// default to FeatherWing USB Host MAX3421E: CS and INT are pin D11, D10
49+
Adafruit_USBH_Host USBHost(&SPI, 11, 10);
4550
#endif
4651
#else
4752
// Native USB Host such as rp2040

examples/DualRole/MassStorage/msc_data_logger/msc_data_logger.ino

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,13 @@ void setup() {
114114

115115
pinMode(LED_BUILTIN, OUTPUT);
116116

117-
#ifndef ARDUINO_ARCH_RP2040
117+
#if defined(CFG_TUH_MAX3421) && CFG_TUH_MAX3421
118118
// init host stack on controller (rhport) 1
119119
// For rp2040: this is called in core1's setup1()
120120
USBHost.begin(1);
121+
122+
// FeatherWing USB Host use MAX3421E's GPIO0 as VBUS enable (active high)
123+
USBHost.max3421_writeIOPINS1(0x01, false);
121124
#endif
122125

123126
#ifdef USE_FREERTOS

examples/DualRole/MassStorage/msc_data_logger/usbh_helper.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,14 @@
3939

4040
#if defined(ARDUINO_METRO_ESP32S2)
4141
Adafruit_USBH_Host USBHost(&SPI, 15, 14);
42-
#else
43-
// Default use SPI and pin 10, 9 for CS and INT
42+
#elif defined(ARDUINO_ADAFRUIT_FEATHER_ESP32_V2)
43+
Adafruit_USBH_Host USBHost(&SPI, 27, 33);
44+
#elif defined(ARDUINO_METRO_ESP32S3) || defined(ADAFRUIT_METRO_M4_EXPRESS) || defined(ADAFRUIT_METRO_M0_EXPRESS)
45+
// For Metro shape CS and INT are pin 10, 9 (host shield default)
4446
Adafruit_USBH_Host USBHost(&SPI, 10, 9);
47+
#else
48+
// default to FeatherWing USB Host MAX3421E: CS and INT are pin D11, D10
49+
Adafruit_USBH_Host USBHost(&SPI, 11, 10);
4550
#endif
4651
#else
4752
// Native USB Host such as rp2040

0 commit comments

Comments
 (0)