File tree 1 file changed +11
-6
lines changed
libraries/SoftwareSerial/src
1 file changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -35,6 +35,8 @@ The latest version of this library can always be found at
35
35
#define _DEBUG 0
36
36
#define _DEBUG_PIN1 11
37
37
#define _DEBUG_PIN2 13
38
+
39
+ #define HALFDUPLEX_SWITCH_DELAY 5
38
40
//
39
41
// Includes
40
42
//
@@ -93,8 +95,6 @@ bool SoftwareSerial::listen()
93
95
{
94
96
if (active_object)
95
97
active_object->stopListening ();
96
- if (_singleWirePin)
97
- setupRXPin (_singleWirePin);
98
98
99
99
_buffer_overflow = false ;
100
100
_receive_buffer_head = _receive_buffer_tail = 0 ;
@@ -393,7 +393,7 @@ void SoftwareSerial::begin(long speed)
393
393
pinMode (_DEBUG_PIN2, OUTPUT);
394
394
#endif
395
395
396
- // Single-wire will be in TX mode by default
396
+ // Single-wire will not listen by default
397
397
if (!_singleWirePin)
398
398
listen ();
399
399
}
@@ -439,7 +439,7 @@ int SoftwareSerial::available()
439
439
size_t SoftwareSerial::write (uint8_t b)
440
440
{
441
441
if (_singleWirePin && isListening ())
442
- return 0 ;
442
+ setupTXPin () ;
443
443
444
444
if (_tx_delay == 0 ) {
445
445
setWriteError ();
@@ -489,8 +489,13 @@ size_t SoftwareSerial::write(uint8_t b)
489
489
*reg |= reg_mask;
490
490
491
491
SREG = oldSREG; // turn interrupts back on
492
- tunedDelay (_tx_delay);
493
-
492
+
493
+ if (!_singleWirePin)
494
+ tunedDelay (_tx_delay);
495
+ else if (isListening ()) {
496
+ tunedDelay (_tx_delay * HALFDUPLEX_SWITCH_DELAY);
497
+ setupRXPin (_singleWirePin);
498
+ }
494
499
return 1 ;
495
500
}
496
501
You can’t perform that action at this time.
0 commit comments