@@ -213,6 +213,7 @@ int SoftwareSerial::available() {
213
213
void ICACHE_RAM_ATTR SoftwareSerial::preciseDelay (bool asyn, uint32_t savedPS) {
214
214
if (asyn)
215
215
{
216
+ // Reenable interrupts while delaying to avoid other tasks piling up
216
217
if (!m_intTxEnabled) { xt_wsr_ps (savedPS); }
217
218
auto expired = ESP.getCycleCount () - m_periodStart;
218
219
auto micro_s = expired < m_periodDuration ? (m_periodDuration - expired) / ESP.getCpuFreqMHz () : 0 ;
@@ -222,6 +223,7 @@ void ICACHE_RAM_ATTR SoftwareSerial::preciseDelay(bool asyn, uint32_t savedPS) {
222
223
if (asyn)
223
224
{
224
225
resetPeriodStart ();
226
+ // Disable interrupts again
225
227
if (!m_intTxEnabled) { savedPS = xt_rsil (15 ); }
226
228
}
227
229
}
@@ -233,17 +235,13 @@ void ICACHE_RAM_ATTR SoftwareSerial::writePeriod(
233
235
digitalWrite (m_txPin, HIGH);
234
236
m_periodDuration += dutyCycle;
235
237
bool asyn = withStopBit && !m_invert;
236
- // Reenable interrupts while delaying to avoid other tasks piling up
237
238
if (asyn || offCycle) preciseDelay (asyn, savedPS);
238
- // Disable interrupts again
239
239
}
240
240
if (offCycle) {
241
241
digitalWrite (m_txPin, LOW);
242
242
m_periodDuration += offCycle;
243
243
bool asyn = withStopBit && m_invert;
244
- // Reenable interrupts while delaying to avoid other tasks piling up
245
244
if (asyn) preciseDelay (asyn, savedPS);
246
- // Disable interrupts again
247
245
}
248
246
}
249
247
0 commit comments