Skip to content

Commit d5d6cdb

Browse files
author
Sebastian Stockhammer
committed
Retain flow control state
1 parent 462d3a5 commit d5d6cdb

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

drivers/SerialBase.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,15 @@ SerialBase::SerialBase(PinName tx, PinName rx, int baud) :
3030
_rx_callback(NULL), _tx_asynch_set(false),
3131
_rx_asynch_set(false),
3232
#endif
33-
_serial(), _baud(baud), _rx_enabled(true), _tx_enabled(true), _tx_pin(tx), _rx_pin(rx)
33+
_serial(),
34+
_baud(baud),
35+
_rx_enabled(true),
36+
_tx_enabled(true),
37+
_tx_pin(tx),
38+
_rx_pin(rx),
39+
_flow_type(Disabled),
40+
_flow1(NC),
41+
_flow2(NC)
3442
{
3543
// No lock needed in the constructor
3644

@@ -121,6 +129,7 @@ int SerialBase::_base_putc(int c)
121129
void SerialBase::_init()
122130
{
123131
serial_init(&_serial, _tx_pin, _rx_pin);
132+
set_flow_control(_flow_type, _flow1, _flow2);
124133
serial_baud(&_serial, _baud);
125134
serial_irq_handler(&_serial, SerialBase::_irq_handler, (uint32_t)this);
126135
}

drivers/SerialBase.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,9 @@ class SerialBase : private NonCopyable<SerialBase> {
340340
bool _tx_enabled;
341341
const PinName _tx_pin;
342342
const PinName _rx_pin;
343+
Flow _flow_type;
344+
PinName _flow1;
345+
PinName _flow2;
343346
#endif
344347
};
345348

drivers/UARTSerial.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ void UARTSerial::set_format(int bits, Parity parity, int stop_bits)
8282
void UARTSerial::set_flow_control(Flow type, PinName flow1, PinName flow2)
8383
{
8484
api_lock();
85+
_flow_type = type;
86+
_flow1 = flow1;
87+
_flow2 = flow2;
8588
SerialBase::set_flow_control(type, flow1, flow2);
8689
api_unlock();
8790
}

0 commit comments

Comments
 (0)