Skip to content

Commit 6f3ffce

Browse files
committed
Add board definition for ESP32-S3-USB-OTG
Includes support for SDMMC, LCD, LEDs, Buttons, Power and USB Switch
1 parent 0bbe7c0 commit 6f3ffce

File tree

5 files changed

+247
-15
lines changed

5 files changed

+247
-15
lines changed

boards.txt

+103-3
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ esp32s3.menu.EventsCore.0.build.event_core=-DARDUINO_EVENT_RUNNING_CORE=0
127127

128128
esp32s3.menu.USBMode.hwcdc=Hardware CDC and JTAG
129129
esp32s3.menu.USBMode.hwcdc.build.usb_mode=1
130-
esp32s3.menu.USBMode.default=USB-OTG
130+
esp32s3.menu.USBMode.default=USB-OTG (TinyUSB)
131131
esp32s3.menu.USBMode.default.build.usb_mode=0
132132

133133
esp32s3.menu.CDCOnBoot.default=Disabled
@@ -145,10 +145,10 @@ esp32s3.menu.DFUOnBoot.default.build.dfu_on_boot=0
145145
esp32s3.menu.DFUOnBoot.dfu=Enabled (Requires USB-OTG Mode)
146146
esp32s3.menu.DFUOnBoot.dfu.build.dfu_on_boot=1
147147

148-
esp32s3.menu.UploadMode.default=UART0
148+
esp32s3.menu.UploadMode.default=UART0 / Hardware CDC
149149
esp32s3.menu.UploadMode.default.upload.use_1200bps_touch=false
150150
esp32s3.menu.UploadMode.default.upload.wait_for_upload_port=false
151-
esp32s3.menu.UploadMode.cdc=Internal USB
151+
esp32s3.menu.UploadMode.cdc=USB-OTG CDC (TinyUSB)
152152
esp32s3.menu.UploadMode.cdc.upload.use_1200bps_touch=true
153153
esp32s3.menu.UploadMode.cdc.upload.wait_for_upload_port=true
154154

@@ -1121,6 +1121,106 @@ esp32s3box.menu.DebugLevel.verbose.build.code_debug=5
11211121

11221122
##############################################################
11231123

1124+
esp32s3usbotg.name=ESP32-S3-USB-OTG
1125+
esp32s3usbotg.vid.0=0x303a
1126+
esp32s3usbotg.pid.0=0x1001
1127+
1128+
esp32s3usbotg.upload.tool=esptool_py
1129+
esp32s3usbotg.upload.maximum_size=1310720
1130+
esp32s3usbotg.upload.maximum_data_size=327680
1131+
esp32s3usbotg.upload.speed=921600
1132+
esp32s3usbotg.upload.flags=
1133+
esp32s3usbotg.upload.extra_flags=
1134+
esp32s3usbotg.upload.use_1200bps_touch=false
1135+
esp32s3usbotg.upload.wait_for_upload_port=false
1136+
1137+
esp32s3usbotg.serial.disableDTR=false
1138+
esp32s3usbotg.serial.disableRTS=false
1139+
1140+
esp32s3usbotg.build.tarch=xtensa
1141+
esp32s3usbotg.build.bootloader_addr=0x0
1142+
esp32s3usbotg.build.target=esp32s3
1143+
esp32s3usbotg.build.mcu=esp32s3
1144+
esp32s3usbotg.build.core=esp32
1145+
esp32s3usbotg.build.variant=esp32s3usbotg
1146+
esp32s3usbotg.build.board=ESP32_S3_USB_OTG
1147+
1148+
esp32s3usbotg.build.usb_mode=0
1149+
esp32s3usbotg.build.cdc_on_boot=0
1150+
esp32s3usbotg.build.msc_on_boot=0
1151+
esp32s3usbotg.build.dfu_on_boot=0
1152+
esp32s3usbotg.build.f_cpu=240000000L
1153+
esp32s3usbotg.build.flash_size=8MB
1154+
esp32s3usbotg.build.flash_freq=80m
1155+
esp32s3usbotg.build.flash_mode=dio
1156+
esp32s3usbotg.build.boot=qio
1157+
esp32s3usbotg.build.partitions=default
1158+
esp32s3usbotg.build.defines=
1159+
esp32s3usbotg.build.memory_type=qspi_qspi
1160+
esp32s3usbotg.build.loop_core=-DARDUINO_RUNNING_CORE=1
1161+
esp32s3usbotg.build.event_core=-DARDUINO_EVENT_RUNNING_CORE=1
1162+
1163+
esp32s3usbotg.menu.USBMode.default=USB-OTG
1164+
esp32s3usbotg.menu.USBMode.default.build.usb_mode=0
1165+
esp32s3usbotg.menu.USBMode.default.build.cdc_on_boot=0
1166+
esp32s3usbotg.menu.USBMode.hwcdc=Hardware CDC and JTAG
1167+
esp32s3usbotg.menu.USBMode.hwcdc.build.usb_mode=1
1168+
esp32s3usbotg.menu.USBMode.hwcdc.build.cdc_on_boot=1
1169+
1170+
esp32s3usbotg.menu.UploadMode.default=UART0 / Hardware CDC
1171+
esp32s3usbotg.menu.UploadMode.default.upload.use_1200bps_touch=false
1172+
esp32s3usbotg.menu.UploadMode.default.upload.wait_for_upload_port=false
1173+
esp32s3usbotg.menu.UploadMode.cdc=USB-OTG CDC (TinyUSB)
1174+
esp32s3usbotg.menu.UploadMode.cdc.upload.use_1200bps_touch=true
1175+
esp32s3usbotg.menu.UploadMode.cdc.upload.wait_for_upload_port=true
1176+
1177+
esp32s3usbotg.menu.PartitionScheme.default=Default 4MB with spiffs (1.2MB APP/1.5MB SPIFFS)
1178+
esp32s3usbotg.menu.PartitionScheme.default.build.partitions=default
1179+
esp32s3usbotg.menu.PartitionScheme.defaultffat=Default 4MB with ffat (1.2MB APP/1.5MB FATFS)
1180+
esp32s3usbotg.menu.PartitionScheme.defaultffat.build.partitions=default_ffat
1181+
esp32s3usbotg.menu.PartitionScheme.default_8MB=8M Flash (3MB APP/1.5MB FAT)
1182+
esp32s3usbotg.menu.PartitionScheme.default_8MB.build.partitions=default_8MB
1183+
esp32s3usbotg.menu.PartitionScheme.default_8MB.upload.maximum_size=3342336
1184+
esp32s3usbotg.menu.PartitionScheme.no_ota=No OTA (2MB APP/2MB SPIFFS)
1185+
esp32s3usbotg.menu.PartitionScheme.no_ota.build.partitions=no_ota
1186+
esp32s3usbotg.menu.PartitionScheme.no_ota.upload.maximum_size=2097152
1187+
esp32s3usbotg.menu.PartitionScheme.noota_3g=No OTA (1MB APP/3MB SPIFFS)
1188+
esp32s3usbotg.menu.PartitionScheme.noota_3g.build.partitions=noota_3g
1189+
esp32s3usbotg.menu.PartitionScheme.noota_3g.upload.maximum_size=1048576
1190+
esp32s3usbotg.menu.PartitionScheme.noota_ffat=No OTA (2MB APP/2MB FATFS)
1191+
esp32s3usbotg.menu.PartitionScheme.noota_ffat.build.partitions=noota_ffat
1192+
esp32s3usbotg.menu.PartitionScheme.noota_ffat.upload.maximum_size=2097152
1193+
esp32s3usbotg.menu.PartitionScheme.noota_3gffat=No OTA (1MB APP/3MB FATFS)
1194+
esp32s3usbotg.menu.PartitionScheme.noota_3gffat.build.partitions=noota_3gffat
1195+
esp32s3usbotg.menu.PartitionScheme.noota_3gffat.upload.maximum_size=1048576
1196+
esp32s3usbotg.menu.PartitionScheme.huge_app=Huge APP (3MB No OTA/1MB SPIFFS)
1197+
esp32s3usbotg.menu.PartitionScheme.huge_app.build.partitions=huge_app
1198+
esp32s3usbotg.menu.PartitionScheme.huge_app.upload.maximum_size=3145728
1199+
esp32s3usbotg.menu.PartitionScheme.min_spiffs=Minimal SPIFFS (1.9MB APP with OTA/190KB SPIFFS)
1200+
esp32s3usbotg.menu.PartitionScheme.min_spiffs.build.partitions=min_spiffs
1201+
esp32s3usbotg.menu.PartitionScheme.min_spiffs.upload.maximum_size=1966080
1202+
esp32s3usbotg.menu.PartitionScheme.fatflash=16M Flash (2MB APP/12.5MB FAT)
1203+
esp32s3usbotg.menu.PartitionScheme.fatflash.build.partitions=ffat
1204+
esp32s3usbotg.menu.PartitionScheme.fatflash.upload.maximum_size=2097152
1205+
esp32s3usbotg.menu.PartitionScheme.app3M_fat9M_16MB=16M Flash (3MB APP/9MB FATFS)
1206+
esp32s3usbotg.menu.PartitionScheme.app3M_fat9M_16MB.build.partitions=app3M_fat9M_16MB
1207+
esp32s3usbotg.menu.PartitionScheme.app3M_fat9M_16MB.upload.maximum_size=3145728
1208+
1209+
esp32s3usbotg.menu.DebugLevel.none=None
1210+
esp32s3usbotg.menu.DebugLevel.none.build.code_debug=0
1211+
esp32s3usbotg.menu.DebugLevel.error=Error
1212+
esp32s3usbotg.menu.DebugLevel.error.build.code_debug=1
1213+
esp32s3usbotg.menu.DebugLevel.warn=Warn
1214+
esp32s3usbotg.menu.DebugLevel.warn.build.code_debug=2
1215+
esp32s3usbotg.menu.DebugLevel.info=Info
1216+
esp32s3usbotg.menu.DebugLevel.info.build.code_debug=3
1217+
esp32s3usbotg.menu.DebugLevel.debug=Debug
1218+
esp32s3usbotg.menu.DebugLevel.debug.build.code_debug=4
1219+
esp32s3usbotg.menu.DebugLevel.verbose=Verbose
1220+
esp32s3usbotg.menu.DebugLevel.verbose.build.code_debug=5
1221+
1222+
##############################################################
1223+
11241224
esp32s3camlcd.name=ESP32S3 CAM LCD
11251225
esp32s3camlcd.vid.0=0x303a
11261226
esp32s3camlcd.pid.0=0x1001

variants/esp32s3/pins_arduino.h

-3
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,4 @@ static const uint8_t T12 = 12;
6161
static const uint8_t T13 = 13;
6262
static const uint8_t T14 = 14;
6363

64-
static const uint8_t DAC1 = 17;
65-
static const uint8_t DAC2 = 18;
66-
6764
#endif /* Pins_Arduino_h */

variants/esp32s3box/pins_arduino.h

-9
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,6 @@ static const uint8_t T14 = 14;
6262
#define I2S_SDIN 16
6363
#define I2S_DOUT 15
6464

65-
#define BOARD_HAS_SDMMC
66-
#define SDMMC_CLK 13
67-
#define SDMMC_CMD 11
68-
#define SDMMC_D0 14
69-
#define SDMMC_D1 12
70-
#define SDMMC_D2 10
71-
#define SDMMC_D3 9
72-
#define BOARD_MAX_SDMMC_FREQ SDMMC_FREQ_DEFAULT
73-
7465
#define PA_PIN 46 //Audio Amp Power
7566
#define MUTE_PIN 1 //MUTE Button
7667
#define TS_IRQ 3 //Touch Screen IRQ

variants/esp32s3usbotg/pins_arduino.h

+98
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
#ifndef Pins_Arduino_h
2+
#define Pins_Arduino_h
3+
4+
#include <stdint.h>
5+
6+
#define USB_VID 0x303a
7+
#define USB_PID 0x1001
8+
9+
#define EXTERNAL_NUM_INTERRUPTS 46
10+
#define NUM_DIGITAL_PINS 48
11+
#define NUM_ANALOG_INPUTS 20
12+
13+
#define analogInputToDigitalPin(p) (((p)<20)?(analogChannelToDigitalPin(p)):-1)
14+
#define digitalPinToInterrupt(p) (((p)<48)?(p):-1)
15+
#define digitalPinHasPWM(p) (p < 46)
16+
17+
static const uint8_t TX = 43;
18+
static const uint8_t RX = 44;
19+
20+
static const uint8_t SDA = 45;
21+
static const uint8_t SCL = 46;
22+
23+
static const uint8_t SS = 34;
24+
static const uint8_t MOSI = 35;
25+
static const uint8_t MISO = 37;
26+
static const uint8_t SCK = 36;
27+
28+
static const uint8_t A0 = 1;
29+
static const uint8_t A1 = 2;
30+
static const uint8_t A2 = 3;
31+
32+
static const uint8_t T3 = 3;
33+
34+
// SDCARD Slot
35+
#define BOARD_HAS_SDMMC
36+
#define SDMMC_D2 33 // SDMMC Data2
37+
#define SDMMC_D3 34 // SDMMC Data3 / SPI CS
38+
#define SDMMC_CMD 35 // SDMMC CMD / SPI MOSI
39+
#define SDMMC_CLK 36 // SDMMC CLK / SPI SCK
40+
#define SDMMC_D0 37 // SDMMC Data0 / SPI MISO
41+
#define SDMMC_D1 38 // SDMMC Data1
42+
#define BOARD_MAX_SDMMC_FREQ SDMMC_FREQ_DEFAULT
43+
44+
// 240x240 LCD
45+
#define BOARD_HAS_SPI_LCD
46+
#define LCD_MODEL ST7789
47+
#define LCD_WIDTH 240
48+
#define LCD_HEIGHT 240 // *RAM height is actually 320!
49+
#define LCD_MISO -1 // LCD Does not use MISO.
50+
#define LCD_DC 4 // Used to switch data and command status.
51+
#define LCD_CS 5 // used to enable LCD, low level to enable.
52+
#define LCD_CLK 6 // LCD SPI Clock.
53+
#define LCD_MOSI 7 // LCD SPI MOSI.
54+
#define LCD_RST 8 // used to reset LCD, low level to reset.
55+
#define LCD_BL 9 // LCD backlight control.
56+
57+
// Buttons
58+
#define BUTTON_OK 0 // OK button, low level when pressed.
59+
#define BUTTON_UP 10 // UP button, low level when pressed.
60+
#define BUTTON_DOWN 11 // Down button, low level when pressed.
61+
#define BUTTON_MENU 14 // Menu button, low level when pressed.
62+
63+
// LEDs
64+
#define LED_GREEN 15 // the light is lit when set high level.
65+
#define LED_YELLOW 16 // the light is lit when set high level.
66+
67+
// Board Controls
68+
#define DEV_VBUS_EN 12 // High level to enable DEV_VBUS power supply.
69+
#define BOOST_EN 13 // High level to enable Battery Boost circuit.
70+
#define LIMIT_EN 17 // Enable USB_HOST current limiting IC, high level enable.
71+
#define USB_HOST_EN 18 // Used to switch the USB interface. When high level, the USB_HOST interface is enabled. When low level, the USB_DEV interface is enabled.
72+
73+
// Board Sensors
74+
#define OVER_CURRENT 21 // Current overrun signal, high level means overrun.
75+
#define HOST_VOLTS 1 // USB_DEV voltage monitoring, ADC1 channel 0. actual_v = value_v * 3.7
76+
#define BAT_VOLTS 2 // Battery voltage monitoring, ADC1 channel 1. actual_v = value_v * 2
77+
78+
// USB Port
79+
#define USB_DN 19 // USB D-
80+
#define USB_DP 20 // USB D+
81+
82+
// Bottom header
83+
#define MTCK 39
84+
#define MTDO 40
85+
#define MTDI 41
86+
#define MTMS 42
87+
// #define FREE_6 3 // Idle, can be customized.
88+
// #define FREE_4 26 // Idle, can be customized.
89+
// #define FREE_1 45 // Idle, can be customized.
90+
// #define FREE_2 46 // Idle, can be customized.
91+
// #define FREE_5 47 // Idle, can be customized.
92+
// #define FREE_3 48 // Idle, can be customized.
93+
94+
typedef enum { USB_HOST_POWER_OFF, USB_HOST_POWER_VBUS, USB_HOST_POWER_BAT } UsbHostPower_t;
95+
void usbHostPower(UsbHostPower_t mode);
96+
void usbHostEnable(bool enable);
97+
98+
#endif /* Pins_Arduino_h */

variants/esp32s3usbotg/variant.cpp

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#include "Arduino.h"
2+
3+
void usbHostPower(UsbHostPower_t mode){
4+
static UsbHostPower_t m = USB_HOST_POWER_OFF;
5+
if(m == mode){
6+
return;
7+
}
8+
if(mode == USB_HOST_POWER_OFF){
9+
digitalWrite(LIMIT_EN, LOW);
10+
if(m == USB_HOST_POWER_VBUS){
11+
digitalWrite(DEV_VBUS_EN, LOW);
12+
} else if(m == USB_HOST_POWER_BAT){
13+
digitalWrite(BOOST_EN, LOW);
14+
}
15+
} else if(mode == USB_HOST_POWER_VBUS){
16+
if(m == USB_HOST_POWER_BAT){
17+
digitalWrite(BOOST_EN, LOW);
18+
}
19+
digitalWrite(DEV_VBUS_EN, HIGH);
20+
} else if(mode == USB_HOST_POWER_BAT){
21+
if(m == USB_HOST_POWER_VBUS){
22+
digitalWrite(DEV_VBUS_EN, LOW);
23+
}
24+
digitalWrite(BOOST_EN, HIGH);
25+
}
26+
if(mode != USB_HOST_POWER_OFF){
27+
digitalWrite(LIMIT_EN, HIGH);
28+
}
29+
m = mode;
30+
}
31+
32+
void usbHostEnable(bool enable){
33+
digitalWrite(USB_HOST_EN, enable);
34+
}
35+
36+
extern "C" void initVariant(void){
37+
// Route USB to Device Side
38+
pinMode(BOOST_EN, OUTPUT); digitalWrite(BOOST_EN, LOW);
39+
pinMode(LIMIT_EN, OUTPUT); digitalWrite(LIMIT_EN, LOW);
40+
pinMode(DEV_VBUS_EN, OUTPUT); digitalWrite(DEV_VBUS_EN, LOW);
41+
pinMode(USB_HOST_EN, OUTPUT); digitalWrite(USB_HOST_EN, LOW);
42+
43+
// Turn Off LCD
44+
pinMode(LCD_RST, OUTPUT); digitalWrite(LCD_RST, LOW);
45+
pinMode(LCD_BL, OUTPUT); digitalWrite(LCD_BL, LOW);
46+
}

0 commit comments

Comments
 (0)