Functions and data types for handling edge events.
More...
Functions and data types for handling edge events.
An edge event object contains information about a single line edge event. It contains the event type, timestamp and the offset of the line on which the event occurred as well as two sequence numbers (global for all lines in the associated request and local for this line only).
Edge events are stored into an edge-event buffer object to improve performance and to limit the number of memory allocations when a large number of events are being read.
◆ gpiod_edge_event_type
Event types.
Enumerator |
---|
GPIOD_EDGE_EVENT_RISING_EDGE | Rising edge event.
|
GPIOD_EDGE_EVENT_FALLING_EDGE | Falling edge event.
|
Definition at line 1190 of file gpiod.h.
◆ gpiod_edge_event_buffer_free()
Free the edge event buffer and release all associated resources.
- Parameters
-
buffer | Edge event buffer to free. |
◆ gpiod_edge_event_buffer_get_capacity()
Get the capacity (the max number of events that can be stored) of the event buffer.
- Parameters
-
- Returns
- The capacity of the buffer.
◆ gpiod_edge_event_buffer_get_event()
Get an event stored in the buffer.
- Parameters
-
buffer | Edge event buffer. |
index | Index of the event in the buffer. |
- Returns
- Pointer to an event stored in the buffer. The lifetime of the event is tied to the buffer object. Users must not free the event returned by this function.
◆ gpiod_edge_event_buffer_get_num_events()
Get the number of events a buffer has stored.
- Parameters
-
- Returns
- Number of events stored in the buffer.
◆ gpiod_edge_event_buffer_new()
Create a new edge event buffer.
- Parameters
-
capacity | Number of events the buffer can store (min = 1, max = 1024). |
- Returns
- New edge event buffer or NULL on error.
- Note
- If capacity equals 0, it will be set to a default value of 64. If capacity is larger than 1024, it will be limited to 1024.
-
The user space buffer is independent of the kernel buffer (gpiod_request_config_set_event_buffer_size). As the user space buffer is filled from the kernel buffer, there is no benefit making the user space buffer larger than the kernel buffer. The default kernel buffer size for each request is (16 * num_lines).
◆ gpiod_edge_event_copy()
Copy the edge event object.
- Parameters
-
- Returns
- Copy of the edge event or NULL on error. The returned object must be freed by the caller using gpiod_edge_event_free.
◆ gpiod_edge_event_free()
Free the edge event object.
- Parameters
-
event | Edge event object to free. |
◆ gpiod_edge_event_get_event_type()
◆ gpiod_edge_event_get_global_seqno()
unsigned long gpiod_edge_event_get_global_seqno |
( |
struct gpiod_edge_event * |
event | ) |
|
Get the global sequence number of the event.
- Parameters
-
- Returns
- Sequence number of the event in the series of events for all lines in the associated line request.
◆ gpiod_edge_event_get_line_offset()
unsigned int gpiod_edge_event_get_line_offset |
( |
struct gpiod_edge_event * |
event | ) |
|
Get the offset of the line which triggered the event.
- Parameters
-
- Returns
- Line offset.
◆ gpiod_edge_event_get_line_seqno()
unsigned long gpiod_edge_event_get_line_seqno |
( |
struct gpiod_edge_event * |
event | ) |
|
Get the event sequence number specific to the line.
- Parameters
-
- Returns
- Sequence number of the event in the series of events only for this line within the lifetime of the associated line request.
◆ gpiod_edge_event_get_timestamp_ns()
Get the timestamp of the event.
- Parameters
-
- Returns
- Timestamp in nanoseconds.
- Note
- The source clock for the timestamp depends on the event_clock setting for the line.