diff options
author | Bertrand SIMONNET <bsimonnet@google.com> | 2016-03-07 14:22:09 -0800 |
---|---|---|
committer | Bertrand Simonnet <bsimonnet@google.com> | 2016-03-10 21:01:57 +0000 |
commit | d3cafe115bdde62957bd3b95fd000e6dae1b1c49 (patch) | |
tree | 05f16cb18c36f2423310fb523b0e7834bf58807b /include | |
parent | 0a407224a1e2b6f15fb56386f8a2633a703417e3 (diff) | |
download | peripheralmanager-d3cafe115bdde62957bd3b95fd000e6dae1b1c49.tar.gz |
Add a helper to acknowledge a GPIO interrupt.
When an interrupt triggers on a GPIO, we must lseek and read the value
in order to be able to poll again. As we don't guarantee that the file
descriptor we use to poll will be the value file, add a convenience
function to reset the file descriptor's state.
To illustrate how to use it, we provide an example that will watch a
GPIO for interrupt and print a message when the GPIO's value changes.
This is implemented with both select and poll.
Bug: 26778811
Change-Id: Ib25338599a8e08d7734839171da6204bb64a2ded
Diffstat (limited to 'include')
-rw-r--r-- | include/peripheralmanager/gpio.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/include/peripheralmanager/gpio.h b/include/peripheralmanager/gpio.h index 28989ea..de5bfdd 100644 --- a/include/peripheralmanager/gpio.h +++ b/include/peripheralmanager/gpio.h @@ -91,6 +91,13 @@ int BGpio_getValue(const BGpio* gpio, int* value); /// @return Error code (one of peripheral_error_t). int BGpio_getPollingFd(const BGpio* gpio, int* fd); +/// Acknowledges the interrupt and resets the file descriptor. +/// This must be called after each event triggers in order to be able to +/// poll/select for another event. +/// @param fd Polling file descriptor to reset. +/// @return 0 on success, errno on error. +int BGpio_ackInterruptEvent(int fd); + /// Destroys a BGpio struct. /// @param gpio Pointer to the BGpio struct. void BGpio_delete(BGpio* gpio); |