From e96d6581db9522cd8b81a0d31ff425f302033b15 Mon Sep 17 00:00:00 2001 From: Kevin Bracey Date: Thu, 21 Feb 2019 16:41:48 +0200 Subject: [PATCH] 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. --- platform/FileHandle.h | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/platform/FileHandle.h b/platform/FileHandle.h index cbaf694e3e..5488169667 100644 --- a/platform/FileHandle.h +++ b/platform/FileHandle.h @@ -220,6 +220,42 @@ public: 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.