Skip to content

Commit 7438327

Browse files
authored
Merge pull request #126 from adafruit/support-esp32-2.0
Add support for ESP32-S2 arduino core version 2.0.0
2 parents 82fafbc + 53e5625 commit 7438327

Some content is hidden

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

46 files changed

+648
-268
lines changed

.github/workflows/githubci.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ jobs:
99
fail-fast: false
1010
matrix:
1111
arduino-platform:
12+
# ESP32S2
13+
- 'funhouse'
14+
- 'magtag'
15+
- 'metroesp32s2'
1216
# nRF52
1317
- 'cpb'
1418
- 'nrf52840'

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,14 @@ There are 2 type of supported cores: with and without built-in support for TinyU
2121

2222
### Cores with built-in support
2323

24-
Following core has Tinyusb as either the primary usb stack or selectable via menu `Tools->USB Stack`. You only need to include `<Adafruit_TinyUSB.h>` in your sketch to use.
24+
Following core has TinyUSB as either the primary usb stack or selectable via menu `Tools->USB Stack`. You only need to include `<Adafruit_TinyUSB.h>` in your sketch to use.
2525

26-
- [Adafruit_nRF52_Arduino](https://github.com/adafruit/Adafruit_nRF52_Arduino)
26+
- [adafruit/Adafruit_nRF52_Arduino](https://github.com/adafruit/Adafruit_nRF52_Arduino)
2727
- [adafruit/ArduinoCore-samd](https://github.com/adafruit/ArduinoCore-samd)
2828
- [earlephilhower/arduino-pico](https://github.com/earlephilhower/arduino-pico)
29+
- [espressif/arduino-esp32](https://github.com/espressif/arduino-esp32)
30+
31+
ESP32 port relies on Espressif's [esp32-hal-tinyusb.c](https://github.com/espressif/arduino-esp32/blob/master/cores/esp32/esp32-hal-tinyusb.c) for building usb descriptors which 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 for this port.
2932

3033
### Cores without built-in support
3134

changelog.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Adafruit TinyUSB Arduino Library Changelog
22

3+
## 1.5.0 - 2021.09.29
4+
5+
- Add support for ESP32-S2 core version 2.0.0
6+
- ESP32 port relies on Espressif's [esp32-hal-tinyusb.c](https://github.com/espressif/arduino-esp32/blob/master/cores/esp32/esp32-hal-tinyusb.c) for building usb descriptors which 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 for this port.
7+
8+
- Add new constructor for Adafruit_USBD_HID(desc_report, len, protocol, interval_ms, has_out_endpoint)
9+
310
## 1.4.4 - 2021.08.18
411

512
- Update tinyusb stack

examples/CDC/cdc_multi/.magtag.test.skip

Whitespace-only changes.

examples/CDC/cdc_multi/.metroesp32s2.test.skip

Whitespace-only changes.

examples/CDC/no_serial/.funhouse.test.skip

Whitespace-only changes.

examples/CDC/no_serial/.magtag.test.skip

Whitespace-only changes.

examples/CDC/no_serial/.metroesp32s2.test.skip

Whitespace-only changes.

examples/Composite/mouse_external_flash/mouse_external_flash.ino

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919
#include "Adafruit_SPIFlash.h"
2020
#include "Adafruit_TinyUSB.h"
2121

22+
//--------------------------------------------------------------------+
23+
// MSC External Flash Config
24+
//--------------------------------------------------------------------+
25+
2226
// Uncomment to run example with FRAM
2327
// #define FRAM_CS A5
2428
// #define FRAM_SPI SPI
@@ -51,26 +55,39 @@ Adafruit_SPIFlash flash(&flashTransport);
5155

5256
Adafruit_USBD_MSC usb_msc;
5357

58+
//--------------------------------------------------------------------+
59+
// HID Config
60+
//--------------------------------------------------------------------+
61+
5462
// HID report descriptor using TinyUSB's template
5563
// Single Report (no ID) descriptor
5664
uint8_t const desc_hid_report[] =
5765
{
5866
TUD_HID_REPORT_DESC_MOUSE()
5967
};
6068

61-
Adafruit_USBD_HID usb_hid;
69+
// USB HID object. For ESP32 these values cannot be changed after this declaration
70+
// desc report, desc len, protocol, interval, use out endpoint
71+
Adafruit_USBD_HID usb_hid(desc_hid_report, sizeof(desc_hid_report), HID_ITF_PROTOCOL_NONE, 2, false);
6272

63-
#if defined ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS
73+
#if defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) || defined(ARDUINO_NRF52840_CIRCUITPLAY)
6474
const int pin = 4; // Left Button
6575
bool activeState = true;
66-
#elif defined ARDUINO_NRF52840_FEATHER
67-
const int pin = 7; // UserSw
76+
77+
#elif defined(ARDUINO_FUNHOUSE_ESP32S2)
78+
const int pin = BUTTON_DOWN;
79+
bool activeState = true;
80+
81+
#elif defined PIN_BUTTON1
82+
const int pin = PIN_BUTTON1;
6883
bool activeState = false;
84+
6985
#else
7086
const int pin = 12;
7187
bool activeState = false;
7288
#endif
7389

90+
7491
// the setup function runs once when you press reset or power the board
7592
void setup()
7693
{
@@ -92,11 +109,12 @@ void setup()
92109

93110
usb_msc.begin();
94111

95-
96112
// Set up button
97113
pinMode(pin, activeState ? INPUT_PULLDOWN : INPUT_PULLUP);
98114

99-
usb_hid.setReportDescriptor(desc_hid_report, sizeof(desc_hid_report));
115+
// Notes: following commented-out functions has no affect on ESP32
116+
// usb_hid.setReportDescriptor(desc_hid_report, sizeof(desc_hid_report));
117+
100118
usb_hid.begin();
101119

102120
Serial.begin(115200);

0 commit comments

Comments
 (0)