diff options
-rw-r--r-- | libraries/SoftwareSerial/SoftwareSerial.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/libraries/SoftwareSerial/SoftwareSerial.cpp b/libraries/SoftwareSerial/SoftwareSerial.cpp index b7dc5c2..527f3f9 100644 --- a/libraries/SoftwareSerial/SoftwareSerial.cpp +++ b/libraries/SoftwareSerial/SoftwareSerial.cpp @@ -266,8 +266,12 @@ SoftwareSerial::~SoftwareSerial() void SoftwareSerial::setTX(uint8_t tx)
{
- pinMode(tx, OUTPUT);
+ // First write, then set output. If we do this the other way around,
+ // the pin would be output low for a short while before switching to
+ // output hihg. Now, it is input with pullup for a short while, which
+ // is fine. With inverse logic, either order is fine.
digitalWrite(tx, _inverse_logic ? LOW : HIGH);
+ pinMode(tx, OUTPUT);
_transmitBitMask = digitalPinToBitMask(tx);
uint8_t port = digitalPinToPort(tx);
_transmitPortRegister = portOutputRegister(port);
|