Skip to content

Commit 1f0da83

Browse files
committed
adding Adafruit TinyUSB support via menu selection
1 parent 21947eb commit 1f0da83

File tree

9 files changed

+72
-9
lines changed

9 files changed

+72
-9
lines changed

boards.txt

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ menu.LORAWAN_REGION=LoRaWan Region
1212
menu.LoRaWanDebugLevel=LoRaWan Debug Level
1313
menu.LoopCore=Arduino Runs On
1414
menu.EventsCore=Events Run On
15+
menu.USBStack=USB Stack
1516

1617
##############################################################
1718
### DO NOT PUT BOARDS ABOVE THE OFFICIAL ESPRESSIF BOARDS! ###
@@ -295,6 +296,11 @@ esp32s2.menu.DebugLevel.debug.build.code_debug=4
295296
esp32s2.menu.DebugLevel.verbose=Verbose
296297
esp32s2.menu.DebugLevel.verbose.build.code_debug=5
297298

299+
esp32s2.menu.USBStack.idf=ESP-IDF
300+
esp32s2.menu.USBStack.idf.build.usbstack_flags="-I{compiler.sdk.path}/include/arduino_tinyusb/tinyusb/src" "-I{compiler.sdk.path}/include/arduino_tinyusb/include"
301+
esp32s2.menu.USBStack.tinyusb=Adafruit TinyUSB
302+
esp32s2.menu.USBStack.tinyusb.build.usbstack_flags=-DUSE_TINYUSB "-I{runtime.platform.path}/libraries/Adafruit_TinyUSB_Arduino/src/arduino"
303+
298304
##############################################################
299305

300306
esp32.name=ESP32 Dev Module
@@ -960,6 +966,11 @@ feathers2.menu.DebugLevel.debug.build.code_debug=4
960966
feathers2.menu.DebugLevel.verbose=Verbose
961967
feathers2.menu.DebugLevel.verbose.build.code_debug=5
962968

969+
feathers2.menu.USBStack.idf=ESP-IDF
970+
feathers2.menu.USBStack.idf.build.usbstack_flags="-I{compiler.sdk.path}/include/arduino_tinyusb/tinyusb/src" "-I{compiler.sdk.path}/include/arduino_tinyusb/include"
971+
feathers2.menu.USBStack.tinyusb=Adafruit TinyUSB
972+
feathers2.menu.USBStack.tinyusb.build.usbstack_flags=-DUSE_TINYUSB "-I{runtime.platform.path}/libraries/Adafruit_TinyUSB_Arduino/src/arduino"
973+
963974
##############################################################
964975

965976
tinys2.name=UM TinyS2
@@ -1075,6 +1086,11 @@ tinys2.menu.DebugLevel.debug.build.code_debug=4
10751086
tinys2.menu.DebugLevel.verbose=Verbose
10761087
tinys2.menu.DebugLevel.verbose.build.code_debug=5
10771088

1089+
tinys2.menu.USBStack.idf=ESP-IDF
1090+
tinys2.menu.USBStack.idf.build.usbstack_flags="-I{compiler.sdk.path}/include/arduino_tinyusb/tinyusb/src" "-I{compiler.sdk.path}/include/arduino_tinyusb/include"
1091+
tinys2.menu.USBStack.tinyusb=Adafruit TinyUSB
1092+
tinys2.menu.USBStack.tinyusb.build.usbstack_flags=-DUSE_TINYUSB "-I{runtime.platform.path}/libraries/Adafruit_TinyUSB_Arduino/src/arduino"
1093+
10781094
##############################################################
10791095
S_ODI_Ultra.name=S.ODI Ultra v1
10801096

@@ -1261,6 +1277,11 @@ micros2.menu.DebugLevel.debug.build.code_debug=4
12611277
micros2.menu.DebugLevel.verbose=Verbose
12621278
micros2.menu.DebugLevel.verbose.build.code_debug=5
12631279

1280+
micros2.menu.USBStack.idf=ESP-IDF
1281+
micros2.menu.USBStack.idf.build.usbstack_flags="-I{compiler.sdk.path}/include/arduino_tinyusb/tinyusb/src" "-I{compiler.sdk.path}/include/arduino_tinyusb/include"
1282+
micros2.menu.USBStack.tinyusb=Adafruit TinyUSB
1283+
micros2.menu.USBStack.tinyusb.build.usbstack_flags=-DUSE_TINYUSB "-I{runtime.platform.path}/libraries/Adafruit_TinyUSB_Arduino/src/arduino"
1284+
12641285
##############################################################
12651286
magicbit.name=MagicBit
12661287

@@ -2140,6 +2161,11 @@ sparkfun_esp32s2_thing_plus.menu.DebugLevel.debug.build.code_debug=4
21402161
sparkfun_esp32s2_thing_plus.menu.DebugLevel.verbose=Verbose
21412162
sparkfun_esp32s2_thing_plus.menu.DebugLevel.verbose.build.code_debug=5
21422163

2164+
sparkfun_esp32s2_thing_plus.menu.USBStack.idf=ESP-IDF
2165+
sparkfun_esp32s2_thing_plus.menu.USBStack.idf.build.usbstack_flags="-I{compiler.sdk.path}/include/arduino_tinyusb/tinyusb/src" "-I{compiler.sdk.path}/include/arduino_tinyusb/include"
2166+
sparkfun_esp32s2_thing_plus.menu.USBStack.tinyusb=Adafruit TinyUSB
2167+
sparkfun_esp32s2_thing_plus.menu.USBStack.tinyusb.build.usbstack_flags=-DUSE_TINYUSB "-I{runtime.platform.path}/libraries/Adafruit_TinyUSB_Arduino/src/arduino"
2168+
21432169
##############################################################
21442170

21452171
sparkfun_lora_gateway_1-channel.name=SparkFun LoRa Gateway 1-Channel
@@ -3449,6 +3475,11 @@ adafruit_metro_esp32s2.menu.DebugLevel.debug.build.code_debug=4
34493475
adafruit_metro_esp32s2.menu.DebugLevel.verbose=Verbose
34503476
adafruit_metro_esp32s2.menu.DebugLevel.verbose.build.code_debug=5
34513477

3478+
adafruit_metro_esp32s2.menu.USBStack.idf=ESP-IDF
3479+
adafruit_metro_esp32s2.menu.USBStack.idf.build.usbstack_flags="-I{compiler.sdk.path}/include/arduino_tinyusb/tinyusb/src" "-I{compiler.sdk.path}/include/arduino_tinyusb/include"
3480+
adafruit_metro_esp32s2.menu.USBStack.tinyusb=Adafruit TinyUSB
3481+
adafruit_metro_esp32s2.menu.USBStack.tinyusb.build.usbstack_flags=-DUSE_TINYUSB "-I{runtime.platform.path}/libraries/Adafruit_TinyUSB_Arduino/src/arduino"
3482+
34523483

34533484
##############################################################
34543485

@@ -3602,6 +3633,11 @@ adafruit_magtag29_esp32s2.menu.DebugLevel.debug.build.code_debug=4
36023633
adafruit_magtag29_esp32s2.menu.DebugLevel.verbose=Verbose
36033634
adafruit_magtag29_esp32s2.menu.DebugLevel.verbose.build.code_debug=5
36043635

3636+
adafruit_magtag29_esp32s2.menu.USBStack.idf=ESP-IDF
3637+
adafruit_magtag29_esp32s2.menu.USBStack.idf.build.usbstack_flags="-I{compiler.sdk.path}/include/arduino_tinyusb/tinyusb/src" "-I{compiler.sdk.path}/include/arduino_tinyusb/include"
3638+
adafruit_magtag29_esp32s2.menu.USBStack.tinyusb=Adafruit TinyUSB
3639+
adafruit_magtag29_esp32s2.menu.USBStack.tinyusb.build.usbstack_flags=-DUSE_TINYUSB "-I{runtime.platform.path}/libraries/Adafruit_TinyUSB_Arduino/src/arduino"
3640+
36053641

36063642
##############################################################
36073643

@@ -3755,6 +3791,11 @@ adafruit_funhouse_esp32s2.menu.DebugLevel.debug.build.code_debug=4
37553791
adafruit_funhouse_esp32s2.menu.DebugLevel.verbose=Verbose
37563792
adafruit_funhouse_esp32s2.menu.DebugLevel.verbose.build.code_debug=5
37573793

3794+
adafruit_funhouse_esp32s2.menu.USBStack.idf=ESP-IDF
3795+
adafruit_funhouse_esp32s2.menu.USBStack.idf.build.usbstack_flags="-I{compiler.sdk.path}/include/arduino_tinyusb/tinyusb/src" "-I{compiler.sdk.path}/include/arduino_tinyusb/include"
3796+
adafruit_funhouse_esp32s2.menu.USBStack.tinyusb=Adafruit TinyUSB
3797+
adafruit_funhouse_esp32s2.menu.USBStack.tinyusb.build.usbstack_flags=-DUSE_TINYUSB "-I{runtime.platform.path}/libraries/Adafruit_TinyUSB_Arduino/src/arduino"
3798+
37583799

37593800
##############################################################
37603801

@@ -3908,6 +3949,11 @@ adafruit_feather_esp32s2_nopsram.menu.DebugLevel.debug.build.code_debug=4
39083949
adafruit_feather_esp32s2_nopsram.menu.DebugLevel.verbose=Verbose
39093950
adafruit_feather_esp32s2_nopsram.menu.DebugLevel.verbose.build.code_debug=5
39103951

3952+
adafruit_feather_esp32s2_nopsram.menu.USBStack.idf=ESP-IDF
3953+
adafruit_feather_esp32s2_nopsram.menu.USBStack.idf.build.usbstack_flags="-I{compiler.sdk.path}/include/arduino_tinyusb/tinyusb/src" "-I{compiler.sdk.path}/include/arduino_tinyusb/include"
3954+
adafruit_feather_esp32s2_nopsram.menu.USBStack.tinyusb=Adafruit TinyUSB
3955+
adafruit_feather_esp32s2_nopsram.menu.USBStack.tinyusb.build.usbstack_flags=-DUSE_TINYUSB "-I{runtime.platform.path}/libraries/Adafruit_TinyUSB_Arduino/src/arduino"
3956+
39113957

39123958
##############################################################
39133959

@@ -8851,4 +8897,4 @@ esp32-trueverit-iot-driver-mkii.menu.DebugLevel.debug.build.code_debug=4
88518897
esp32-trueverit-iot-driver-mkii.menu.DebugLevel.verbose=Verbose
88528898
esp32-trueverit-iot-driver-mkii.menu.DebugLevel.verbose.build.code_debug=5
88538899

8854-
##############################################################
8900+
##############################################################

cores/esp32/USB.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#include "esp32-hal.h"
1515
#include "esp32-hal-tinyusb.h"
1616
#include "USB.h"
17-
#if CONFIG_TINYUSB_ENABLED
17+
#if CONFIG_TINYUSB_ENABLED && !defined(USE_TINYUSB)
1818

1919
#ifndef USB_VID
2020
#define USB_VID USB_ESPRESSIF_VID

cores/esp32/USB.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,12 @@
1414
#pragma once
1515

1616
#include "sdkconfig.h"
17-
#if CONFIG_TINYUSB_ENABLED
17+
18+
#ifdef USE_TINYUSB // Adafruit TinyUSB is selected in menu
19+
20+
#include "Adafruit_TinyUSB_API.h"
21+
22+
#elif CONFIG_TINYUSB_ENABLED
1823

1924
#include "Arduino.h"
2025
#include "USBCDC.h"

cores/esp32/USBCDC.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#include "esp32-hal-tinyusb.h"
1616
#include "USB.h"
1717
#include "USBCDC.h"
18-
#if CONFIG_TINYUSB_ENABLED
18+
#if CONFIG_TINYUSB_ENABLED && !defined(USE_TINYUSB)
1919

2020
ESP_EVENT_DEFINE_BASE(ARDUINO_USB_CDC_EVENTS);
2121
esp_err_t arduino_usb_event_post(esp_event_base_t event_base, int32_t event_id, void *event_data, size_t event_data_size, TickType_t ticks_to_wait);

cores/esp32/USBCDC.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,13 @@
1717

1818
#include "Stream.h"
1919
#include "esp32-hal.h"
20-
#if CONFIG_TINYUSB_CDC_ENABLED
20+
21+
#ifdef USE_TINYUSB
22+
23+
// Adafruit TinyUSB is selected in menu
24+
#include "Adafruit_USBD_CDC.h"
25+
26+
#elif CONFIG_TINYUSB_CDC_ENABLED
2127

2228
#include "esp_event.h"
2329

cores/esp32/esp32-hal-tinyusb.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
#include "sdkconfig.h"
3-
#if CONFIG_TINYUSB_ENABLED
3+
#if CONFIG_TINYUSB_ENABLED && !defined(USE_TINYUSB)
44
#include <stdlib.h>
55
#include <stdbool.h>
66

cores/esp32/esp32-hal-tinyusb.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#include "esp32-hal.h"
1717

1818
#if CONFIG_IDF_TARGET_ESP32S2
19-
#if CONFIG_TINYUSB_ENABLED
19+
#if CONFIG_TINYUSB_ENABLED && !defined(USE_TINYUSB)
2020

2121
#ifdef __cplusplus
2222
extern "C" {

cores/esp32/main.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,12 @@ void loopTask(void *pvParameters)
4848
extern "C" void app_main()
4949
{
5050
#if ARDUINO_SERIAL_PORT //Serial used for USB CDC
51+
#ifdef USE_TINYUSB
52+
// Adafruit TinyUSB is selected in menu
53+
TinyUSB_Device_Init(0);
54+
#else
5155
USB.begin();
56+
#endif
5257
#endif
5358
loopTaskWDTEnabled = false;
5459
initArduino();

platform.txt

Lines changed: 3 additions & 2 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)