Functions and data structures for requesting and reading GPIO line events.
More...
|
int | gpiod_line_event_request (struct gpiod_line *line, struct gpiod_line_evreq_config *config) GPIOD_API |
| Request event notifications for a single line. More...
|
|
int | gpiod_line_event_request_rising (struct gpiod_line *line, const char *consumer, bool active_low) GPIOD_API |
| Request rising edge event notifications on a single line. More...
|
|
int | gpiod_line_event_request_falling (struct gpiod_line *line, const char *consumer, bool active_low) GPIOD_API |
| Request falling edge event notifications on a single line. More...
|
|
int | gpiod_line_event_request_all (struct gpiod_line *line, const char *consumer, bool active_low) GPIOD_API |
| Request all event type notifications on a single line. More...
|
|
void | gpiod_line_event_release (struct gpiod_line *line) GPIOD_API |
| Stop listening for events and release the line. More...
|
|
bool | gpiod_line_event_configured (struct gpiod_line *line) GPIOD_API |
| Check if event notifications are configured on this line. More...
|
|
int | gpiod_line_event_wait (struct gpiod_line *line, const struct timespec *timeout) GPIOD_API |
| Wait for an event on a single line. More...
|
|
int | gpiod_line_event_wait_bulk (struct gpiod_line_bulk *bulk, const struct timespec *timeout, struct gpiod_line **line) GPIOD_API |
| Wait for the first event on a set of lines. More...
|
|
int | gpiod_line_event_read (struct gpiod_line *line, struct gpiod_line_event *event) GPIOD_API |
| Read the last event from the GPIO line. More...
|
|
int | gpiod_line_event_get_fd (struct gpiod_line *line) GPIOD_API |
| Get the event file descriptor. More...
|
|
int | gpiod_line_event_read_fd (int fd, struct gpiod_line_event *event) GPIOD_API |
| Read the last GPIO event directly from a file descriptor. More...
|
|
Functions and data structures for requesting and reading GPIO line events.
◆ anonymous enum
Event types.
Enumerator |
---|
GPIOD_EVENT_RISING_EDGE | Rising edge event.
|
GPIOD_EVENT_FALLING_EDGE | Falling edge event.
|
GPIOD_EVENT_BOTH_EDGES | Rising or falling edge event: only relevant for event requests.
|
Definition at line 626 of file gpiod.h.
◆ gpiod_line_event_configured()
bool gpiod_line_event_configured |
( |
struct gpiod_line * |
line | ) |
|
Check if event notifications are configured on this line.
- Parameters
-
- Returns
- True if event notifications are configured. False otherwise.
◆ gpiod_line_event_get_fd()
int gpiod_line_event_get_fd |
( |
struct gpiod_line * |
line | ) |
|
Get the event file descriptor.
- Parameters
-
- Returns
- Number of the event file descriptor or -1 on error.
Users may want to poll the event file descriptor on their own. This routine allows to access it.
◆ gpiod_line_event_read()
int gpiod_line_event_read |
( |
struct gpiod_line * |
line, |
|
|
struct gpiod_line_event * |
event |
|
) |
| |
Read the last event from the GPIO line.
- Parameters
-
line | GPIO line object. |
event | Buffer to which the event data will be copied. |
- Returns
- 0 if the event was read correctly, -1 on error.
◆ gpiod_line_event_read_fd()
Read the last GPIO event directly from a file descriptor.
- Parameters
-
fd | File descriptor. |
event | Buffer to which the event data will be copied. |
- Returns
- 0 if the event was read correctly, -1 on error.
Users who directly poll the file descriptor for incoming events can also directly read the event data from it using this routine. This function translates the kernel representation of the event to the libgpiod format.
◆ gpiod_line_event_release()
void gpiod_line_event_release |
( |
struct gpiod_line * |
line | ) |
|
Stop listening for events and release the line.
- Parameters
-
◆ gpiod_line_event_request()
Request event notifications for a single line.
- Parameters
-
line | GPIO line object. |
config | Event request configuration. |
- Returns
- 0 if the operation succeeds. In case of an error this routine returns -1 and sets the last error number.
◆ gpiod_line_event_request_all()
int gpiod_line_event_request_all |
( |
struct gpiod_line * |
line, |
|
|
const char * |
consumer, |
|
|
bool |
active_low |
|
) |
| |
Request all event type notifications on a single line.
- Parameters
-
line | GPIO line object. |
consumer | Name of the consumer. |
active_low | Active state of the line - true if low. |
- Returns
- 0 if the operation succeeds, -1 on failure.
◆ gpiod_line_event_request_falling()
int gpiod_line_event_request_falling |
( |
struct gpiod_line * |
line, |
|
|
const char * |
consumer, |
|
|
bool |
active_low |
|
) |
| |
Request falling edge event notifications on a single line.
- Parameters
-
line | GPIO line object. |
consumer | Name of the consumer. |
active_low | Active state of the line - true if low. |
- Returns
- 0 if the operation succeeds, -1 on failure.
◆ gpiod_line_event_request_rising()
int gpiod_line_event_request_rising |
( |
struct gpiod_line * |
line, |
|
|
const char * |
consumer, |
|
|
bool |
active_low |
|
) |
| |
Request rising edge event notifications on a single line.
- Parameters
-
line | GPIO line object. |
consumer | Name of the consumer. |
active_low | Active state of the line - true if low. |
- Returns
- 0 if the operation succeeds, -1 on failure.
◆ gpiod_line_event_wait()
int gpiod_line_event_wait |
( |
struct gpiod_line * |
line, |
|
|
const struct timespec * |
timeout |
|
) |
| |
Wait for an event on a single line.
- Parameters
-
line | GPIO line object. |
timeout | Wait time limit. |
- Returns
- 0 if wait timed out, -1 if an error occurred, 1 if an event occurred.
◆ gpiod_line_event_wait_bulk()
int gpiod_line_event_wait_bulk |
( |
struct gpiod_line_bulk * |
bulk, |
|
|
const struct timespec * |
timeout, |
|
|
struct gpiod_line ** |
line |
|
) |
| |
Wait for the first event on a set of lines.
- Parameters
-
bulk | Set of GPIO lines to monitor. |
timeout | Wait time limit. |
line | The handle of the line on which an event occurs is stored in this variable. Can be NULL. |
- Returns
- 0 if wait timed out, -1 if an error occurred, 1 if an event occurred.