mirror of
https://github.com/arduino/Arduino.git
synced 2025-02-19 13:54:23 +01:00
Add SoftwareSerial::setRxIntMsk()
This moves the interrupt mask enabling / disabling code into a separate method, so we can call it from multiple spots next.
This commit is contained in:
parent
1704e7e820
commit
db1a4ad139
@ -403,8 +403,11 @@ void SoftwareSerial::begin(long speed)
|
||||
// Set up RX interrupts, but only if we have a valid RX baud rate
|
||||
if (_rx_delay_stopbit)
|
||||
{
|
||||
// Enable the PCINT for the entire port here, but never disable it
|
||||
// (others might also need it, so we disable the interrupt by using
|
||||
// the per-pin PCMSK register).
|
||||
*digitalPinToPCICR(_receivePin) |= _BV(digitalPinToPCICRbit(_receivePin));
|
||||
*digitalPinToPCMSK(_receivePin) |= _BV(digitalPinToPCMSKbit(_receivePin));
|
||||
setRxIntMsk(true);
|
||||
tunedDelay(_tx_delay); // if we were low this establishes the end
|
||||
}
|
||||
|
||||
@ -416,10 +419,18 @@ void SoftwareSerial::begin(long speed)
|
||||
listen();
|
||||
}
|
||||
|
||||
void SoftwareSerial::setRxIntMsk(bool enable)
|
||||
{
|
||||
if (enable)
|
||||
*digitalPinToPCMSK(_receivePin) |= _BV(digitalPinToPCMSKbit(_receivePin));
|
||||
else
|
||||
*digitalPinToPCMSK(_receivePin) &= ~_BV(digitalPinToPCMSKbit(_receivePin));
|
||||
}
|
||||
|
||||
void SoftwareSerial::end()
|
||||
{
|
||||
if (_rx_delay_stopbit)
|
||||
*digitalPinToPCMSK(_receivePin) &= ~_BV(digitalPinToPCMSKbit(_receivePin));
|
||||
setRxIntMsk(false);
|
||||
}
|
||||
|
||||
|
||||
|
@ -74,6 +74,7 @@ private:
|
||||
void tx_pin_write(uint8_t pin_state);
|
||||
void setTX(uint8_t transmitPin);
|
||||
void setRX(uint8_t receivePin);
|
||||
void setRxIntMsk(bool enable);
|
||||
|
||||
// private static method for timing
|
||||
static inline void tunedDelay(uint16_t delay);
|
||||
|
Loading…
x
Reference in New Issue
Block a user