Initial support for ESP32S3 with support for 38 configurable GPIOs

This commit is contained in:
Stephan Hadinger 2022-02-01 12:05:56 +01:00
parent f8b402f198
commit 8f8f0aba42
8 changed files with 161 additions and 15 deletions

View File

@ -20,6 +20,7 @@ All notable changes to this project will be documented in this file.
- Support for MQ analog sensor for air quality by Francesco Adriani (#14581)
- Command ``SetOption134 1`` to disable PWM auto-phasing for lights by default (new behavior) (#14590)
- Increase PWM channels to 16 (Esp32 only)
- Initial support for ESP32S3 with support for 38 configurable GPIOs
### Changed
- BME68x-Sensor-API library from v3.5.9 to v4.4.7

View File

@ -100,6 +100,8 @@
#define OTA_URL "http://ota.tasmota.com/tasmota32/release/tasmota32c3.bin" // [OtaUrl]
#elif defined(CONFIG_IDF_TARGET_ESP32S2)
#define OTA_URL "no official version (yet)" // [OtaUrl]
#elif defined(CONFIG_IDF_TARGET_ESP32S3)
#define OTA_URL "no official version (yet)" // [OtaUrl]
#elif defined(CORE32SOLO1)
#define OTA_URL "http://ota.tasmota.com/tasmota32/release/tasmota32solo1.bin" // [OtaUrl]
#else

View File

@ -527,6 +527,31 @@ typedef struct {
uint8_t ex_switchmode[8]; // 3A4 - Free since 9.2.0.6
#ifdef CONFIG_IDF_TARGET_ESP32S3
// ------------------------------------
// Remapping of the section for ESP32S3
// ------------------------------------
myio my_gp; // 3AC (+x62) 2x49 bytes (ESP32-S3)
uint8_t eth_type; // 40E
uint8_t eth_clk_mode; // 40F
mytmplt user_template; // 410 (9x4E) 2x39 bytes (ESP32-S3)
uint8_t eth_address; // 45E
uint8_t module; // 45F
WebCamCfg webcam_config; // 460
uint8_t ws_width[3]; // 464
char serial_delimiter; // 467
uint8_t seriallog_level; // 468
uint8_t sleep; // 469
uint16_t domoticz_switch_idx[MAX_DOMOTICZ_IDX]; // 46A (+8)
uint16_t domoticz_sensor_idx[MAX_DOMOTICZ_SNS_IDX]; // 472 (+x18)
uint8_t ws_color[4][3]; // 48A (+xC)
// 496
// ----------------------------------------
// End of remapping, next is all other CPUs
// ----------------------------------------
#else
myio my_gp; // 3AC 2x18 bytes (ESP8266) / 2x40 bytes (ESP32) / 2x22 bytes (ESP32-C3) / 2x47 bytes (ESP32-S2)
#ifdef ESP8266
uint16_t gpio16_converted; // 3D0
@ -545,6 +570,7 @@ typedef struct {
#ifdef CONFIG_IDF_TARGET_ESP32C3
uint8_t free_esp32c3_42A[28]; // 42A - Due to smaller mytmplt
#endif // CONFIG_IDF_TARGET_ESP32C3
uint8_t eth_type; // 446
uint8_t eth_clk_mode; // 447
@ -556,6 +582,7 @@ typedef struct {
WebCamCfg webcam_config; // 44C
uint8_t eth_address; // 450
#endif // ESP32
char serial_delimiter; // 451
uint8_t seriallog_level; // 452
uint8_t sleep; // 453
@ -576,7 +603,12 @@ typedef struct {
#endif
#endif // ESP32
uint8_t ex_my_adc0; // 495 Free since 9.0.0.1
uint8_t ex_my_adc0; // 495 Free since 9.0.0.1 - Do not use anymore because of ESP32S3
// ----------------------------------------
// End of remapping for non-ESP32S3
// ----------------------------------------
#endif // ESP32S3
uint16_t light_pixels; // 496
uint8_t light_color[LST_MAX]; // 498 LST_MAX = 5

View File

@ -1465,7 +1465,7 @@ void TemplateGpios(myio *gp)
for (uint32_t i = 0; i < nitems(Settings->user_template.gp.io); i++) {
#if defined(ESP32) && CONFIG_IDF_TARGET_ESP32C3
dest[i] = src[i];
#elif defined(CONFIG_IDF_TARGET_ESP32S2)
#elif defined(CONFIG_IDF_TARGET_ESP32S2) || defined(CONFIG_IDF_TARGET_ESP32S3)
if (22 == i) { j = 33; } // skip 22-32
dest[j] = src[i];
j++;
@ -1534,7 +1534,7 @@ bool FlashPin(uint32_t pin)
{
#if defined(ESP32) && CONFIG_IDF_TARGET_ESP32C3
return (pin > 10) && (pin < 18); // ESP32C3 has GPIOs 11-17 reserved for Flash
#elif defined(CONFIG_IDF_TARGET_ESP32S2)
#elif defined(CONFIG_IDF_TARGET_ESP32S2) || defined(CONFIG_IDF_TARGET_ESP32S3)
return (pin > 21) && (pin < 33); // ESP32S2 skip 22-32
#elif defined(CONFIG_IDF_TARGET_ESP32)
return (pin >= 28) && (pin <= 31); // ESP21 skip 28-31
@ -1549,6 +1549,8 @@ bool RedPin(uint32_t pin) // pin may be dangerous to change, display in RED in t
return false; // no red pin on ESP32C3
#elif defined(CONFIG_IDF_TARGET_ESP32S2)
return false; // no red pin on ESP32S3
#elif defined(CONFIG_IDF_TARGET_ESP32S3)
return (33<=pin) && (37>=pin); // ESP32S3: GPIOs 33..37 are usually used for PSRAM
#elif defined(CONFIG_IDF_TARGET_ESP32) // red pins are 6-11 for original ESP32, other models like PICO are not impacted if flash pins are condfigured
// PICO can also have 16/17/18/23 not available
return ((6<=pin) && (11>=pin)) || (16==pin) || (17==pin); // TODO adapt depending on the exact type of ESP32

View File

@ -535,6 +535,8 @@ float CpuTemperature(void) {
t = (float)temperatureRead(); // In Celsius
}
return t;
#else
return NAN;
#endif
#endif
}
@ -582,6 +584,8 @@ float CpuTemperature(void) {
#endif
*/
// #include "esp_chip_info.h"
String GetDeviceHardware(void) {
// https://www.espressif.com/en/products/socs
@ -589,10 +593,12 @@ String GetDeviceHardware(void) {
Source: esp-idf esp_system.h and esptool
typedef enum {
CHIP_ESP32 = 1, //!< ESP32
CHIP_ESP32S2 = 2, //!< ESP32-S2
CHIP_ESP32S3 = 4, //!< ESP32-S3
CHIP_ESP32C3 = 5, //!< ESP32-C3
CHIP_ESP32 = 1, //!< ESP32
CHIP_ESP32S2 = 2, //!< ESP32-S2
CHIP_ESP32S3 = 9, //!< ESP32-S3
CHIP_ESP32C3 = 5, //!< ESP32-C3
CHIP_ESP32H2 = 6, //!< ESP32-H2
CHIP_ESP32C2 = 12, //!< ESP32-C2
} esp_chip_model_t;
// Chip feature flags, used in esp_chip_info_t
@ -600,6 +606,9 @@ typedef enum {
#define CHIP_FEATURE_WIFI_BGN BIT(1) //!< Chip has 2.4GHz WiFi
#define CHIP_FEATURE_BLE BIT(4) //!< Chip has Bluetooth LE
#define CHIP_FEATURE_BT BIT(5) //!< Chip has Bluetooth Classic
#define CHIP_FEATURE_IEEE802154 BIT(6) //!< Chip has IEEE 802.15.4
#define CHIP_FEATURE_EMB_PSRAM BIT(7) //!< Chip has embedded psram
// The structure represents information about the chip
typedef struct {
@ -681,7 +690,10 @@ typedef struct {
#endif // CONFIG_IDF_TARGET_ESP32S2
return F("ESP32-S2");
}
else if (4 == chip_model) { // ESP32-S3
else if (9 == chip_model) { // ESP32-S3
#ifdef CONFIG_IDF_TARGET_ESP32S3
// no variants for now
#endif // CONFIG_IDF_TARGET_ESP32S3
return F("ESP32-S3"); // Max 240MHz, Dual core, QFN 7*7, ESP32-S3-WROOM-1, ESP32-S3-DevKitC-1
}
else if (5 == chip_model) { // ESP32-C3

View File

@ -1098,6 +1098,22 @@ const char PINS_WEMOS[] PROGMEM = "AOAOAOAOAOAOIOIOIOIOIOFLFLFLFLFLFLFLIOIORXTX"
// 0 1 2 3 4 5 6 7 8 910111213141516171819202122232425262728293031323334353637383940414243444546
const char PINS_WEMOS[] PROGMEM = "IOAOAOAOAOAOAOAOAOAOAOAOAOAOAOAOAOAOAOAOAOIO--------FLFLFLFLFLFLFLIOIOIOIOIOIOIOIOIOIOIOIOIOI ";
#elif defined(CONFIG_IDF_TARGET_ESP32S3)
/* ****************************************
* ESP32S3
* GPIOs 0..21 + 33..48
* - 22..25 are not used
* - 26..32 are used for SPI Flash
* - 33..37 are used by PSRAM
* ****************************************/
#define MAX_GPIO_PIN 49 // Number of supported GPIO, 0..48
#define MIN_FLASH_PINS 11 // Number of flash chip pins unusable for configuration (22-25 don't exist, 26-32 for SPI)
#define MAX_USER_PINS 38 // MAX_GPIO_PIN - MIN_FLASH_PINS
#define WEMOS_MODULE 0 // Wemos module
// 0 1 2 3 4 5 6 7 8 9101112131415161718192021222324252627282930313233343536373839404142434445464748
const char PINS_WEMOS[] PROGMEM = "IOAOAOAOAOAOAOAOAOAOAOAOAOAOAOAOAOAOAOAOAOIO--------FLFLFLFLFLFLFLIOIOIOIOIOIOIOIOIOIOIOIOIOIOIOIO";
#else // not CONFIG_IDF_TARGET_ESP32C3 nor CONFIG_IDF_TARGET_ESP32S2 - ESP32
/* ****************************************
@ -1138,11 +1154,11 @@ const char PINS_WEMOS[] PROGMEM = "IOTXIORXIOIOFLFLFLFLFLFLIOIOIOIOIOIOIOIOIOIOI
typedef struct MYIO {
uint16_t io[MAX_GPIO_PIN];
} myio; // ESP8266: 18*2 = 36 bytes / ESP32: 40*2 = 80 bytes / ESP32-C3: 22*2 = 44 bytes / ESP32-S2: 47*2 = 94 bytes
} myio; // ESP8266: 18*2 = 36 bytes / ESP32: 40*2 = 80 bytes / ESP32-C3: 22*2 = 44 bytes / ESP32-S2: 47*2 = 94 bytes / ESP32-S3: 49*2 = 98 bytes
typedef struct MYCFGIO {
uint16_t io[MAX_USER_PINS];
} mycfgio; // ESP8266: 14*2 = 28 bytes / ESP32: 36*2 = 72 bytes / ESP32-C3: 22*2 = 44 bytes / ESP32-S2: 36*2 = 72 bytes
} mycfgio; // ESP8266: 14*2 = 28 bytes / ESP32: 36*2 = 72 bytes / ESP32-C3: 22*2 = 44 bytes / ESP32-S2: 36*2 = 72 bytes / ESP32-S3: 33*2 = 66 bytes
#define GPIO_FLAG_USED 0 // Currently no flags used
@ -2725,6 +2741,89 @@ const mytmplt kModules[] PROGMEM = {
Known templates
\*********************************************************************************************/
#elif defined(CONFIG_IDF_TARGET_ESP32S3)
/********************************************************************************************\
* ESP32-S3 Module templates
\********************************************************************************************/
#define USER_MODULE 255
// Supported hardware modules
enum SupportedModulesESP32S3 {
WEMOS,
MAXMODULE };
// Default module settings
const uint8_t kModuleNiceList[] PROGMEM = {
WEMOS,
};
// !!! Update this list in the same order as kModuleNiceList !!!
const char kModuleNames[] PROGMEM =
"ESP32S3|"
;
// !!! Update this list in the same order as SupportedModulesESP32S2 !!!
const mytmplt kModules[] PROGMEM = {
{ // Generic ESP32C3 device
AGPIO(GPIO_USER), // 0 IO RTC_GPIO0, GPIO0, Strapping
AGPIO(GPIO_USER), // 1 AO RTC_GPIO1, GPIO1, TOUCH1, ADC1_CH0
AGPIO(GPIO_USER), // 2 AO RTC_GPIO2, GPIO2, TOUCH2, ADC1_CH1
AGPIO(GPIO_USER), // 3 AO RTC_GPIO3, GPIO3, TOUCH3, ADC1_CH2, Strapping
AGPIO(GPIO_USER), // 4 AO RTC_GPIO4, GPIO4, TOUCH4, ADC1_CH3
AGPIO(GPIO_USER), // 5 AO RTC_GPIO5, GPIO5, TOUCH5, ADC1_CH4
AGPIO(GPIO_USER), // 6 AO RTC_GPIO6, GPIO6, TOUCH6, ADC1_CH5
AGPIO(GPIO_USER), // 7 AO RTC_GPIO7, GPIO7, TOUCH7, ADC1_CH6
AGPIO(GPIO_USER), // 8 AO RTC_GPIO8, GPIO8, TOUCH8, ADC1_CH7, SUBSPICS1
AGPIO(GPIO_USER), // 9 AO RTC_GPIO9, GPIO9, TOUCH9, ADC1_CH8, SUBSPIHD, FSPIHD
AGPIO(GPIO_USER), // 10 AO RTC_GPIO10, GPIO10, TOUCH10, ADC1_CH9, FSPIIO4, SUBSPICS0, FSPICS0
AGPIO(GPIO_USER), // 11 AO RTC_GPIO11, GPIO11, TOUCH11, ADC2_CH0, FSPIIO5, SUBSPID, FSPID
AGPIO(GPIO_USER), // 12 AO RTC_GPIO12, GPIO12, TOUCH12, ADC2_CH1, FSPIIO6, SUBSPICLK, FSPICLK
AGPIO(GPIO_USER), // 13 AO RTC_GPIO13, GPIO13, TOUCH13, ADC2_CH2, FSPIIO7, SUBSPIQ, FSPIQ
AGPIO(GPIO_USER), // 14 AO RTC_GPIO14, GPIO14, TOUCH14, ADC2_CH3, FSPIDQS, SUBSPIWP, FSPIWP
AGPIO(GPIO_USER), // 15 AO RTC_GPIO15, GPIO15, U0RTS, ADC2_CH4, XTAL_32K_P
AGPIO(GPIO_USER), // 16 AO RTC_GPIO16, GPIO16, U0CTS, ADC2_CH5, XTAL_32K_N
AGPIO(GPIO_USER), // 17 AO RTC_GPIO17, GPIO17, U1TXD, ADC2_CH6
AGPIO(GPIO_USER), // 18 AO RTC_GPIO18, GPIO18, U1RXD, ADC2_CH7, CLK_OUT3
AGPIO(GPIO_USER), // 19 AO RTC_GPIO19, GPIO19, U1RTS, ADC2_CH8, CLK_OUT2, USB_D­
AGPIO(GPIO_USER), // 20 AO RTC_GPIO20, GPIO20, U1CTS, ADC2_CH9, CLK_OUT1, USB_D+
AGPIO(GPIO_USER), // 21 IO RTC_GPIO21, GPIO21
// 22 -- Unused
// 23 -- Unused
// 24 -- Unused
// 25 -- Unused
// 26 FL SPICS1, GPIO26
// 27 FL SPIHD, GPIO27
// 28 FL SPIWP, GPIO28
// 29 FL SPICS0, GPIO29
// 30 FL SPICLK, GPIO30
// 31 FL SPIQ, GPIO31
// 32 FL SPID, GPIO32
AGPIO(GPIO_NONE), // 33 IO SPIIO4, GPIO33, FSPIHD, SUBSPIHD
AGPIO(GPIO_NONE), // 34 IO SPIIO5, GPIO34, FSPICS0, SUBSPICS0
AGPIO(GPIO_NONE), // 35 IO SPIIO6, GPIO35, FSPID, SUBSPID
AGPIO(GPIO_NONE), // 36 IO SPIIO7, GPIO36, FSPICLK, SUBSPICLK
AGPIO(GPIO_NONE), // 37 IO SPIDQS, GPIO37, FSPIQ, SUBSPIQ
AGPIO(GPIO_USER), // 38 IO GPIO38, FSPIWP, SUBSPIWP
AGPIO(GPIO_USER), // 39 IO MTCK, GPIO39, CLK_OUT3, SUBSPICS1
AGPIO(GPIO_USER), // 40 IO MTDO, GPIO40, CLK_OUT2
AGPIO(GPIO_USER), // 41 IO MTDI, GPIO41, CLK_OUT1
AGPIO(GPIO_USER), // 42 IO MTMS, GPIO42
AGPIO(GPIO_USER), // 43 IO U0TXD, GPIO43, CLK_OUT1
AGPIO(GPIO_USER), // 44 IO U0RXD, GPIO44, CLK_OUT2
AGPIO(GPIO_USER), // 45 IO GPIO45, Strapping
AGPIO(GPIO_USER), // 46 IO GPIO46, Strapping
AGPIO(GPIO_USER), // 47 IO SPICLK_P_DIFF, GPIO47, SUBSPICLK_P_DIFF
AGPIO(GPIO_USER), // 48 IO SPICLK_N_DIFF, GPIO48, SUBSPICLK_N_DIFF
0 // Flag
},
};
/*********************************************************************************************\
Known templates
\*********************************************************************************************/
#else // not CONFIG_IDF_TARGET_ESP32C3 nor CONFIG_IDF_TARGET_ESP32S2 - ESP32
/********************************************************************************************\
* ESP32 Module templates

View File

@ -150,7 +150,7 @@ const char HTTP_SCRIPT_TEMPLATE2[] PROGMEM =
"for(i=0;i<" STR(MAX_USER_PINS) ";i++){"
"sk(g[i],i);" // Set GPIO
"}";
#elif defined(CONFIG_IDF_TARGET_ESP32S2)
#elif defined(CONFIG_IDF_TARGET_ESP32S2) || defined(CONFIG_IDF_TARGET_ESP32S3)
const char HTTP_SCRIPT_TEMPLATE2[] PROGMEM =
"j=0;"
"for(i=0;i<" STR(MAX_USER_PINS) ";i++){" // Skip 22-32
@ -1577,7 +1577,7 @@ void HandleTemplateConfiguration(void) {
#if defined(ESP32) && CONFIG_IDF_TARGET_ESP32C3
// ESP32C3 we always send all GPIOs, Flash are just hidden
WSContentSend_P(PSTR("%s%d"), (i>0)?",":"", template_gp.io[i]);
#elif defined(CONFIG_IDF_TARGET_ESP32S2)
#elif defined(CONFIG_IDF_TARGET_ESP32S2) || defined(CONFIG_IDF_TARGET_ESP32S3)
if (!FlashPin(i)) {
WSContentSend_P(PSTR("%s%d"), (i>0)?",":"", template_gp.io[i]);
}
@ -1679,7 +1679,7 @@ void TemplateSaveSettings(void) {
for (uint32_t i = 0; i < nitems(Settings->user_template.gp.io); i++) {
#if defined(ESP32) && CONFIG_IDF_TARGET_ESP32C3
snprintf_P(command, sizeof(command), PSTR("%s%s%d"), command, (i>0)?",":"", WebGetGpioArg(i));
#elif defined(CONFIG_IDF_TARGET_ESP32S2)
#elif defined(CONFIG_IDF_TARGET_ESP32S2) || defined(CONFIG_IDF_TARGET_ESP32S3)
if (22 == i) { j = 33; } // skip 22-32
snprintf_P(command, sizeof(command), PSTR("%s%s%d"), command, (i>0)?",":"", WebGetGpioArg(j));
j++;

View File

@ -81,8 +81,6 @@ extern "C" {
} else {
be_raise(vm, "value_error", "DAC only supported on GPIO17-18");
}
#elif defined(CONFIG_IDF_TARGET_ESP32C3)
be_raise(vm, "value_error", "DAC unsupported in this chip");
#else
be_raise(vm, "value_error", "DAC unsupported in this chip");
#endif