Skip to content

Commit 605d681

Browse files
committed
feat(esp32) resolve conflict with latest v3.1.3. better enforce tusb_config_esp32.h within tusb_option.h
also change CFG_TUD_MIDI_RX/TX_BUFSIZE for rp2040 to 64
1 parent 41bde22 commit 605d681

File tree

26 files changed

+69
-131
lines changed

26 files changed

+69
-131
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ Following core has TinyUSB as either the primary usb stack or selectable via men
3838
- [adafruit/Adafruit_nRF52_Arduino](https://github.com/adafruit/Adafruit_nRF52_Arduino)
3939
- [adafruit/ArduinoCore-samd](https://github.com/adafruit/ArduinoCore-samd)
4040
- [earlephilhower/arduino-pico](https://github.com/earlephilhower/arduino-pico)
41-
- [espressif/arduino-esp32](https://github.com/espressif/arduino-esp32)
41+
- [espressif/arduino-esp32](https://github.com/espressif/arduino-esp32) additional Tools menu is needed
42+
- `USB Mode=USB-OTG (TinyUSB)` for S3 and P4
43+
- `USB CDC On Boot=Enabled`, `USB Firmware MSC On Boot=Disabled`, `USB DFU On Boot=Disabled`
4244
- [openwch/arduino_core_ch32](https://github.com/openwch/arduino_core_ch32)
4345

4446
Note: For ESP32 port, version before v3.0 requires all descriptors must be specified in usb objects declaration i.e constructors. Therefore all descriptor-related fields must be part of object declaration and descriptor-related API have no effect afterwards. This limitation is not the case for version from v3.0.

src/Adafruit_TinyUSB.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,6 @@
2525
#ifndef ADAFRUIT_TINYUSB_H_
2626
#define ADAFRUIT_TINYUSB_H_
2727

28-
// ESP32 out-of-sync
29-
#ifdef ARDUINO_ARCH_ESP32
30-
#include "arduino/ports/esp32/tusb_config_esp32.h"
31-
#endif
32-
3328
#include "tusb_option.h"
3429

3530
// Device

src/arduino/ports/esp32/tusb_config_esp32.h

Lines changed: 60 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -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))

src/arduino/ports/rp2040/tusb_config_rp2040.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ extern "C" {
117117
#define CFG_TUD_HID_EP_BUFSIZE 64
118118

119119
// MIDI FIFO size of TX and RX
120-
#define CFG_TUD_MIDI_RX_BUFSIZE 128
121-
#define CFG_TUD_MIDI_TX_BUFSIZE 128
120+
#define CFG_TUD_MIDI_RX_BUFSIZE 64
121+
#define CFG_TUD_MIDI_TX_BUFSIZE 64
122122

123123
// Vendor FIFO size of TX and RX
124124
#define CFG_TUD_VENDOR_RX_BUFSIZE 64

src/class/audio/audio_device.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,6 @@
5656
//--------------------------------------------------------------------+
5757
// INCLUDE
5858
//--------------------------------------------------------------------+
59-
// ESP32 out-of-sync
60-
#ifdef ARDUINO_ARCH_ESP32
61-
#include "arduino/ports/esp32/tusb_config_esp32.h"
62-
#endif
63-
6459
#include "device/usbd.h"
6560
#include "device/usbd_pvt.h"
6661

src/class/bth/bth_device.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,6 @@
3131
//--------------------------------------------------------------------+
3232
// INCLUDE
3333
//--------------------------------------------------------------------+
34-
35-
// ESP32 out-of-sync
36-
#ifdef ARDUINO_ARCH_ESP32
37-
#include "arduino/ports/esp32/tusb_config_esp32.h"
38-
#endif
39-
4034
#include "bth_device.h"
4135
#include <device/usbd_pvt.h>
4236

src/class/cdc/cdc_device.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,6 @@
2424
* This file is part of the TinyUSB stack.
2525
*/
2626

27-
// ESP32 out-of-sync
28-
#ifdef ARDUINO_ARCH_ESP32
29-
#include "arduino/ports/esp32/tusb_config_esp32.h"
30-
#endif
31-
3227
#include "tusb_option.h"
3328

3429
#if (CFG_TUD_ENABLED && CFG_TUD_CDC)

src/class/dfu/dfu_device.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,6 @@
2424
* This file is part of the TinyUSB stack.
2525
*/
2626

27-
// ESP32 out-of-sync
28-
#ifdef ARDUINO_ARCH_ESP32
29-
#include "arduino/ports/esp32/tusb_config_esp32.h"
30-
#endif
31-
3227
#include "tusb_option.h"
3328

3429
#if (CFG_TUD_ENABLED && CFG_TUD_DFU)

src/class/dfu/dfu_rt_device.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,6 @@
2424
* This file is part of the TinyUSB stack.
2525
*/
2626

27-
// ESP32 out-of-sync
28-
#ifdef ARDUINO_ARCH_ESP32
29-
#include "arduino/ports/esp32/tusb_config_esp32.h"
30-
#endif
31-
3227
#include "tusb_option.h"
3328

3429
#if (CFG_TUD_ENABLED && CFG_TUD_DFU_RUNTIME)

src/class/hid/hid_host.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,6 @@
2424
* This file is part of the TinyUSB stack.
2525
*/
2626

27-
// ESP32 out-of-sync
28-
#ifdef ARDUINO_ARCH_ESP32
29-
#include "arduino/ports/esp32/tusb_config_esp32.h"
30-
#endif
31-
3227
#include "tusb_option.h"
3328

3429
#if (CFG_TUH_ENABLED && CFG_TUH_HID)

0 commit comments

Comments
 (0)