libgpiod  2.0.1
Enumerations | Functions
Line edge events handling

Functions and data types for handling edge events. More...

Enumerations

enum  gpiod_edge_event_type { GPIOD_EDGE_EVENT_RISING_EDGE = 1 , GPIOD_EDGE_EVENT_FALLING_EDGE }
 Event types. More...
 

Functions

void gpiod_edge_event_free (struct gpiod_edge_event *event)
 Free the edge event object. More...
 
struct gpiod_edge_eventgpiod_edge_event_copy (struct gpiod_edge_event *event)
 Copy the edge event object. More...
 
enum gpiod_edge_event_type gpiod_edge_event_get_event_type (struct gpiod_edge_event *event)
 Get the event type. More...
 
uint64_t gpiod_edge_event_get_timestamp_ns (struct gpiod_edge_event *event)
 Get the timestamp of the event. More...
 
unsigned int gpiod_edge_event_get_line_offset (struct gpiod_edge_event *event)
 Get the offset of the line which triggered the event. More...
 
unsigned long gpiod_edge_event_get_global_seqno (struct gpiod_edge_event *event)
 Get the global sequence number of the event. More...
 
unsigned long gpiod_edge_event_get_line_seqno (struct gpiod_edge_event *event)
 Get the event sequence number specific to the line. More...
 
struct gpiod_edge_event_buffergpiod_edge_event_buffer_new (size_t capacity)
 Create a new edge event buffer. More...
 
size_t gpiod_edge_event_buffer_get_capacity (struct gpiod_edge_event_buffer *buffer)
 Get the capacity (the max number of events that can be stored) of the event buffer. More...
 
void gpiod_edge_event_buffer_free (struct gpiod_edge_event_buffer *buffer)
 Free the edge event buffer and release all associated resources. More...
 
struct gpiod_edge_eventgpiod_edge_event_buffer_get_event (struct gpiod_edge_event_buffer *buffer, unsigned long index)
 Get an event stored in the buffer. More...
 
size_t gpiod_edge_event_buffer_get_num_events (struct gpiod_edge_event_buffer *buffer)
 Get the number of events a buffer has stored. More...
 

Detailed Description

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.

Enumeration Type Documentation

◆ 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.

Function Documentation

◆ gpiod_edge_event_buffer_free()

void gpiod_edge_event_buffer_free ( struct gpiod_edge_event_buffer buffer)

Free the edge event buffer and release all associated resources.

Parameters
bufferEdge event buffer to free.

◆ gpiod_edge_event_buffer_get_capacity()

size_t gpiod_edge_event_buffer_get_capacity ( struct gpiod_edge_event_buffer buffer)

Get the capacity (the max number of events that can be stored) of the event buffer.

Parameters
bufferEdge event buffer.
Returns
The capacity of the buffer.

◆ gpiod_edge_event_buffer_get_event()

struct gpiod_edge_event* gpiod_edge_event_buffer_get_event ( struct gpiod_edge_event_buffer buffer,
unsigned long  index 
)

Get an event stored in the buffer.

Parameters
bufferEdge event buffer.
indexIndex 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()

size_t gpiod_edge_event_buffer_get_num_events ( struct gpiod_edge_event_buffer buffer)

Get the number of events a buffer has stored.

Parameters
bufferEdge event buffer.
Returns
Number of events stored in the buffer.

◆ gpiod_edge_event_buffer_new()

struct gpiod_edge_event_buffer* gpiod_edge_event_buffer_new ( size_t  capacity)

Create a new edge event buffer.

Parameters
capacityNumber 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()

struct gpiod_edge_event* gpiod_edge_event_copy ( struct gpiod_edge_event event)

Copy the edge event object.

Parameters
eventEdge event to copy.
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()

void gpiod_edge_event_free ( struct gpiod_edge_event event)

Free the edge event object.

Parameters
eventEdge event object to free.

◆ gpiod_edge_event_get_event_type()

enum gpiod_edge_event_type gpiod_edge_event_get_event_type ( struct gpiod_edge_event event)

Get the event type.

Parameters
eventGPIO edge event.
Returns
The event type (GPIOD_EDGE_EVENT_RISING_EDGE or GPIOD_EDGE_EVENT_FALLING_EDGE).

◆ 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
eventGPIO edge event.
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
eventGPIO edge event.
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
eventGPIO edge event.
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()

uint64_t gpiod_edge_event_get_timestamp_ns ( struct gpiod_edge_event event)

Get the timestamp of the event.

Parameters
eventGPIO edge event.
Returns
Timestamp in nanoseconds.
Note
The source clock for the timestamp depends on the event_clock setting for the line.