Skip to content

Commit e96d658

Browse files
committed
Add enable API to FileHandle
Add API to dynamically enable/disable input and output on FileHandles. Aim is to allow power saving by indicating that we permanently or temporarily do not require input, so that for example serial Rx interrupts can be released, and deep sleep permitted.
1 parent 95906f1 commit e96d658

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

platform/FileHandle.h

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,42 @@ class FileHandle : private NonCopyable<FileHandle> {
220220
return true;
221221
}
222222

223+
/** Enable or disable input
224+
*
225+
* Control enabling of device for input. This is primarily intended
226+
* for temporary power-saving; the overall ability of the device to operate for
227+
* input and/or output may be fixed at creation time, but this call can
228+
* allow input to be temporarily disabled to permit power saving without
229+
* losing device state.
230+
*
231+
* @param enabled true to enable input, false to disable.
232+
*
233+
* @return 0 on success
234+
* @return Negative error code on failure
235+
*/
236+
virtual int enable_input(bool enabled)
237+
{
238+
return -EINVAL;
239+
}
240+
241+
/** Enable or disable output
242+
*
243+
* Control enabling of device for output. This is primarily intended
244+
* for temporary power-saving; the overall ability of the device to operate for
245+
* input and/or output may be fixed at creation time, but this call can
246+
* allow output to be temporarily disabled to permit power saving without
247+
* losing device state.
248+
*
249+
* @param enabled true to enable output, false to disable.
250+
*
251+
* @return 0 on success
252+
* @return Negative error code on failure
253+
*/
254+
virtual int enable_output(bool enabled)
255+
{
256+
return -EINVAL;
257+
}
258+
223259
/** Check for poll event flags
224260
* You can use or ignore the input parameter. You can return all events
225261
* or check just the events listed in events.

0 commit comments

Comments
 (0)