Skip to content

Commit

Permalink
Waveform stopped by runtime limit in iSR doesn't deinit the timer, bu…
Browse files Browse the repository at this point in the history
…t stopWaveform refuses to do anything if the waveform was stopped by runtime, either. Fixes #7230.
  • Loading branch information
dok-net committed Apr 21, 2020
1 parent b02643e commit cf9c5b1
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions cores/esp8266/core_esp8266_waveform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<<pin;
if (!(waveformEnabled & mask)) {
return false; // It's not running, nothing to do here
}
waveformToDisable |= mask;
// Ensure timely service....
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 & (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();
Expand Down

0 comments on commit cf9c5b1

Please sign in to comment.