1
0
mirror of https://github.com/arduino/Arduino.git synced 2024-12-11 22:24:13 +01:00

Fix idle level when initializing a inverted SoftwareSerial

Previously, when SoftwareSerial was initialized, it would always be set
to an idle level of HIGH, even when inverted logic was enabled. Once a
byte is transmitted, the idle level gets correctly set to LOW instead.
This commit makes sure that the idle level is correct directly after
initialization already.

This fixes #1361.
This commit is contained in:
Jens-Christian Skibakk 2014-05-23 11:29:30 +02:00
parent 9ad8748d40
commit 17e1eb5ef2

View File

@ -355,7 +355,7 @@ SoftwareSerial::~SoftwareSerial()
void SoftwareSerial::setTX(uint8_t tx) void SoftwareSerial::setTX(uint8_t tx)
{ {
pinMode(tx, OUTPUT); pinMode(tx, OUTPUT);
digitalWrite(tx, HIGH); digitalWrite(tx, _inverse_logic ? LOW : HIGH);
_transmitBitMask = digitalPinToBitMask(tx); _transmitBitMask = digitalPinToBitMask(tx);
uint8_t port = digitalPinToPort(tx); uint8_t port = digitalPinToPort(tx);
_transmitPortRegister = portOutputRegister(port); _transmitPortRegister = portOutputRegister(port);