Simple high-level routines for straightforward GPIO manipulation.
More...
|
typedef void(* | gpiod_set_value_cb) (void *) |
| Simple set value callback signature.
|
|
typedef int(* | gpiod_event_cb) (int, const struct timespec *, void *) |
| Simple event callack signature.
|
|
|
int | gpiod_simple_get_value_multiple (const char *consumer, const char *device, const unsigned int *offsets, int *values, unsigned int num_lines, bool active_low) GPIOD_API |
| Read current values from a set of GPIO lines. More...
|
|
static int | gpiod_simple_get_value (const char *consumer, const char *device, unsigned int offset, bool active_low) |
| Read current value from a single GPIO line. More...
|
|
int | gpiod_simple_set_value_multiple (const char *consumer, const char *device, const unsigned int *offsets, const int *values, unsigned int num_lines, bool active_low, gpiod_set_value_cb cb, void *data) GPIOD_API |
| Set values of a set of a set of GPIO lines. More...
|
|
static int | gpiod_simple_set_value (const char *consumer, const char *device, unsigned int offset, int value, bool active_low, gpiod_set_value_cb cb, void *data) |
| Set value of a single GPIO line. More...
|
|
int | gpiod_simple_event_loop (const char *consumer, const char *device, unsigned int offset, bool active_low, const struct timespec *timeout, gpiod_event_cb callback, void *cbdata) GPIOD_API |
| Wait for events on a single GPIO line. More...
|
|
Simple high-level routines for straightforward GPIO manipulation.
◆ anonymous enum
Event types that can be passed to the simple event callback.
Enumerator |
---|
GPIOD_EVENT_CB_TIMEOUT | Waiting for events timed out.
|
GPIOD_EVENT_CB_RISING_EDGE | Rising edge event occured.
|
GPIOD_EVENT_CB_FALLING_EDGE | Falling edge event occured.
|
Definition at line 212 of file gpiod.h.
◆ anonymous enum
Return status values that the simple event callback can return.
Enumerator |
---|
GPIOD_EVENT_CB_OK | Continue processing events.
|
GPIOD_EVENT_CB_STOP | Stop processing events.
|
Definition at line 224 of file gpiod.h.
◆ gpiod_simple_event_loop()
int gpiod_simple_event_loop |
( |
const char * |
consumer, |
|
|
const char * |
device, |
|
|
unsigned int |
offset, |
|
|
bool |
active_low, |
|
|
const struct timespec * |
timeout, |
|
|
gpiod_event_cb |
callback, |
|
|
void * |
cbdata |
|
) |
| |
Wait for events on a single GPIO line.
- Parameters
-
consumer | Name of the consumer. |
device | Name, path or number of the gpiochip. |
offset | GPIO line offset on the chip. |
active_low | The active state of this line - true if low. |
timeout | Maximum wait time for each iteration. |
callback | Callback function to call on event occurence. |
cbdata | User data passed to the callback. |
- Returns
- 0 no errors were encountered, -1 if an error occured.
◆ gpiod_simple_get_value()
static int gpiod_simple_get_value |
( |
const char * |
consumer, |
|
|
const char * |
device, |
|
|
unsigned int |
offset, |
|
|
bool |
active_low |
|
) |
| |
|
inlinestatic |
Read current value from a single GPIO line.
- Parameters
-
consumer | Name of the consumer. |
device | Name, path or number of the gpiochip. |
offset | GPIO line offset on the chip. |
active_low | The active state of this line - true if low. |
- Returns
- 0 or 1 (GPIO value) if the operation succeeds, -1 on error.
Definition at line 147 of file gpiod.h.
References gpiod_simple_get_value_multiple().
◆ gpiod_simple_get_value_multiple()
int gpiod_simple_get_value_multiple |
( |
const char * |
consumer, |
|
|
const char * |
device, |
|
|
const unsigned int * |
offsets, |
|
|
int * |
values, |
|
|
unsigned int |
num_lines, |
|
|
bool |
active_low |
|
) |
| |
Read current values from a set of GPIO lines.
- Parameters
-
consumer | Name of the consumer. |
device | Name, path or number of the gpiochip. |
offsets | An array of offsets of lines whose values should be read. |
values | A buffer in which the values will be stored. |
num_lines | Number of lines, must be > 0. |
active_low | The active state of the lines - true if low. |
- Returns
- 0 if the operation succeeds, -1 on error.
Referenced by gpiod_simple_get_value().
◆ gpiod_simple_set_value()
static int gpiod_simple_set_value |
( |
const char * |
consumer, |
|
|
const char * |
device, |
|
|
unsigned int |
offset, |
|
|
int |
value, |
|
|
bool |
active_low, |
|
|
gpiod_set_value_cb |
cb, |
|
|
void * |
data |
|
) |
| |
|
inlinestatic |
Set value of a single GPIO line.
- Parameters
-
consumer | Name of the consumer. |
device | Name, path or number of the gpiochip. |
offset | GPIO line offset on the chip. |
value | New value. |
active_low | The active state of this line - true if low. |
cb | Callback function that will be called right after the value is set. Users can use this, for example, to pause the execution after toggling a GPIO. |
data | User data that will be passed to the callback function. |
- Returns
- 0 if the operation succeeds, -1 on error.
Definition at line 198 of file gpiod.h.
References gpiod_simple_set_value_multiple().
◆ gpiod_simple_set_value_multiple()
int gpiod_simple_set_value_multiple |
( |
const char * |
consumer, |
|
|
const char * |
device, |
|
|
const unsigned int * |
offsets, |
|
|
const int * |
values, |
|
|
unsigned int |
num_lines, |
|
|
bool |
active_low, |
|
|
gpiod_set_value_cb |
cb, |
|
|
void * |
data |
|
) |
| |
Set values of a set of a set of GPIO lines.
- Parameters
-
consumer | Name of the consumer. |
device | Name, path or number of the gpiochip. |
offsets | An array of offsets of lines whose values should be set. |
values | An array of integers containing new values. |
num_lines | Number of lines, must be > 0. |
active_low | The active state of the lines - true if low. |
cb | Callback function that will be called right after the values are set. |
data | User data that will be passed to the callback function. |
- Returns
- 0 if the operation succeeds, -1 on error.
Referenced by gpiod_simple_set_value().