File tree 1 file changed +9
-11
lines changed
1 file changed +9
-11
lines changed Original file line number Diff line number Diff line change @@ -178,17 +178,15 @@ int ICACHE_RAM_ATTR stopWaveform(uint8_t pin) {
178
178
}
179
179
// If user sends in a pin >16 but <32, this will always point to a 0 bit
180
180
// 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
+ }
192
190
}
193
191
if (!waveformEnabled && !timer1CB) {
194
192
deinitTimer ();
You can’t perform that action at this time.
0 commit comments