From 5297bab041ffe63faf5e1edaa33a5758b65fcd78 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Fri, 17 Nov 2023 16:06:45 +0100 Subject: [PATCH] Revert "Final fix ESP32C3 relay toggle" This reverts commit 4489dba8ddff8df77311414d1867a9907f97252b. --- tasmota/tasmota_support/support_esp32.ino | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/tasmota/tasmota_support/support_esp32.ino b/tasmota/tasmota_support/support_esp32.ino index 746656aac..e3c29dcce 100644 --- a/tasmota/tasmota_support/support_esp32.ino +++ b/tasmota/tasmota_support/support_esp32.ino @@ -993,11 +993,7 @@ extern "C" void ARDUINO_ISR_ATTR pinMode(uint8_t pin, uint8_t mode) { __pinMode(pin, mode); #ifdef CONFIG_IDF_TARGET_ESP32C3 // See GpioForceHoldRelay() below - static uint64_t pin_hold_mask = 0; - if (!bitRead(pin_hold_mask, pin)) { - bitSet(pin_hold_mask, pin); - gpio_hold_dis((gpio_num_t)pin); // Allow state change - } + gpio_hold_dis((gpio_num_t)pin); // Allow state change #endif } @@ -1008,12 +1004,10 @@ void GpioForceHoldRelay(void) { // gpio_force_hold_all(); // This will hold flash/serial too so do not use - // Use current gpio config -// for (uint32_t i = 0; i < nitems(TasmotaGlobal.gpio_pin); i++) { -// if ((TasmotaGlobal.gpio_pin[i] & 0xFFE0) == GPIO_REL1 << 5) { - // Use future gpio config - for (uint32_t i = 0; i < nitems(Settings->my_gp.io); i++) { - if ((Settings->my_gp.io[i] & 0xFFE0) == GPIO_REL1 << 5) { + uint16_t real_gpio = GPIO_REL1 << 5; + uint16_t mask = 0xFFE0; + for (uint32_t i = 0; i < nitems(TasmotaGlobal.gpio_pin); i++) { + if ((TasmotaGlobal.gpio_pin[i] & mask) == real_gpio) { gpio_hold_en((gpio_num_t)i); // Retain the state when the chip or system is reset, for example, when watchdog time-out or Deep-sleep } }