Implement override of enable_* functions

pull/14175/head
Harrison Mutai 2021-01-21 10:20:49 +00:00
parent 7b8ca37bd7
commit 0214a156e7
2 changed files with 47 additions and 2 deletions

View File

@ -143,6 +143,35 @@ public:
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
* @return Negative error code on failure
*/
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
*/
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
@ -157,8 +186,6 @@ public:
using SerialBase::attach;
using SerialBase::baud;
using SerialBase::enable_input;
using SerialBase::enable_output;
using SerialBase::format;
using SerialBase::readable;
using SerialBase::writeable;

View File

@ -99,6 +99,24 @@ short UnbufferedSerial::poll(short events) const
return revents;
}
int UnbufferedSerial::enable_input(bool enabled)
{
lock();
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)
{