File tree Expand file tree Collapse file tree 2 files changed +14
-2
lines changed
hardware/arduino/avr/libraries/SoftwareSerial Expand file tree Collapse file tree 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)
403403 // Set up RX interrupts, but only if we have a valid RX baud rate
404404 if (_rx_delay_stopbit)
405405 {
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).
406409 *digitalPinToPCICR (_receivePin) |= _BV (digitalPinToPCICRbit (_receivePin));
407- * digitalPinToPCMSK (_receivePin) |= _BV ( digitalPinToPCMSKbit (_receivePin) );
410+ setRxIntMsk ( true );
408411 tunedDelay (_tx_delay); // if we were low this establishes the end
409412 }
410413
@@ -416,10 +419,18 @@ void SoftwareSerial::begin(long speed)
416419 listen ();
417420}
418421
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+
419430void SoftwareSerial::end ()
420431{
421432 if (_rx_delay_stopbit)
422- * digitalPinToPCMSK (_receivePin) &= ~_BV (digitalPinToPCMSKbit(_receivePin) );
433+ setRxIntMsk ( false );
423434}
424435
425436
Original file line number Diff line number Diff line change @@ -74,6 +74,7 @@ class SoftwareSerial : public Stream
7474 void tx_pin_write (uint8_t pin_state);
7575 void setTX (uint8_t transmitPin);
7676 void setRX (uint8_t receivePin);
77+ void setRxIntMsk (bool enable);
7778
7879 // private static method for timing
7980 static inline void tunedDelay (uint16_t delay);
You can’t perform that action at this time.
0 commit comments