diff --git a/lib/Adafruit_GFX_Library/Adafruit_SPITFT.cpp b/lib/Adafruit_GFX_Library/Adafruit_SPITFT.cpp index 2c8ef01b8..fa083b646 100644 --- a/lib/Adafruit_GFX_Library/Adafruit_SPITFT.cpp +++ b/lib/Adafruit_GFX_Library/Adafruit_SPITFT.cpp @@ -35,6 +35,18 @@ #include "Adafruit_SPITFT.h" +#if defined(ESP32) +#if ESP_IDF_VERSION_MAJOR >= 5 +#include +#define NOT_FAST_PINIO_WAIT for (std::atomic i = 0; i < 1; i++) ; +#else +#define NOT_FAST_PINIO_WAIT for (volatile uint8_t i = 0; i < 1; i++) ; +#endif +#else +#define NOT_FAST_PINIO_WAIT +#endif + + #if defined(__AVR__) #if defined(__AVR_XMEGA__) // only tested with __AVR_ATmega4809__ #define AVR_WRITESPI(x) \ @@ -2305,10 +2317,7 @@ inline void Adafruit_SPITFT::SPI_MOSI_HIGH(void) { #endif // end !HAS_PORT_SET_CLR #else // !USE_FAST_PINIO digitalWrite(swspi._mosi, HIGH); -#if defined(ESP32) - for (volatile uint8_t i = 0; i < 1; i++) - ; -#endif // end ESP32 + NOT_FAST_PINIO_WAIT #endif // end !USE_FAST_PINIO } @@ -2328,10 +2337,7 @@ inline void Adafruit_SPITFT::SPI_MOSI_LOW(void) { #endif // end !HAS_PORT_SET_CLR #else // !USE_FAST_PINIO digitalWrite(swspi._mosi, LOW); -#if defined(ESP32) - for (volatile uint8_t i = 0; i < 1; i++) - ; -#endif // end ESP32 + NOT_FAST_PINIO_WAIT #endif // end !USE_FAST_PINIO } @@ -2355,10 +2361,7 @@ inline void Adafruit_SPITFT::SPI_SCK_HIGH(void) { #endif // end !HAS_PORT_SET_CLR #else // !USE_FAST_PINIO digitalWrite(swspi._sck, HIGH); -#if defined(ESP32) - for (volatile uint8_t i = 0; i < 1; i++) - ; -#endif // end ESP32 + NOT_FAST_PINIO_WAIT #endif // end !USE_FAST_PINIO } @@ -2382,10 +2385,7 @@ inline void Adafruit_SPITFT::SPI_SCK_LOW(void) { #endif // end !HAS_PORT_SET_CLR #else // !USE_FAST_PINIO digitalWrite(swspi._sck, LOW); -#if defined(ESP32) - for (volatile uint8_t i = 0; i < 1; i++) - ; -#endif // end ESP32 + NOT_FAST_PINIO_WAIT #endif // end !USE_FAST_PINIO } diff --git a/lib/Adafruit_TSL2591/Adafruit_TSL2591.cpp b/lib/Adafruit_TSL2591/Adafruit_TSL2591.cpp index 52e71971f..b230f800c 100644 --- a/lib/Adafruit_TSL2591/Adafruit_TSL2591.cpp +++ b/lib/Adafruit_TSL2591/Adafruit_TSL2591.cpp @@ -141,7 +141,8 @@ void Adafruit_TSL2591::setGain(tsl2591Gain_t gain) enable(); _gain = gain; - write8(TSL2591_COMMAND_BIT | TSL2591_REGISTER_CONTROL, _integration | _gain); + const uint8_t value = static_cast(_integration) | static_cast(_gain); + write8(TSL2591_COMMAND_BIT | TSL2591_REGISTER_CONTROL, value); disable(); } @@ -162,7 +163,8 @@ void Adafruit_TSL2591::setTiming(tsl2591IntegrationTime_t integration) enable(); _integration = integration; - write8(TSL2591_COMMAND_BIT | TSL2591_REGISTER_CONTROL, _integration | _gain); + const uint8_t value = static_cast(_integration) | static_cast(_gain); + write8(TSL2591_COMMAND_BIT | TSL2591_REGISTER_CONTROL, value); disable(); } diff --git a/src/_P076_HLW8012.ino b/src/_P076_HLW8012.ino index 1925b3283..6c556f7ed 100644 --- a/src/_P076_HLW8012.ino +++ b/src/_P076_HLW8012.ino @@ -68,8 +68,14 @@ float p076_hpowfact{}; # define P076_Gosund 9 # define P076_Shelly_PLUG_S 10 +#if ESP_IDF_VERSION_MAJOR >= 5 +// FIXME TD-er: Must check if older (and ESP8266) envs need IRAM_ATTR in the function declaration. +void p076_hlw8012_cf1_interrupt(); +void p076_hlw8012_cf_interrupt(); +#else void IRAM_ATTR p076_hlw8012_cf1_interrupt(); void IRAM_ATTR p076_hlw8012_cf_interrupt(); +#endif bool p076_getDeviceParameters(int device, diff --git a/src/src/CustomBuild/define_plugin_sets.h b/src/src/CustomBuild/define_plugin_sets.h index 51bcc4ac2..0d56716bc 100644 --- a/src/src/CustomBuild/define_plugin_sets.h +++ b/src/src/CustomBuild/define_plugin_sets.h @@ -3211,6 +3211,13 @@ To create/register a plugin, you have to : #undef USES_P002 #endif + + // Internal temp sensor causes crashes on ESP32-C3 + #ifdef FEATURE_INTERNAL_TEMPERATURE + # undef FEATURE_INTERNAL_TEMPERATURE + # define FEATURE_INTERNAL_TEMPERATURE 0 + #endif + #endif diff --git a/src/src/PluginStructs/P090_data_struct.cpp b/src/src/PluginStructs/P090_data_struct.cpp index 958e465d5..31bcf4288 100644 --- a/src/src/PluginStructs/P090_data_struct.cpp +++ b/src/src/PluginStructs/P090_data_struct.cpp @@ -57,8 +57,8 @@ CCS811Core::status CCS811Core::beginCore(void) # endif // Spin for a few ms - volatile uint8_t temp = 0; - + ESPEASY_VOLATILE(uint8_t) temp = 0; + // FIXME TD-er: This is a rather odd way to avoid calling "delay" for (uint16_t i = 0; i < 10000; i++) { temp++; diff --git a/src/src/PluginStructs/P092_data_struct.h b/src/src/PluginStructs/P092_data_struct.h index 81030b660..20d82b114 100644 --- a/src/src/PluginStructs/P092_data_struct.h +++ b/src/src/PluginStructs/P092_data_struct.h @@ -44,7 +44,7 @@ public: volatile uint8_t ISR_DLB_Pin = 0xFF; volatile boolean ISR_Receiving = false; // receiving flag volatile boolean ISR_AllBitsReceived = false; - volatile uint16_t ISR_PulseCount = 0; // number of received pulses + ESPEASY_VOLATILE(uint16_t) ISR_PulseCount = 0; // number of received pulses volatile uint16_t ISR_PulseNumber = 0; // max naumber of the received pulses volatile uint16_t ISR_MinPulseWidth = 0; volatile uint16_t ISR_MaxPulseWidth = 0;