Skip to content

Commit 8ef3020

Browse files
authored
Merge pull request #498 from adafruit/update-tinyusb-1cfc88dbcb8cff6f926aef02c5609880169ec94c
Update tinyusb to commit 334ac8072650e3b18278042c2c2b402db73c7359
2 parents c92b7fd + 3918606 commit 8ef3020

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+6268
-3971
lines changed

README.md

+3-1
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.

examples/DualRole/MassStorage/msc_data_logger/msc_data_logger.ino

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
#endif
3939

4040
// SdFat is required for using Adafruit_USBH_MSC_SdFatDevice
41-
#include "SdFat.h"
41+
#include "SdFat_Adafruit_Fork.h"
4242

4343
// USBHost is defined in usbh_helper.h
4444
#include "usbh_helper.h"

examples/DualRole/MassStorage/msc_file_explorer/msc_file_explorer.ino

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
*/
2828

2929
// SdFat is required for using Adafruit_USBH_MSC_SdFatDevice
30-
#include "SdFat.h"
30+
#include "SdFat_Adafruit_Fork.h"
3131

3232
// USBHost is defined in usbh_helper.h
3333
#include "usbh_helper.h"

examples/MassStorage/msc_esp32_file_browser/msc_esp32_file_browser.ino

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
*/
3333

3434
#include "SPI.h"
35-
#include "SdFat.h"
35+
#include "SdFat_Adafruit_Fork.h"
3636
#include "Adafruit_SPIFlash.h"
3737
#include "Adafruit_TinyUSB.h"
3838

examples/MassStorage/msc_external_flash/msc_external_flash.ino

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
*/
2424

2525
#include "SPI.h"
26-
#include "SdFat.h"
26+
#include "SdFat_Adafruit_Fork.h"
2727
#include "Adafruit_SPIFlash.h"
2828
#include "Adafruit_TinyUSB.h"
2929

examples/MassStorage/msc_external_flash_sdcard/msc_external_flash_sdcard.ino

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
*/
2424

2525
#include "SPI.h"
26-
#include "SdFat.h"
26+
#include "SdFat_Adafruit_Fork.h"
2727
#include "Adafruit_SPIFlash.h"
2828
#include "Adafruit_TinyUSB.h"
2929

examples/MassStorage/msc_internal_flash_samd/msc_internal_flash_samd.ino

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*********************************************************************/
1111

1212
#include "SPI.h"
13-
#include "SdFat.h"
13+
#include "SdFat_Adafruit_Fork.h"
1414
#include "Adafruit_InternalFlash.h"
1515
#include "Adafruit_TinyUSB.h"
1616

examples/MassStorage/msc_sdfat/msc_sdfat.ino

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
*/
1515

1616
#include "SPI.h"
17-
#include "SdFat.h"
17+
#include "SdFat_Adafruit_Fork.h"
1818
#include "Adafruit_TinyUSB.h"
1919

2020
const int chipSelect = 10;

src/Adafruit_TinyUSB.h

-5
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/Adafruit_TinyUSB_API.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131

3232
extern "C" {
3333

34+
uint32_t tusb_time_millis_api(void) { return millis(); }
35+
3436
//--------------------------------------------------------------------+
3537
// Device
3638
//--------------------------------------------------------------------+

src/arduino/msc/Adafruit_USBH_MSC.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
#include "Adafruit_USBH_MSC.h"
3535
#include "tusb.h"
3636

37-
#if __has_include("SdFat.h")
37+
#if __has_include("SdFat_Adafruit_Fork.h")
3838

3939
Adafruit_USBH_MSC_BlockDevice::Adafruit_USBH_MSC_BlockDevice() {
4040
_daddr = _lun = 0;

src/arduino/msc/Adafruit_USBH_MSC.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@
2828
#include "tusb.h"
2929

3030
// define SdFat host helper class if SdFat library is available
31-
#if __has_include("SdFat.h")
31+
#if __has_include("SdFat_Adafruit_Fork.h")
3232

33-
#include "SdFat.h"
33+
#include "SdFat_Adafruit_Fork.h"
3434

3535
class Adafruit_USBH_MSC_BlockDevice : public FsBlockDeviceInterface {
3636
public:

src/arduino/ports/esp32/tusb_config_esp32.h

+59-10
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,42 @@ 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+
#endif
68+
69+
#if CONFIG_IDF_TARGET_ESP32P4
70+
#define CFG_TUD_MAX_SPEED OPT_MODE_HIGH_SPEED
71+
#define CFG_TUH_MAX_SPEED OPT_MODE_HIGH_SPEED
72+
#else
73+
#define CFG_TUD_MAX_SPEED OPT_MODE_FULL_SPEED
74+
#define CFG_TUH_MAX_SPEED OPT_MODE_FULL_SPEED
75+
#endif
76+
5277
#ifndef CFG_TUSB_OS
5378
#define CFG_TUSB_OS OPT_OS_FREERTOS
5479
// clang-format off
@@ -64,33 +89,57 @@ extern "C" {
6489
#define CFG_TUH_LOG_LEVEL 2
6590
#endif
6691

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-
7392
#ifndef CFG_TUSB_DEBUG
7493
#define CFG_TUSB_DEBUG 0
7594
#endif
7695

7796
// For selectively disable device log (when > CFG_TUSB_DEBUG)
7897
// #define CFG_TUD_LOG_LEVEL 3
7998

99+
#define CFG_TUSB_MEM_SECTION
100+
#define CFG_TUSB_MEM_ALIGN TU_ATTR_ALIGNED(4)
101+
80102
//--------------------------------------------------------------------
81103
// DEVICE CONFIGURATION
82104
//--------------------------------------------------------------------
105+
#define CFG_TUD_ENABLED 1
106+
107+
#define CFG_TUD_CDC 2
108+
#define CFG_TUD_MSC 1
109+
#define CFG_TUD_HID 2
110+
#define CFG_TUD_MIDI 1
111+
#define CFG_TUD_VENDOR 1
112+
#define CFG_TUD_VIDEO 1
113+
#define CFG_TUD_VIDEO_STREAMING 1
83114

84-
// device configuration is configured in BSP
85-
// sdk/include/arduino_tinyusb/include/tusb_config.h
115+
// video streaming endpoint buffer size
116+
#define CFG_TUD_VIDEO_STREAMING_EP_BUFSIZE \
117+
CONFIG_TINYUSB_VIDEO_STREAMING_BUFSIZE
118+
119+
// CDC FIFO size of TX and RX
120+
#define CFG_TUD_CDC_RX_BUFSIZE CONFIG_TINYUSB_CDC_RX_BUFSIZE
121+
#define CFG_TUD_CDC_TX_BUFSIZE CONFIG_TINYUSB_CDC_TX_BUFSIZE
122+
123+
// MSC Buffer size of Device Mass storage
124+
#define CFG_TUD_MSC_EP_BUFSIZE CONFIG_TINYUSB_MSC_BUFSIZE
125+
126+
// HID buffer size Should be sufficient to hold ID (if any) + Data
127+
#define CFG_TUD_HID_BUFSIZE CONFIG_TINYUSB_HID_BUFSIZE
128+
129+
// MIDI FIFO size of TX and RX
130+
#define CFG_TUD_MIDI_RX_BUFSIZE CONFIG_TINYUSB_MIDI_RX_BUFSIZE
131+
#define CFG_TUD_MIDI_TX_BUFSIZE CONFIG_TINYUSB_MIDI_TX_BUFSIZE
132+
133+
// Vendor FIFO size of TX and RX
134+
#define CFG_TUD_VENDOR_RX_BUFSIZE CONFIG_TINYUSB_VENDOR_RX_BUFSIZE
135+
#define CFG_TUD_VENDOR_TX_BUFSIZE CONFIG_TINYUSB_VENDOR_TX_BUFSIZE
86136

87137
//--------------------------------------------------------------------
88138
// Host Configuration
89139
//--------------------------------------------------------------------
90140

91141
// Enable host stack with MAX3421E (host shield)
92142
#define CFG_TUH_ENABLED 1
93-
#define CFG_TUH_MAX_SPEED OPT_MODE_FULL_SPEED
94143
#define CFG_TUH_MAX3421 1
95144

96145
#ifndef CFG_TUH_MAX3421_ENDPOINT_TOTAL

src/arduino/ports/rp2040/tusb_config_rp2040.h

+2-2
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

0 commit comments

Comments
 (0)