1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-04-21 10:26:06 +03:00

Allow stopWaveform to stop timed-out waveforms (#7236)

Fixes #7230.
This commit is contained in:
Dirk O. Kaar 2020-04-24 01:00:17 +02:00 committed by GitHub
parent 9b41d9ac5e
commit 36e047e908
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -178,18 +178,16 @@ 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 (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();
}