File tree Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -360,6 +360,9 @@ void SoftwareSerial::setTX(uint8_t tx)
360360 // if rx and tx shares a pin, only set pin to output when writing
361361 if (!_sharedRxTx){
362362 pinMode (tx, OUTPUT);
363+
364+ // @edbaafi - if inverse logic is allowed, why would line rest high
365+ // regardless if _invers_logic is set? Was inverse logic added for rx-only?
363366 digitalWrite (tx, HIGH);
364367 }
365368 _transmitBitMask = digitalPinToBitMask (tx);
@@ -498,11 +501,25 @@ size_t SoftwareSerial::write(uint8_t b)
498501
499502 tx_pin_write (HIGH); // restore pin to natural state
500503 }
504+
505+ // if rx and tx shares a pin, set back to input when done writing
501506 if (_sharedRxTx){
502507
503508 pinMode (_receivePin, INPUT);
504- if (!_inverse_logic)
509+ if (!_inverse_logic){
510+ // @edbaafi - PORTx is already set to high for this pin
511+ // //but given questions about rest states when inverse logic, I'll leave this for clarity
505512 digitalWrite (_receivePin, HIGH); // pullup for normal logic!
513+ }
514+ else {
515+ // disable pullup
516+
517+ // @edbaafi - don't think this is happening by default by setting pinMode alone
518+ // //Haven't followed pinMode->portModeRegister->even_more_indirection but it appears to
519+ // //simply set DDRB without initializing PORTx and previous (rest) state is HIGH
520+ // //(even when inverse logic - see questions above)
521+ digitalWrite (_receivePin,LOW);
522+ }
506523 }
507524
508525 SREG = oldSREG; // turn interrupts back on
You can’t perform that action at this time.
0 commit comments