Skip to content

Commit

Permalink
Add enable API to FileHandle
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
kjbracey committed Feb 21, 2019
1 parent 95906f1 commit e96d658
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions platform/FileHandle.h
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,42 @@ class FileHandle : private NonCopyable<FileHandle> {
return true;
}

/** 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
*/
virtual int enable_input(bool enabled)
{
return -EINVAL;
}

/** 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
*/
virtual int enable_output(bool enabled)
{
return -EINVAL;
}

/** Check for poll event flags
* You can use or ignore the input parameter. You can return all events
* or check just the events listed in events.
Expand Down

0 comments on commit e96d658

Please sign in to comment.