Skip to content

Commit 0214a15

Browse files
Implement override of enable_* functions
1 parent 7b8ca37 commit 0214a15

File tree

2 files changed

+47
-2
lines changed

2 files changed

+47
-2
lines changed

drivers/include/drivers/UnbufferedSerial.h

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,35 @@ class UnbufferedSerial:
143143
return 0;
144144
}
145145

146+
/** Enable or disable input
147+
*
148+
* Control enabling of device for input. This is primarily intended
149+
* for temporary power-saving; the overall ability of the device to operate
150+
* for input and/or output may be fixed at creation time, but this call can
151+
* allow input to be temporarily disabled to permit power saving without
152+
* losing device state.
153+
*
154+
* @param enabled true to enable input, false to disable.
155+
*
156+
* @return 0 on success
157+
* @return Negative error code on failure
158+
*/
159+
int enable_input(bool enabled) override;
160+
161+
/** Enable or disable output
162+
*
163+
* Control enabling of device for output. This is primarily intended
164+
* for temporary power-saving; the overall ability of the device to operate
165+
* for input and/or output may be fixed at creation time, but this call can
166+
* allow output to be temporarily disabled to permit power saving without
167+
* losing device state.
168+
*
169+
* @param enabled true to enable output, false to disable.
170+
*
171+
* @return 0 on success
172+
* @return Negative error code on failure
173+
*/
174+
int enable_output(bool enabled) override;
146175

147176
/** Check for poll event flags
148177
* Check the events listed in events to see if data can be read or written
@@ -157,8 +186,6 @@ class UnbufferedSerial:
157186

158187
using SerialBase::attach;
159188
using SerialBase::baud;
160-
using SerialBase::enable_input;
161-
using SerialBase::enable_output;
162189
using SerialBase::format;
163190
using SerialBase::readable;
164191
using SerialBase::writeable;

drivers/source/UnbufferedSerial.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,24 @@ short UnbufferedSerial::poll(short events) const
9999
return revents;
100100
}
101101

102+
int UnbufferedSerial::enable_input(bool enabled)
103+
{
104+
lock();
105+
SerialBase::enable_input(enabled);
106+
unlock();
107+
108+
return 0;
109+
}
110+
111+
int UnbufferedSerial::enable_output(bool enabled)
112+
{
113+
lock();
114+
SerialBase::enable_output(enabled);
115+
unlock();
116+
117+
return 0;
118+
}
119+
102120
#if DEVICE_SERIAL_FC
103121
void UnbufferedSerial::set_flow_control(Flow type, PinName flow1, PinName flow2)
104122
{

0 commit comments

Comments
 (0)