Skip to content

Commit b2ed06a

Browse files
committed
Same performance for normal and inverted line signal, but lower for normal.
1 parent bbffcd2 commit b2ed06a

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/SoftwareSerial.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ int SoftwareSerial::available() {
213213
void ICACHE_RAM_ATTR SoftwareSerial::preciseDelay(bool asyn, uint32_t savedPS) {
214214
if (asyn)
215215
{
216+
// Reenable interrupts while delaying to avoid other tasks piling up
216217
if (!m_intTxEnabled) { xt_wsr_ps(savedPS); }
217218
auto expired = ESP.getCycleCount() - m_periodStart;
218219
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) {
222223
if (asyn)
223224
{
224225
resetPeriodStart();
226+
// Disable interrupts again
225227
if (!m_intTxEnabled) { savedPS = xt_rsil(15); }
226228
}
227229
}
@@ -233,17 +235,13 @@ void ICACHE_RAM_ATTR SoftwareSerial::writePeriod(
233235
digitalWrite(m_txPin, HIGH);
234236
m_periodDuration += dutyCycle;
235237
bool asyn = withStopBit && !m_invert;
236-
// Reenable interrupts while delaying to avoid other tasks piling up
237238
if (asyn || offCycle) preciseDelay(asyn, savedPS);
238-
// Disable interrupts again
239239
}
240240
if (offCycle) {
241241
digitalWrite(m_txPin, LOW);
242242
m_periodDuration += offCycle;
243243
bool asyn = withStopBit && m_invert;
244-
// Reenable interrupts while delaying to avoid other tasks piling up
245244
if (asyn) preciseDelay(asyn, savedPS);
246-
// Disable interrupts again
247245
}
248246
}
249247

0 commit comments

Comments
 (0)