From 7d18dd0e9e5d46f880cc3aadc7bcfd6d2fe16c22 Mon Sep 17 00:00:00 2001 From: Christian Baars Date: Mon, 14 Aug 2023 09:34:48 +0200 Subject: [PATCH] fix OneWire for IDF5.1 and C2/C6 (#19303) * fix OneWire for IDF5.1 and C2/C6 * Use Onewire in arduino30 builds * use SOC specific defines for C2,C3 and C6 --- lib/lib_basic/OneWire-Stickbreaker/OneWire.h | 13 ++++++++----- platformio_tasmota_env32.ini | 2 -- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/lib_basic/OneWire-Stickbreaker/OneWire.h b/lib/lib_basic/OneWire-Stickbreaker/OneWire.h index c92dda8d0afa..cb1e16d73132 100644 --- a/lib/lib_basic/OneWire-Stickbreaker/OneWire.h +++ b/lib/lib_basic/OneWire-Stickbreaker/OneWire.h @@ -147,6 +147,9 @@ #elif defined(ARDUINO_ARCH_ESP32) #include +#if ESP_IDF_VERSION_MAJOR >= 5 +#include "soc/gpio_periph.h" +#endif // ESP_IDF_VERSION_MAJOR >= 5 #define PIN_TO_BASEREG(pin) (0) #define PIN_TO_BITMASK(pin) (pin) #define IO_REG_TYPE uint32_t @@ -156,7 +159,7 @@ static inline __attribute__((always_inline)) IO_REG_TYPE directRead(IO_REG_TYPE pin) { -#if CONFIG_IDF_TARGET_ESP32C3 +#if CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C2 || CONFIG_IDF_TARGET_ESP32C6 // max. usable Pins are 23 for C6 (below flash pins) return (GPIO.in.val >> pin) & 0x1; #else // plain ESP32 if ( pin < 32 ) @@ -171,7 +174,7 @@ IO_REG_TYPE directRead(IO_REG_TYPE pin) static inline __attribute__((always_inline)) void directWriteLow(IO_REG_TYPE pin) { -#if CONFIG_IDF_TARGET_ESP32C3 +#if CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C2 || CONFIG_IDF_TARGET_ESP32C6 GPIO.out_w1tc.val = ((uint32_t)1 << pin); #else // plain ESP32 if ( pin < 32 ) @@ -184,7 +187,7 @@ void directWriteLow(IO_REG_TYPE pin) static inline __attribute__((always_inline)) void directWriteHigh(IO_REG_TYPE pin) { -#if CONFIG_IDF_TARGET_ESP32C3 +#if CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C2 || CONFIG_IDF_TARGET_ESP32C6 GPIO.out_w1ts.val = ((uint32_t)1 << pin); #else // plain ESP32 if ( pin < 32 ) @@ -197,7 +200,7 @@ void directWriteHigh(IO_REG_TYPE pin) static inline __attribute__((always_inline)) void directModeInput(IO_REG_TYPE pin) { -#if CONFIG_IDF_TARGET_ESP32C3 +#if CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C2 || CONFIG_IDF_TARGET_ESP32C6 GPIO.enable_w1tc.val = ((uint32_t)1 << (pin)); #else if ( digitalPinIsValid(pin) ) @@ -223,7 +226,7 @@ void directModeInput(IO_REG_TYPE pin) static inline __attribute__((always_inline)) void directModeOutput(IO_REG_TYPE pin) { -#if CONFIG_IDF_TARGET_ESP32C3 +#if CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C2 || CONFIG_IDF_TARGET_ESP32C6 GPIO.enable_w1ts.val = ((uint32_t)1 << (pin)); #else if ( digitalPinIsValid(pin) && pin <= 33 ) // pins above 33 can be only inputs diff --git a/platformio_tasmota_env32.ini b/platformio_tasmota_env32.ini index 2e826f757b61..fe74871af750 100644 --- a/platformio_tasmota_env32.ini +++ b/platformio_tasmota_env32.ini @@ -54,7 +54,6 @@ lib_ignore = ESP Mail Client IRremoteESP8266 NeoPixelBus - OneWire MFRC522 universal display Library ESP8266Audio @@ -75,7 +74,6 @@ lib_ignore = ESP Mail Client IRremoteESP8266 NeoPixelBus - OneWire MFRC522 universal display Library ESP8266Audio