Skip to content

Commit

Permalink
Merge pull request letscontrolit#5185 from TD-er/bugfix/ESP32C3_flash…
Browse files Browse the repository at this point in the history
…PinSelection

[Flash] Fix availability of flash pins on ESP32C3
  • Loading branch information
TD-er authored Dec 29, 2024
2 parents d671184 + eda2c59 commit 40d65f0
Show file tree
Hide file tree
Showing 35 changed files with 2,199 additions and 1,417 deletions.
277 changes: 231 additions & 46 deletions docs/source/ESPEasy/ESPchips.rst

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/ESPEasy_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#endif // if defined(ESP8266)
#if defined(ESP32)
# include <WiFi.h>
# include <soc/soc_caps.h>
#endif // if defined(ESP32)


Expand Down
14 changes: 8 additions & 6 deletions src/_P097_Esp32Touch.ino
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,20 @@
// #######################################################################################################


#if defined(ESP32) && !defined(ESP32C2) && !defined(ESP32C3) && !defined(ESP32C6)
#if defined(SOC_TOUCH_SENSOR_SUPPORTED) && SOC_TOUCH_SENSOR_SUPPORTED

# define LAST_TOUCH_INPUT_INDEX SOC_TOUCH_SENSOR_NUM

#ifdef ESP32_CLASSIC
# define HAS_T0_INPUT 1
# define HAS_T10_TO_T14 0
# define LAST_TOUCH_INPUT_INDEX 10
#endif
#if defined(ESP32S2) || defined(ESP32S3)
// # define LAST_TOUCH_INPUT_INDEX 10
#elif defined(ESP32S2) || defined(ESP32S3)
# define HAS_T0_INPUT 0
# define HAS_T10_TO_T14 1
# define LAST_TOUCH_INPUT_INDEX 15

// # define LAST_TOUCH_INPUT_INDEX 15
#else
static_assert(false, "Implement processor architecture");
#endif


Expand Down
7 changes: 4 additions & 3 deletions src/_P152_DAC.ino
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

#include "_Plugin_Helper.h"

#if defined(SOC_DAC_SUPPORTED) && SOC_DAC_SUPPORTED

#define PLUGIN_152
#define PLUGIN_ID_152 152
#define PLUGIN_NAME_152 "Output - ESP32 DAC"
Expand All @@ -21,9 +23,6 @@
#define P152_DAC_VALUE UserVar[event->BaseVarIndex]
#define P152_SET_DAC_VALUE(x) UserVar.setFloat(event->TaskIndex, 0, x)

#if !(defined(ESP32_CLASSIC) || defined(ESP32S2))
# error P152 ESP32 DAC not supported on this CPU type!
#endif // if !(defined(ESP32_CLASSIC) || defined(ESP32S2))

boolean Plugin_152(uint8_t function, struct EventStruct *event, String& string)
{
Expand Down Expand Up @@ -122,4 +121,6 @@ boolean Plugin_152(uint8_t function, struct EventStruct *event, String& string)
return success;
}

#endif

#endif // USES_P152
17 changes: 15 additions & 2 deletions src/src/CustomBuild/define_plugin_sets.h
Original file line number Diff line number Diff line change
Expand Up @@ -1446,7 +1446,7 @@ To create/register a plugin, you have to :
#define USES_P073 // 7DGT
#define USES_P079 // Wemos Motoshield

#if !defined(USES_P152) && (defined(ESP32_CLASSIC) || defined(ESP32S2)) // Only supported on ESP32 and ESP32-S2
#if defined(SOC_DAC_SUPPORTED) && SOC_DAC_SUPPORTED // Only supported on ESP32 and ESP32-S2
#define USES_P152 // ESP32 DAC
#endif
#endif
Expand Down Expand Up @@ -2445,7 +2445,7 @@ To create/register a plugin, you have to :
#ifndef USES_P151
#define USES_P151 // Environment - I2C Honeywell Pressure
#endif
#if !defined(USES_P152) && (defined(ESP32_CLASSIC) || defined(ESP32S2)) // Only supported on ESP32 and ESP32-S2
#if defined(SOC_DAC_SUPPORTED) && SOC_DAC_SUPPORTED // Only supported on ESP32 and ESP32-S2
#define USES_P152 // ESP32 DAC
#endif
#ifndef USES_P153
Expand Down Expand Up @@ -3628,4 +3628,17 @@ To create/register a plugin, you have to :
#endif
#endif

#if !(defined(SOC_DAC_SUPPORTED) && SOC_DAC_SUPPORTED)
#ifdef USES_P152
#undef USES_P152
#endif
#endif

#if !(defined(SOC_TOUCH_SENSOR_SUPPORTED) && SOC_TOUCH_SENSOR_SUPPORTED)
#ifdef USES_P097
#undef USES_P097
#endif
#endif


#endif // CUSTOMBUILD_DEFINE_PLUGIN_SETS_H
34 changes: 6 additions & 28 deletions src/src/Helpers/Hardware.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,39 +66,17 @@
# include <bootloader_common.h>
# endif // if ESP_IDF_VERSION_MAJOR == 4


# if CONFIG_IDF_TARGET_ESP32S3 // ESP32-S3
# define HAS_HALL_EFFECT_SENSOR 0
# define HAS_TOUCH_GPIO 1
# elif CONFIG_IDF_TARGET_ESP32S2 // ESP32-S2
# define HAS_HALL_EFFECT_SENSOR 0
# define HAS_TOUCH_GPIO 1
# elif CONFIG_IDF_TARGET_ESP32C6 // ESP32-C6
# define HAS_HALL_EFFECT_SENSOR 0
# define HAS_TOUCH_GPIO 0
# elif CONFIG_IDF_TARGET_ESP32C3 // ESP32-C3
# define HAS_HALL_EFFECT_SENSOR 0
# define HAS_TOUCH_GPIO 0
# elif CONFIG_IDF_TARGET_ESP32C2 // ESP32-C2
# define HAS_HALL_EFFECT_SENSOR 0
# define HAS_TOUCH_GPIO 0
# elif CONFIG_IDF_TARGET_ESP32 // ESP32/PICO-D4
#if CONFIG_IDF_TARGET_ESP32 // ESP32/PICO-D4
# if ESP_IDF_VERSION_MAJOR < 5
# define HAS_HALL_EFFECT_SENSOR 1
# else // if ESP_IDF_VERSION_MAJOR < 5

// Support for Hall Effect sensor was removed in ESP_IDF 5.x
# define HAS_HALL_EFFECT_SENSOR 0
# endif // if ESP_IDF_VERSION_MAJOR < 5
# define HAS_TOUCH_GPIO 1
# else // if CONFIG_IDF_TARGET_ESP32S3
# error Target CONFIG_IDF_TARGET is not supported
# endif // if CONFIG_IDF_TARGET_ESP32S3


# ifndef HAS_TOUCH_GPIO
# define HAS_TOUCH_GPIO 0
# endif // ifndef HAS_TOUCH_GPIO
# else
# define HAS_HALL_EFFECT_SENSOR 0
# endif


# if ESP_IDF_VERSION_MAJOR >= 5
Expand Down Expand Up @@ -444,9 +422,9 @@ int espeasy_analogRead(int pin, bool readAsTouch) {

if (canread) {
if (readAsTouch && (t >= 0)) {
# if HAS_TOUCH_GPIO
#if defined(SOC_TOUCH_SENSOR_SUPPORTED) && SOC_TOUCH_SENSOR_SUPPORTED
value = touchRead(pin);
# endif // if HAS_TOUCH_GPIO
# endif
} else {
value = analogRead(pin);
}
Expand Down
10 changes: 5 additions & 5 deletions src/src/Helpers/Hardware_ADC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ bool Hardware_ADC_t::init(int pin, adc_atten_t attenuation)
return false;
}
_pin = pin;
# if HAS_TOUCH_GPIO
#if defined(SOC_TOUCH_SENSOR_SUPPORTED) && SOC_TOUCH_SENSOR_SUPPORTED
_isTouchPin = t >= 0;
# endif // if HAS_TOUCH_GPIO
#endif
_attenuation = attenuation;

# if ESP_IDF_VERSION_MAJOR >= 5
Expand Down Expand Up @@ -103,7 +103,7 @@ int Hardware_ADC_t::read(bool readAsTouch) {
# endif // if HAS_HALL_EFFECT_SENSOR

# if ESP_IDF_VERSION_MAJOR >= 5
// Starting with IDF 5.x, you can apparently no use ADC2 along with WiFi running.
// Starting with IDF 5.x, you can apparently now use ADC2 along with WiFi running.
// See: https://docs.espressif.com/projects/esp-idf/en/v5.1.1/esp32/api-reference/peripherals/adc_oneshot.html#hardware-limitations
const bool canread = true;
#else
Expand All @@ -115,12 +115,12 @@ int Hardware_ADC_t::read(bool readAsTouch) {
#endif

if (canread) {
# if HAS_TOUCH_GPIO
#if defined(SOC_TOUCH_SENSOR_SUPPORTED) && SOC_TOUCH_SENSOR_SUPPORTED

if (readAsTouch && _isTouchPin) {
return touchRead(_pin);
}
# endif // if HAS_TOUCH_GPIO
# endif

# if ESP_IDF_VERSION_MAJOR >= 5

Expand Down
4 changes: 2 additions & 2 deletions src/src/Helpers/Hardware_ADC.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ class Hardware_ADC_t {
int _pin = -1;
int _adc = -1;

# if HAS_TOUCH_GPIO
#if defined(SOC_TOUCH_SENSOR_SUPPORTED) && SOC_TOUCH_SENSOR_SUPPORTED
bool _isTouchPin = false;
# endif // if HAS_TOUCH_GPIO
# endif
bool _useFactoryCalibration = false;
#if ESP_IDF_VERSION_MAJOR >= 5
adc_atten_t _attenuation = ADC_ATTEN_DB_12;
Expand Down
Loading

0 comments on commit 40d65f0

Please sign in to comment.