Skip to content

Commit 61e908e

Browse files
committed
add support for running tinyusb + max3421 on no OTG MCU such as esp32
1 parent f3e0ff7 commit 61e908e

File tree

11 files changed

+38
-5
lines changed

11 files changed

+38
-5
lines changed

examples/DualRole/CDC/serial_host_bridge/usbh_helper.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939

4040
#if defined(ARDUINO_METRO_ESP32S2)
4141
Adafruit_USBH_Host USBHost(&SPI, 15, 14);
42+
#elif defined(ARDUINO_ADAFRUIT_FEATHER_ESP32_V2)
43+
Adafruit_USBH_Host USBHost(&SPI, 27, 33);
4244
#elif defined(ARDUINO_METRO_ESP32S3) || defined(ADAFRUIT_METRO_M4_EXPRESS) || defined(ADAFRUIT_METRO_M0_EXPRESS)
4345
// For Metro shape CS and INT are pin 10, 9 (host shield default)
4446
Adafruit_USBH_Host USBHost(&SPI, 10, 9);

examples/DualRole/HID/hid_device_report/usbh_helper.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939

4040
#if defined(ARDUINO_METRO_ESP32S2)
4141
Adafruit_USBH_Host USBHost(&SPI, 15, 14);
42+
#elif defined(ARDUINO_ADAFRUIT_FEATHER_ESP32_V2)
43+
Adafruit_USBH_Host USBHost(&SPI, 27, 33);
4244
#elif defined(ARDUINO_METRO_ESP32S3) || defined(ADAFRUIT_METRO_M4_EXPRESS) || defined(ADAFRUIT_METRO_M0_EXPRESS)
4345
// For Metro shape CS and INT are pin 10, 9 (host shield default)
4446
Adafruit_USBH_Host USBHost(&SPI, 10, 9);

examples/DualRole/HID/hid_mouse_log_filter/usbh_helper.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939

4040
#if defined(ARDUINO_METRO_ESP32S2)
4141
Adafruit_USBH_Host USBHost(&SPI, 15, 14);
42+
#elif defined(ARDUINO_ADAFRUIT_FEATHER_ESP32_V2)
43+
Adafruit_USBH_Host USBHost(&SPI, 27, 33);
4244
#elif defined(ARDUINO_METRO_ESP32S3) || defined(ADAFRUIT_METRO_M4_EXPRESS) || defined(ADAFRUIT_METRO_M0_EXPRESS)
4345
// For Metro shape CS and INT are pin 10, 9 (host shield default)
4446
Adafruit_USBH_Host USBHost(&SPI, 10, 9);

examples/DualRole/HID/hid_mouse_tremor_filter/usbh_helper.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939

4040
#if defined(ARDUINO_METRO_ESP32S2)
4141
Adafruit_USBH_Host USBHost(&SPI, 15, 14);
42+
#elif defined(ARDUINO_ADAFRUIT_FEATHER_ESP32_V2)
43+
Adafruit_USBH_Host USBHost(&SPI, 27, 33);
4244
#elif defined(ARDUINO_METRO_ESP32S3) || defined(ADAFRUIT_METRO_M4_EXPRESS) || defined(ADAFRUIT_METRO_M0_EXPRESS)
4345
// For Metro shape CS and INT are pin 10, 9 (host shield default)
4446
Adafruit_USBH_Host USBHost(&SPI, 10, 9);

examples/DualRole/HID/hid_remapper/usbh_helper.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939

4040
#if defined(ARDUINO_METRO_ESP32S2)
4141
Adafruit_USBH_Host USBHost(&SPI, 15, 14);
42+
#elif defined(ARDUINO_ADAFRUIT_FEATHER_ESP32_V2)
43+
Adafruit_USBH_Host USBHost(&SPI, 27, 33);
4244
#elif defined(ARDUINO_METRO_ESP32S3) || defined(ADAFRUIT_METRO_M4_EXPRESS) || defined(ADAFRUIT_METRO_M0_EXPRESS)
4345
// For Metro shape CS and INT are pin 10, 9 (host shield default)
4446
Adafruit_USBH_Host USBHost(&SPI, 10, 9);

examples/DualRole/MassStorage/msc_data_logger/usbh_helper.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939

4040
#if defined(ARDUINO_METRO_ESP32S2)
4141
Adafruit_USBH_Host USBHost(&SPI, 15, 14);
42+
#elif defined(ARDUINO_ADAFRUIT_FEATHER_ESP32_V2)
43+
Adafruit_USBH_Host USBHost(&SPI, 27, 33);
4244
#elif defined(ARDUINO_METRO_ESP32S3) || defined(ADAFRUIT_METRO_M4_EXPRESS) || defined(ADAFRUIT_METRO_M0_EXPRESS)
4345
// For Metro shape CS and INT are pin 10, 9 (host shield default)
4446
Adafruit_USBH_Host USBHost(&SPI, 10, 9);

examples/DualRole/MassStorage/msc_file_explorer/usbh_helper.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939

4040
#if defined(ARDUINO_METRO_ESP32S2)
4141
Adafruit_USBH_Host USBHost(&SPI, 15, 14);
42+
#elif defined(ARDUINO_ADAFRUIT_FEATHER_ESP32_V2)
43+
Adafruit_USBH_Host USBHost(&SPI, 27, 33);
4244
#elif defined(ARDUINO_METRO_ESP32S3) || defined(ADAFRUIT_METRO_M4_EXPRESS) || defined(ADAFRUIT_METRO_M0_EXPRESS)
4345
// For Metro shape CS and INT are pin 10, 9 (host shield default)
4446
Adafruit_USBH_Host USBHost(&SPI, 10, 9);

examples/DualRole/Simple/device_info/usbh_helper.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939

4040
#if defined(ARDUINO_METRO_ESP32S2)
4141
Adafruit_USBH_Host USBHost(&SPI, 15, 14);
42+
#elif defined(ARDUINO_ADAFRUIT_FEATHER_ESP32_V2)
43+
Adafruit_USBH_Host USBHost(&SPI, 27, 33);
4244
#elif defined(ARDUINO_METRO_ESP32S3) || defined(ADAFRUIT_METRO_M4_EXPRESS) || defined(ADAFRUIT_METRO_M0_EXPRESS)
4345
// For Metro shape CS and INT are pin 10, 9 (host shield default)
4446
Adafruit_USBH_Host USBHost(&SPI, 10, 9);

src/arduino/Adafruit_USBH_Host.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#ifdef ARDUINO_ARCH_ESP32
2727
#include "arduino/ports/esp32/tusb_config_esp32.h"
2828
#include "driver/gpio.h"
29+
#include <Arduino.h>
2930
#define MSBFIRST SPI_MSBFIRST
3031
#endif
3132

@@ -123,15 +124,13 @@ bool Adafruit_USBH_Host::begin(uint8_t rhport) {
123124
#ifdef ARDUINO_ARCH_ESP32
124125
// ESP32 SPI assign pins when begin() of declaration as standard API
125126
_spi->begin(_sck, _miso, _mosi, -1);
126-
#else
127-
_spi->begin();
128-
#endif
129127

130-
#ifdef ARDUINO_ARCH_ESP32
131128
// Create an task for executing interrupt handler in thread mode
132129
max3421_intr_sem = xSemaphoreCreateBinary();
133130
xTaskCreateUniversal(max3421_intr_task, "max3421 intr", 2048, NULL, 5, NULL,
134131
ARDUINO_RUNNING_CORE);
132+
#else
133+
_spi->begin();
135134
#endif
136135

137136
// Interrupt pin

src/arduino/ports/esp32/tusb_config_esp32.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,20 @@ extern "C" {
5757
#define CFG_TUH_LOG_LEVEL 2
5858
#endif
5959

60+
//--------------------------------------------------------------------
61+
// COMMON CONFIGURATION
62+
// Note: it is possible to use tinyusb + max3421e as host controller
63+
// with no OTG USB MCU such as eps32, c3 etc...
64+
//--------------------------------------------------------------------
65+
66+
#ifndef CFG_TUSB_OS
67+
#define CFG_TUSB_OS OPT_OS_FREERTOS
68+
69+
// clang-format off
70+
#define CFG_TUSB_OS_INC_PATH freertos/
71+
// clang-format on
72+
#endif
73+
6074
// #ifndef CFG_TUSB_DEBUG
6175
// #define CFG_TUSB_DEBUG 0
6276
// #endif

src/tusb_config.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,11 @@
4242
// Note: when compiling core Arduino IDEs will include tusb_config.h in the BSP
4343
// sdk/include/arduino_tinyusb/include. While compiling .c file in this library this
4444
// file will be used instead. For consistency: include the one in BSP here as well
45-
#include "../../arduino_tinyusb/include/tusb_config.h"
45+
#if CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3
46+
#include "../../arduino_tinyusb/include/tusb_config.h"
47+
#else
48+
#include "arduino/ports/esp32/tusb_config_esp32.h"
49+
#endif
4650

4751
// Note: For platformio prioritize this file over the one in BSP in all cases
4852

0 commit comments

Comments
 (0)