@@ -38,17 +38,43 @@ extern "C" {
3838// libraries, this file is used to make it compatible with ESP32 Arduino core.
3939
4040// This file also contains additional configuration for EPS32 in addition to
41- // tools/sdk /esp32xx/include/arduino_tinyusb/include/tusb_config.h
41+ // tools/esp32-arduino-libs /esp32xx/include/arduino_tinyusb/include/tusb_config.h
4242
4343//--------------------------------------------------------------------+
4444// ESP32 out-of-sync
4545//--------------------------------------------------------------------+
4646#include "esp_arduino_version.h"
47+ #include "sdkconfig.h"
4748
4849#if ESP_ARDUINO_VERSION < ESP_ARDUINO_VERSION_VAL (2 , 0 , 8 )
4950#error "ESP32 Arduino core version 2.0.8 or later is required"
5051#endif
5152
53+ //--------------------------------------------------------------------
54+ // COMMON CONFIGURATION
55+ // Note: it is possible to use tinyusb + max3421e as host controller
56+ // with no OTG USB MCU such as eps32, c3 etc...
57+ //--------------------------------------------------------------------
58+
59+ #if CONFIG_IDF_TARGET_ESP32S2
60+ #define CFG_TUSB_MCU OPT_MCU_ESP32S2
61+ #elif CONFIG_IDF_TARGET_ESP32S3
62+ #define CFG_TUSB_MCU OPT_MCU_ESP32S3
63+ #elif CONFIG_IDF_TARGET_ESP32P4
64+ #define CFG_TUSB_MCU OPT_MCU_ESP32P4
65+ #else
66+ #define CFG_TUSB_MCU OPT_MCU_ESP32
67+ #define CFG_TUH_MAX3421 1
68+ #endif
69+
70+ #if CONFIG_IDF_TARGET_ESP32P4
71+ #define CFG_TUD_MAX_SPEED OPT_MODE_HIGH_SPEED
72+ #define CFG_TUH_MAX_SPEED OPT_MODE_HIGH_SPEED
73+ #else
74+ #define CFG_TUD_MAX_SPEED OPT_MODE_FULL_SPEED
75+ #define CFG_TUH_MAX_SPEED OPT_MODE_FULL_SPEED
76+ #endif
77+
5278#ifndef CFG_TUSB_OS
5379#define CFG_TUSB_OS OPT_OS_FREERTOS
5480// clang-format off
@@ -64,34 +90,57 @@ extern "C" {
6490#define CFG_TUH_LOG_LEVEL 2
6591#endif
6692
67- //--------------------------------------------------------------------
68- // COMMON CONFIGURATION
69- // Note: it is possible to use tinyusb + max3421e as host controller
70- // with no OTG USB MCU such as eps32, c3 etc...
71- //--------------------------------------------------------------------
72-
7393#ifndef CFG_TUSB_DEBUG
7494#define CFG_TUSB_DEBUG 0
7595#endif
7696
7797// For selectively disable device log (when > CFG_TUSB_DEBUG)
7898// #define CFG_TUD_LOG_LEVEL 3
7999
100+ #define CFG_TUSB_MEM_SECTION
101+ #define CFG_TUSB_MEM_ALIGN TU_ATTR_ALIGNED(4)
102+
80103//--------------------------------------------------------------------
81104// DEVICE CONFIGURATION
82105//--------------------------------------------------------------------
106+ #define CFG_TUD_ENABLED 1
107+
108+ #define CFG_TUD_CDC 2
109+ #define CFG_TUD_MSC 1
110+ #define CFG_TUD_HID 2
111+ #define CFG_TUD_MIDI 1
112+ #define CFG_TUD_VENDOR 1
113+ #define CFG_TUD_VIDEO 1
114+ #define CFG_TUD_VIDEO_STREAMING 1
115+
116+ // video streaming endpoint buffer size
117+ #define CFG_TUD_VIDEO_STREAMING_EP_BUFSIZE \
118+ CONFIG_TINYUSB_VIDEO_STREAMING_BUFSIZE
83119
84- // device configuration is configured in BSP
85- // sdk/include/arduino_tinyusb/include/tusb_config.h
120+ // CDC FIFO size of TX and RX
121+ #define CFG_TUD_CDC_RX_BUFSIZE CONFIG_TINYUSB_CDC_RX_BUFSIZE
122+ #define CFG_TUD_CDC_TX_BUFSIZE CONFIG_TINYUSB_CDC_TX_BUFSIZE
123+
124+ // MSC Buffer size of Device Mass storage
125+ #define CFG_TUD_MSC_EP_BUFSIZE CONFIG_TINYUSB_MSC_BUFSIZE
126+
127+ // HID buffer size Should be sufficient to hold ID (if any) + Data
128+ #define CFG_TUD_HID_BUFSIZE CONFIG_TINYUSB_HID_BUFSIZE
129+
130+ // MIDI FIFO size of TX and RX
131+ #define CFG_TUD_MIDI_RX_BUFSIZE CONFIG_TINYUSB_MIDI_RX_BUFSIZE
132+ #define CFG_TUD_MIDI_TX_BUFSIZE CONFIG_TINYUSB_MIDI_TX_BUFSIZE
133+
134+ // Vendor FIFO size of TX and RX
135+ #define CFG_TUD_VENDOR_RX_BUFSIZE CONFIG_TINYUSB_VENDOR_RX_BUFSIZE
136+ #define CFG_TUD_VENDOR_TX_BUFSIZE CONFIG_TINYUSB_VENDOR_TX_BUFSIZE
86137
87138//--------------------------------------------------------------------
88139// Host Configuration
89140//--------------------------------------------------------------------
90141
91142// Enable host stack with MAX3421E (host shield)
92143#define CFG_TUH_ENABLED 1
93- #define CFG_TUH_MAX_SPEED OPT_MODE_FULL_SPEED
94- #define CFG_TUH_MAX3421 1
95144
96145#ifndef CFG_TUH_MAX3421_ENDPOINT_TOTAL
97146#define CFG_TUH_MAX3421_ENDPOINT_TOTAL (8 + 4 * (CFG_TUH_DEVICE_MAX - 1))
0 commit comments