Skip to content

Commit

Permalink
Retain flow control state
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian Stockhammer committed Aug 26, 2019
1 parent 462d3a5 commit d5d6cdb
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
11 changes: 10 additions & 1 deletion drivers/SerialBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,15 @@ SerialBase::SerialBase(PinName tx, PinName rx, int baud) :
_rx_callback(NULL), _tx_asynch_set(false),
_rx_asynch_set(false),
#endif
_serial(), _baud(baud), _rx_enabled(true), _tx_enabled(true), _tx_pin(tx), _rx_pin(rx)
_serial(),
_baud(baud),
_rx_enabled(true),
_tx_enabled(true),
_tx_pin(tx),
_rx_pin(rx),
_flow_type(Disabled),
_flow1(NC),
_flow2(NC)
{
// No lock needed in the constructor

Expand Down Expand Up @@ -121,6 +129,7 @@ int SerialBase::_base_putc(int c)
void SerialBase::_init()
{
serial_init(&_serial, _tx_pin, _rx_pin);
set_flow_control(_flow_type, _flow1, _flow2);
serial_baud(&_serial, _baud);
serial_irq_handler(&_serial, SerialBase::_irq_handler, (uint32_t)this);
}
Expand Down
3 changes: 3 additions & 0 deletions drivers/SerialBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,9 @@ class SerialBase : private NonCopyable<SerialBase> {
bool _tx_enabled;
const PinName _tx_pin;
const PinName _rx_pin;
Flow _flow_type;
PinName _flow1;
PinName _flow2;
#endif
};

Expand Down
3 changes: 3 additions & 0 deletions drivers/UARTSerial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ void UARTSerial::set_format(int bits, Parity parity, int stop_bits)
void UARTSerial::set_flow_control(Flow type, PinName flow1, PinName flow2)
{
api_lock();
_flow_type = type;
_flow1 = flow1;
_flow2 = flow2;
SerialBase::set_flow_control(type, flow1, flow2);
api_unlock();
}
Expand Down

0 comments on commit d5d6cdb

Please sign in to comment.