Skip to content

Commit 31babca

Browse files
author
Sebastian Stockhammer
committed
Retain flow control state
1 parent 37b54ca commit 31babca

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

drivers/SerialBase.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,9 @@ class SerialBase : private NonCopyable<SerialBase> {
344344
bool _tx_enabled;
345345
const PinName _tx_pin;
346346
const PinName _rx_pin;
347+
Flow _flow_type;
348+
PinName _flow1;
349+
PinName _flow2;
347350
#endif
348351
};
349352

drivers/source/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/source/UARTSerial.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ void UARTSerial::set_format(int bits, Parity parity, int stop_bits)
7777
void UARTSerial::set_flow_control(Flow type, PinName flow1, PinName flow2)
7878
{
7979
api_lock();
80+
_flow_type = type;
81+
_flow1 = flow1;
82+
_flow2 = flow2;
8083
SerialBase::set_flow_control(type, flow1, flow2);
8184
api_unlock();
8285
}

0 commit comments

Comments
 (0)