From cf9c5b1af05ad3c9e2e9f65d0fc1f8b4c08131b1 Mon Sep 17 00:00:00 2001 From: "Dirk O. Kaar" Date: Sun, 19 Apr 2020 18:09:05 +0200 Subject: [PATCH] Waveform stopped by runtime limit in iSR doesn't deinit the timer, but stopWaveform refuses to do anything if the waveform was stopped by runtime, either. Fixes #7230. --- cores/esp8266/core_esp8266_waveform.cpp | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/cores/esp8266/core_esp8266_waveform.cpp b/cores/esp8266/core_esp8266_waveform.cpp index bd9667cf72..597a8e88ab 100644 --- a/cores/esp8266/core_esp8266_waveform.cpp +++ b/cores/esp8266/core_esp8266_waveform.cpp @@ -178,17 +178,15 @@ int ICACHE_RAM_ATTR stopWaveform(uint8_t pin) { } // If user sends in a pin >16 but <32, this will always point to a 0 bit // If they send >=32, then the shift will result in 0 and it will also return false - uint32_t mask = 1< microsecondsToClockCycles(10)) { - timer1_write(microsecondsToClockCycles(10)); - } - while (waveformToDisable) { - /* no-op */ // Can't delay() since stopWaveform may be called from an IRQ + if (waveformEnabled & (1UL << pin)) { + waveformToDisable = 1UL << pin; + // Must not interfere if Timer is due shortly + if (T1L > microsecondsToClockCycles(10)) { + timer1_write(microsecondsToClockCycles(10)); + } + while (waveformToDisable) { + /* no-op */ // Can't delay() since stopWaveform may be called from an IRQ + } } if (!waveformEnabled && !timer1CB) { deinitTimer();