From 07125d907ff8b761c4e85c4ee8643219fc3e162b Mon Sep 17 00:00:00 2001 From: "Earle F. Philhower, III" Date: Sun, 19 Apr 2020 22:59:55 -0700 Subject: [PATCH 1/3] Turn off IRQ on stopWaveform after Tone timeout Fix #7230 (until 3.0 when this whole code will probably change). Before, a timed out pin would clear its bit in `waveformEnabled`. The logic in `stopWaveform`. If only one tone was running and timed out, `stopWaveform` would check the `enabled` bitmask and see nothing active and immediately return w/o cancelling the IRQ. So, the IRQ would be called every 1/100th of a second and return immediately when no work to be done was detected. Remove the check and always send in a `waveformToDisable` bit. It's save to disable an already disabled pin, so no logical consequences will occur, and the final IRQ disable will be executed when appropriate. --- cores/esp8266/core_esp8266_waveform.cpp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/cores/esp8266/core_esp8266_waveform.cpp b/cores/esp8266/core_esp8266_waveform.cpp index bd9667cf72..fdaaf5432b 100644 --- a/cores/esp8266/core_esp8266_waveform.cpp +++ b/cores/esp8266/core_esp8266_waveform.cpp @@ -176,12 +176,6 @@ int ICACHE_RAM_ATTR stopWaveform(uint8_t pin) { if (!timerRunning) { return false; } - // 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)) { From 6579c9f7fd9325ee1664598f3d64f05e4eab9aba Mon Sep 17 00:00:00 2001 From: "Earle F. Philhower, III" Date: Mon, 20 Apr 2020 09:23:15 -0700 Subject: [PATCH 2/3] No-op push to get Travis running again --- cores/esp8266/core_esp8266_waveform.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cores/esp8266/core_esp8266_waveform.cpp b/cores/esp8266/core_esp8266_waveform.cpp index fdaaf5432b..f4fbf7aaf8 100644 --- a/cores/esp8266/core_esp8266_waveform.cpp +++ b/cores/esp8266/core_esp8266_waveform.cpp @@ -182,7 +182,7 @@ int ICACHE_RAM_ATTR stopWaveform(uint8_t pin) { timer1_write(microsecondsToClockCycles(10)); } while (waveformToDisable) { - /* no-op */ // Can't delay() since stopWaveform may be called from an IRQ + /* no-op */ // Can't delay() because stopWaveform may be called from an IRQ } if (!waveformEnabled && !timer1CB) { deinitTimer(); From 70a38d7c809156a9a23f7ee639f9b6a228ab5628 Mon Sep 17 00:00:00 2001 From: "Earle F. Philhower, III" Date: Mon, 20 Apr 2020 11:40:09 -0700 Subject: [PATCH 3/3] Fix syntax error --- cores/esp8266/core_esp8266_waveform.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cores/esp8266/core_esp8266_waveform.cpp b/cores/esp8266/core_esp8266_waveform.cpp index f4fbf7aaf8..1ecc4e05ba 100644 --- a/cores/esp8266/core_esp8266_waveform.cpp +++ b/cores/esp8266/core_esp8266_waveform.cpp @@ -176,13 +176,14 @@ int ICACHE_RAM_ATTR stopWaveform(uint8_t pin) { if (!timerRunning) { return false; } + uint32_t mask = 1< microsecondsToClockCycles(10)) { timer1_write(microsecondsToClockCycles(10)); } while (waveformToDisable) { - /* no-op */ // Can't delay() because stopWaveform may be called from an IRQ + /* no-op */ // Can't delay() since stopWaveform may be called from an IRQ } if (!waveformEnabled && !timer1CB) { deinitTimer();