Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add declaration to expose enable_* functions from SerialBase #14175

Merged
merged 3 commits into from
Jan 25, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 33 additions & 4 deletions drivers/include/drivers/UnbufferedSerial.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,35 @@ class UnbufferedSerial:
return 0;
}

/** Enable or disable input
*
* Control enabling of device for input. This is primarily intended
* for temporary power-saving; the overall ability of the device to operate
* for input and/or output may be fixed at creation time, but this call can
* allow input to be temporarily disabled to permit power saving without
* losing device state.
*
* @param enabled true to enable input, false to disable.
*
* @return 0 on success
harmut01 marked this conversation as resolved.
Show resolved Hide resolved
* @return Negative error code on failure
hugueskamba marked this conversation as resolved.
Show resolved Hide resolved
*/
int enable_input(bool enabled) override;

/** Enable or disable output
*
* Control enabling of device for output. This is primarily intended
* for temporary power-saving; the overall ability of the device to operate
* for input and/or output may be fixed at creation time, but this call can
* allow output to be temporarily disabled to permit power saving without
* losing device state.
*
* @param enabled true to enable output, false to disable.
*
* @return 0 on success
* @return Negative error code on failure
hugueskamba marked this conversation as resolved.
Show resolved Hide resolved
*/
int enable_output(bool enabled) override;

/** Check for poll event flags
* Check the events listed in events to see if data can be read or written
Expand All @@ -155,14 +184,14 @@ class UnbufferedSerial:
*/
short poll(short events) const override;

using SerialBase::readable;
using SerialBase::writeable;
using SerialBase::format;
using SerialBase::attach;
using SerialBase::baud;
using SerialBase::format;
using SerialBase::readable;
using SerialBase::writeable;
using SerialBase::IrqCnt;
using SerialBase::RxIrq;
using SerialBase::TxIrq;
using SerialBase::IrqCnt;

#if DEVICE_SERIAL_FC
// For now use the base enum - but in future we may have extra options
Expand Down
18 changes: 18 additions & 0 deletions drivers/source/UnbufferedSerial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,24 @@ short UnbufferedSerial::poll(short events) const
return revents;
}

int UnbufferedSerial::enable_input(bool enabled)
{
lock();
harmut01 marked this conversation as resolved.
Show resolved Hide resolved
SerialBase::enable_input(enabled);
unlock();

return 0;
}

int UnbufferedSerial::enable_output(bool enabled)
{
lock();
SerialBase::enable_output(enabled);
unlock();

return 0;
}

#if DEVICE_SERIAL_FC
void UnbufferedSerial::set_flow_control(Flow type, PinName flow1, PinName flow2)
{
Expand Down