diff --git a/drivers/include/drivers/UnbufferedSerial.h b/drivers/include/drivers/UnbufferedSerial.h index 73a94a45cc..a330d6e92b 100644 --- a/drivers/include/drivers/UnbufferedSerial.h +++ b/drivers/include/drivers/UnbufferedSerial.h @@ -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; diff --git a/drivers/source/UnbufferedSerial.cpp b/drivers/source/UnbufferedSerial.cpp index 56b19f8327..c8e081d021 100644 --- a/drivers/source/UnbufferedSerial.cpp +++ b/drivers/source/UnbufferedSerial.cpp @@ -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) {