Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit cf9c5b1

Browse files
committedApr 21, 2020
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 esp8266#7230.
1 parent b02643e commit cf9c5b1

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed
 

‎cores/esp8266/core_esp8266_waveform.cpp

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -178,17 +178,15 @@ int ICACHE_RAM_ATTR stopWaveform(uint8_t pin) {
178178
}
179179
// If user sends in a pin >16 but <32, this will always point to a 0 bit
180180
// If they send >=32, then the shift will result in 0 and it will also return false
181-
uint32_t mask = 1<<pin;
182-
if (!(waveformEnabled & mask)) {
183-
return false; // It's not running, nothing to do here
184-
}
185-
waveformToDisable |= mask;
186-
// Ensure timely service....
187-
if (T1L > microsecondsToClockCycles(10)) {
188-
timer1_write(microsecondsToClockCycles(10));
189-
}
190-
while (waveformToDisable) {
191-
/* no-op */ // Can't delay() since stopWaveform may be called from an IRQ
181+
if (waveformEnabled & (1UL << pin)) {
182+
waveformToDisable = 1UL << pin;
183+
// Must not interfere if Timer is due shortly
184+
if (T1L > microsecondsToClockCycles(10)) {
185+
timer1_write(microsecondsToClockCycles(10));
186+
}
187+
while (waveformToDisable) {
188+
/* no-op */ // Can't delay() since stopWaveform may be called from an IRQ
189+
}
192190
}
193191
if (!waveformEnabled && !timer1CB) {
194192
deinitTimer();

0 commit comments

Comments
 (0)
Please sign in to comment.