File tree 2 files changed +14
-2
lines changed
2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -403,8 +403,11 @@ void SoftwareSerial::begin(long speed)
403
403
// Set up RX interrupts, but only if we have a valid RX baud rate
404
404
if (_rx_delay_stopbit)
405
405
{
406
+ // Enable the PCINT for the entire port here, but never disable it
407
+ // (others might also need it, so we disable the interrupt by using
408
+ // the per-pin PCMSK register).
406
409
*digitalPinToPCICR (_receivePin) |= _BV (digitalPinToPCICRbit (_receivePin));
407
- * digitalPinToPCMSK (_receivePin) |= _BV ( digitalPinToPCMSKbit (_receivePin) );
410
+ setRxIntMsk ( true );
408
411
tunedDelay (_tx_delay); // if we were low this establishes the end
409
412
}
410
413
@@ -416,10 +419,18 @@ void SoftwareSerial::begin(long speed)
416
419
listen ();
417
420
}
418
421
422
+ void SoftwareSerial::setRxIntMsk (bool enable)
423
+ {
424
+ if (enable)
425
+ *digitalPinToPCMSK (_receivePin) |= _BV (digitalPinToPCMSKbit (_receivePin));
426
+ else
427
+ *digitalPinToPCMSK (_receivePin) &= ~_BV (digitalPinToPCMSKbit(_receivePin));
428
+ }
429
+
419
430
void SoftwareSerial::end ()
420
431
{
421
432
if (_rx_delay_stopbit)
422
- * digitalPinToPCMSK (_receivePin) &= ~_BV (digitalPinToPCMSKbit(_receivePin) );
433
+ setRxIntMsk ( false );
423
434
}
424
435
425
436
Original file line number Diff line number Diff line change @@ -74,6 +74,7 @@ class SoftwareSerial : public Stream
74
74
void tx_pin_write (uint8_t pin_state);
75
75
void setTX (uint8_t transmitPin);
76
76
void setRX (uint8_t receivePin);
77
+ void setRxIntMsk (bool enable);
77
78
78
79
// private static method for timing
79
80
static inline void tunedDelay (uint16_t delay);
You can’t perform that action at this time.
0 commit comments