From 6e8928b8a1106422153a672f2de9791d65286966 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Tue, 23 Jun 2020 17:28:15 +0200 Subject: [PATCH] Fix PWM software watchdogs Fix PWM software watchdogs by correctly initializing variables (#8721) --- tasmota/core_esp8266_waveform.cpp | 8 ++++---- tasmota/core_esp8266_wiring_digital.cpp | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tasmota/core_esp8266_waveform.cpp b/tasmota/core_esp8266_waveform.cpp index 1ff0a3687..29a485874 100644 --- a/tasmota/core_esp8266_waveform.cpp +++ b/tasmota/core_esp8266_waveform.cpp @@ -133,9 +133,9 @@ constexpr int maxPWMs = 8; // PWM machine state typedef struct PWMState { - uint32_t mask; // Bitmask of active pins - uint32_t cnt; // How many entries - uint32_t idx; // Where the state machine is along the list + uint32_t mask = 0; // Bitmask of active pins + uint32_t cnt = 0; // How many entries + uint32_t idx = 0; // Where the state machine is along the list uint8_t pin[maxPWMs + 1]; uint32_t delta[maxPWMs + 1]; uint32_t nextServiceCycle; // Clock cycle for next step @@ -528,7 +528,7 @@ static ICACHE_RAM_ATTR void timer1Interrupt() { // Done, remove! if (i == 16) { GP16O = 0; - } + } GPOC = mask; wvfState.waveformEnabled &= ~mask; continue; diff --git a/tasmota/core_esp8266_wiring_digital.cpp b/tasmota/core_esp8266_wiring_digital.cpp index 199fbabd8..7fb3ccb00 100644 --- a/tasmota/core_esp8266_wiring_digital.cpp +++ b/tasmota/core_esp8266_wiring_digital.cpp @@ -153,8 +153,8 @@ void ICACHE_RAM_ATTR interrupt_handler(void*) while(!(changedbits & (1 << i))) i++; changedbits &= ~(1 << i); interrupt_handler_t *handler = &interrupt_handlers[i]; - if (handler->fn && - (handler->mode == CHANGE || + if (handler->fn && + (handler->mode == CHANGE || (handler->mode & 1) == !!(levels & (1 << i)))) { // to make ISR compatible to Arduino AVR model where interrupts are disabled // we disable them before we call the client ISR