Simple high-level routines for straightforward GPIO manipulation without the need to use the gpiod_* structures or to keep track of resources.
More...
|
int | gpiod_ctxless_get_value (const char *device, unsigned int offset, bool active_low, const char *consumer) GPIOD_API |
| Read current value from a single GPIO line. More...
|
|
int | gpiod_ctxless_get_value_multiple (const char *device, const unsigned int *offsets, int *values, unsigned int num_lines, bool active_low, const char *consumer) GPIOD_API |
| Read current values from a set of GPIO lines. More...
|
|
int | gpiod_ctxless_set_value (const char *device, unsigned int offset, int value, bool active_low, const char *consumer, gpiod_ctxless_set_value_cb cb, void *data) GPIOD_API |
| Set value of a single GPIO line. More...
|
|
int | gpiod_ctxless_set_value_multiple (const char *device, const unsigned int *offsets, const int *values, unsigned int num_lines, bool active_low, const char *consumer, gpiod_ctxless_set_value_cb cb, void *data) GPIOD_API |
| Set values of multiple GPIO lines. More...
|
|
int | gpiod_ctxless_event_loop (const char *device, unsigned int offset, bool active_low, const char *consumer, const struct timespec *timeout, gpiod_ctxless_event_poll_cb poll_cb, gpiod_ctxless_event_handle_cb event_cb, void *data) GPIOD_API GPIOD_DEPRECATED |
| Wait for events on a single GPIO line. More...
|
|
int | gpiod_ctxless_event_loop_multiple (const char *device, const unsigned int *offsets, unsigned int num_lines, bool active_low, const char *consumer, const struct timespec *timeout, gpiod_ctxless_event_poll_cb poll_cb, gpiod_ctxless_event_handle_cb event_cb, void *data) GPIOD_API GPIOD_DEPRECATED |
| Wait for events on multiple GPIO lines. More...
|
|
int | gpiod_ctxless_event_monitor (const char *device, int event_type, unsigned int offset, bool active_low, const char *consumer, const struct timespec *timeout, gpiod_ctxless_event_poll_cb poll_cb, gpiod_ctxless_event_handle_cb event_cb, void *data) GPIOD_API |
| Wait for events on a single GPIO line. More...
|
|
int | gpiod_ctxless_event_monitor_multiple (const char *device, int event_type, const unsigned int *offsets, unsigned int num_lines, bool active_low, const char *consumer, const struct timespec *timeout, gpiod_ctxless_event_poll_cb poll_cb, gpiod_ctxless_event_handle_cb event_cb, void *data) GPIOD_API |
| Wait for events on multiple GPIO lines. More...
|
|
int | gpiod_ctxless_find_line (const char *name, char *chipname, size_t chipname_size, unsigned int *offset) GPIOD_API |
| Determine the chip name and line offset of a line with given name. More...
|
|
Simple high-level routines for straightforward GPIO manipulation without the need to use the gpiod_* structures or to keep track of resources.
typedef int(* gpiod_ctxless_event_handle_cb) (int, unsigned int, const struct timespec *, void *) |
Simple event callback signature.
The callback function takes the following arguments: event type (int), GPIO line offset (unsigned int), event timestamp (const struct timespec *) and a pointer to user data (void *).
This callback is called by the ctxless event loop functions for each GPIO event. If the callback returns GPIOD_CTXLESS_EVENT_CB_RET_ERR, it should also set errno.
Definition at line 203 of file gpiod.h.
Simple event poll callback signature.
The poll callback function takes the following arguments: number of lines (unsigned int), an array of file descriptors on which input events should be monitored (struct gpiod_ctxless_event_poll_fd *), poll timeout (const struct timespec *) and a pointer to user data (void *).
The callback should poll for input events on the set of descriptors and return an appropriate value that can be interpreted by the event loop routine.
Definition at line 243 of file gpiod.h.
Wait for events on multiple GPIO lines.
- Parameters
-
device | Name, path, number or label of the gpiochip. |
offsets | Array of GPIO line offsets to monitor. |
num_lines | Number of lines to monitor. |
active_low | The active state of this line - true if low. |
consumer | Name of the consumer. |
timeout | Maximum wait time for each iteration. |
poll_cb | Callback function to call when waiting for events. Can be NULL. |
event_cb | Callback function to call on event occurrence. |
data | User data passed to the callback. |
- Returns
- 0 no errors were encountered, -1 if an error occurred.
- Note
- The poll callback can be NULL in which case the routine will fall back to a basic, ppoll() based callback.
Internally this routine opens the GPIO chip, requests the set of lines for both-edges events and calls the polling callback in a loop. The role of the polling callback is to detect input events on a set of file descriptors and notify the caller about the fds ready for reading.
The ctxless event loop then reads each queued event from marked descriptors and calls the event callback. Both callbacks can stop the loop at any point.
The poll_cb argument can be NULL in which case the function falls back to a default, ppoll() based callback.
int gpiod_ctxless_event_monitor_multiple |
( |
const char * |
device, |
|
|
int |
event_type, |
|
|
const unsigned int * |
offsets, |
|
|
unsigned int |
num_lines, |
|
|
bool |
active_low, |
|
|
const char * |
consumer, |
|
|
const struct timespec * |
timeout, |
|
|
gpiod_ctxless_event_poll_cb |
poll_cb, |
|
|
gpiod_ctxless_event_handle_cb |
event_cb, |
|
|
void * |
data |
|
) |
| |
Wait for events on multiple GPIO lines.
- Parameters
-
device | Name, path, number or label of the gpiochip. |
event_type | Type of events to listen for. |
offsets | Array of GPIO line offsets to monitor. |
num_lines | Number of lines to monitor. |
active_low | The active state of this line - true if low. |
consumer | Name of the consumer. |
timeout | Maximum wait time for each iteration. |
poll_cb | Callback function to call when waiting for events. Can be NULL. |
event_cb | Callback function to call on event occurrence. |
data | User data passed to the callback. |
- Returns
- 0 no errors were encountered, -1 if an error occurred.
- Note
- The poll callback can be NULL in which case the routine will fall back to a basic, ppoll() based callback.
Internally this routine opens the GPIO chip, requests the set of lines for the type of events specified in the event_type paramter and calls the polling callback in a loop. The role of the polling callback is to detect input events on a set of file descriptors and notify the caller about the fds ready for reading.
The ctxless event loop then reads each queued event from marked descriptors and calls the event callback. Both callbacks can stop the loop at any point.
The poll_cb argument can be NULL in which case the function falls back to a default, ppoll() based callback.