Skip to content

Commit 7f7ac74

Browse files
committed
support esp32p4
1 parent 8ef3020 commit 7f7ac74

File tree

8 files changed

+21
-31
lines changed

8 files changed

+21
-31
lines changed

.github/workflows/githubci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ jobs:
5050
# ESP32 ci use dev json
5151
- 'feather_esp32s2'
5252
- 'feather_esp32s3'
53+
- 'esp32p4'
5354
# nRF52
5455
- 'cpb'
5556
- 'nrf52840'
@@ -69,6 +70,7 @@ jobs:
6970
uses: actions/checkout@v4
7071
with:
7172
repository: adafruit/ci-arduino
73+
ref: add-esp32p4
7274
path: ci
7375

7476
- name: pre-install

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ 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) additional Tools menu is needed
41+
- [espressif/arduino-esp32](https://github.com/espressif/arduino-esp32) Host mode using MAX3421E controller should work with all chips. Device mode only support S2/S3/P4 and additional Tools menu are needed
4242
- `USB Mode=USB-OTG (TinyUSB)` for S3 and P4
4343
- `USB CDC On Boot=Enabled`, `USB Firmware MSC On Boot=Disabled`, `USB DFU On Boot=Disabled`
4444
- [openwch/arduino_core_ch32](https://github.com/openwch/arduino_core_ch32)

examples/MIDI/midi_test/midi_test.ino

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@ void setup() {
4444

4545
Serial.begin(115200);
4646

47-
pinMode(LED_BUILTIN, OUTPUT);
48-
4947
usb_midi.setStringDescriptor("TinyUSB MIDI");
5048

5149
// Initialize MIDI, and listen to all MIDI channels

src/arduino/Adafruit_USBD_CDC.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@
3838
#define TINYUSB_API_VERSION 0
3939
#endif
4040

41-
#define BULK_PACKET_SIZE (TUD_OPT_HIGH_SPEED ? 512 : 64)
42-
4341
// SerialTinyUSB can be macro expanding to "Serial" on supported cores
4442
Adafruit_USBD_CDC SerialTinyUSB;
4543

@@ -71,8 +69,10 @@ uint16_t Adafruit_USBD_CDC::getInterfaceDescriptor(uint8_t itfnum_deprecated,
7169
uint8_t _strid = 0;
7270
#endif
7371

74-
uint8_t const desc[] = {TUD_CDC_DESCRIPTOR(itfnum, _strid, ep_notif, 8,
75-
ep_out, ep_in, BULK_PACKET_SIZE)};
72+
uint16_t const mps =
73+
(TUD_OPT_HIGH_SPEED ? 512 : 64); // TODO actual link speed
74+
uint8_t const desc[] = {
75+
TUD_CDC_DESCRIPTOR(itfnum, _strid, ep_notif, 8, ep_out, ep_in, mps)};
7676

7777
uint16_t const len = sizeof(desc);
7878

src/arduino/Adafruit_USBD_Device.cpp

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -161,18 +161,6 @@ void Adafruit_USBD_Device::task(void) {
161161
#endif
162162
}
163163

164-
bool Adafruit_USBD_Device::mounted(void) { return tud_mounted(); }
165-
166-
bool Adafruit_USBD_Device::suspended(void) { return tud_suspended(); }
167-
168-
bool Adafruit_USBD_Device::ready(void) { return tud_ready(); }
169-
170-
bool Adafruit_USBD_Device::remoteWakeup(void) { return tud_remote_wakeup(); }
171-
172-
bool Adafruit_USBD_Device::detach(void) { return tud_disconnect(); }
173-
174-
bool Adafruit_USBD_Device::attach(void) { return tud_connect(); }
175-
176164
void Adafruit_USBD_Device::clearConfiguration(void) {
177165
tusb_desc_device_t const desc_dev = {.bLength = sizeof(tusb_desc_device_t),
178166
.bDescriptorType = TUSB_DESC_DEVICE,
@@ -257,8 +245,10 @@ bool Adafruit_USBD_Device::begin(uint8_t rhport) {
257245
// follow USBCDC cdc descriptor
258246
uint8_t itfnum = allocInterface(2);
259247
uint8_t strid = addStringDescriptor("TinyUSB Serial");
248+
uint16_t const mps =
249+
(TUD_OPT_HIGH_SPEED ? 512 : 64); // TODO actual link speed
260250
uint8_t const desc_cdc[TUD_CDC_DESC_LEN] = {
261-
TUD_CDC_DESCRIPTOR(itfnum, strid, 0x85, 64, 0x03, 0x84, 64)};
251+
TUD_CDC_DESCRIPTOR(itfnum, strid, 0x85, 64, 0x03, 0x84, mps)};
262252

263253
memcpy(_desc_cfg + _desc_cfg_len, desc_cdc, sizeof(desc_cdc));
264254
_desc_cfg_len += sizeof(desc_cdc);

src/arduino/Adafruit_USBD_Device.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,14 +119,15 @@ class Adafruit_USBD_Device {
119119
void task(void);
120120

121121
// physical disable/enable pull-up
122-
bool detach(void);
123-
bool attach(void);
122+
bool detach(void) { return tud_disconnect(); }
123+
bool attach(void) { return tud_connect(); }
124124

125125
//------------- status -------------//
126-
bool mounted(void);
127-
bool suspended(void);
128-
bool ready(void);
129-
bool remoteWakeup(void);
126+
bool mounted(void) { return tud_mounted(); }
127+
bool suspended(void) { return tud_suspended(); }
128+
bool ready(void) { return tud_ready(); }
129+
bool remoteWakeup(void) { return tud_remote_wakeup(); }
130+
tusb_speed_t getSpeed(void) { return tud_speed_get(); }
130131

131132
private:
132133
uint16_t const *descriptor_string_cb(uint8_t index, uint16_t langid);

src/arduino/msc/Adafruit_USBD_MSC.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@
2828

2929
#include "Adafruit_USBD_MSC.h"
3030

31-
#define BULK_PACKET_SIZE (TUD_OPT_HIGH_SPEED ? 512 : 64)
32-
3331
static Adafruit_USBD_MSC *_msc_dev = NULL;
3432

3533
Adafruit_USBD_MSC::Adafruit_USBD_MSC(void) {
@@ -51,8 +49,10 @@ uint16_t Adafruit_USBD_MSC::getInterfaceDescriptor(uint8_t itfnum_deprecated,
5149
uint8_t const ep_in = TinyUSBDevice.allocEndpoint(TUSB_DIR_IN);
5250
uint8_t const ep_out = TinyUSBDevice.allocEndpoint(TUSB_DIR_OUT);
5351

52+
uint16_t const mps =
53+
(TUD_OPT_HIGH_SPEED ? 512 : 64); // TODO actual link speed
5454
uint8_t const desc[] = {
55-
TUD_MSC_DESCRIPTOR(itfnum, _strid, ep_out, ep_in, BULK_PACKET_SIZE)};
55+
TUD_MSC_DESCRIPTOR(itfnum, _strid, ep_out, ep_in, mps)};
5656
uint16_t const len = sizeof(desc);
5757

5858
if (bufsize < len) {

src/arduino/ports/esp32/tusb_config_esp32.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,8 @@ extern "C" {
6868

6969
#if CONFIG_IDF_TARGET_ESP32P4
7070
#define CFG_TUD_MAX_SPEED OPT_MODE_HIGH_SPEED
71-
#define CFG_TUH_MAX_SPEED OPT_MODE_HIGH_SPEED
7271
#else
7372
#define CFG_TUD_MAX_SPEED OPT_MODE_FULL_SPEED
74-
#define CFG_TUH_MAX_SPEED OPT_MODE_FULL_SPEED
7573
#endif
7674

7775
#ifndef CFG_TUSB_OS
@@ -141,6 +139,7 @@ extern "C" {
141139
// Enable host stack with MAX3421E (host shield)
142140
#define CFG_TUH_ENABLED 1
143141
#define CFG_TUH_MAX3421 1
142+
#define CFG_TUH_MAX_SPEED OPT_MODE_FULL_SPEED
144143

145144
#ifndef CFG_TUH_MAX3421_ENDPOINT_TOTAL
146145
#define CFG_TUH_MAX3421_ENDPOINT_TOTAL (8 + 4 * (CFG_TUH_DEVICE_MAX - 1))

0 commit comments

Comments
 (0)