From aca4223ad6b285b8734a1238726fd972af8e602c Mon Sep 17 00:00:00 2001 From: Stephan Hadinger Date: Tue, 16 Nov 2021 22:21:44 +0100 Subject: [PATCH] ESP32 fix leftover GPIO configuration after restart --- CHANGELOG.md | 1 + tasmota/support_tasmota.ino | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index cf3b47477..3c68385d0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ All notable changes to this project will be documented in this file. ## [10.0.0.3] ### Added - Autoconfiguration for ESP32 and variants +- ESP32 fix leftover GPIO configuration after restart ### Changed - ESP8266 Gratuitous ARP enabled and set to 60 seconds (#13623) diff --git a/tasmota/support_tasmota.ino b/tasmota/support_tasmota.ino index 10bbcc495..bfe894446 100644 --- a/tasmota/support_tasmota.ino +++ b/tasmota/support_tasmota.ino @@ -1651,6 +1651,22 @@ void ResetPwm(void) /********************************************************************************************/ +#ifdef ESP32 +// Since ESP-IDF 4.4, GPIO matrix or I/O is not reset during a restart +// and GPIO configuration can get stuck because of leftovers +// +// This patched version of pinMode forces a full GPIO reset before setting new mode +// +extern "C" void ARDUINO_ISR_ATTR __pinMode(uint8_t pin, uint8_t mode); + +extern "C" void ARDUINO_ISR_ATTR pinMode(uint8_t pin, uint8_t mode) { + gpio_reset_pin((gpio_num_t)pin); + __pinMode(pin, mode); +} +#endif + +/********************************************************************************************/ + void GpioInit(void) { if (!ValidModule(Settings->module)) {