libgpiod
1.5.1
|
Commonly used utility macros. More...
Data Structures | |
struct | gpiod_ctxless_event_poll_fd |
Helper structure for the ctxless event loop poll callback. More... | |
struct | gpiod_line_bulk |
Helper structure for storing a set of GPIO line objects. More... | |
struct | gpiod_line_request_config |
Structure holding configuration of a line request. More... | |
struct | gpiod_line_event |
Structure holding event info. More... | |
class | gpiod::chip |
Represents a GPIO chip. More... | |
struct | gpiod::line_request |
Stores the configuration for line requests. More... | |
class | gpiod::line |
Represents a single GPIO line. More... | |
struct | gpiod::line_event |
Describes a single GPIO line event. More... | |
class | gpiod::line_bulk |
Represents a set of GPIO lines. More... | |
class | gpiod::chip_iter |
Allows to iterate over all GPIO chips present on the system. More... | |
class | gpiod::line_iter |
Allows to iterate over all lines owned by a GPIO chip. More... | |
Macros | |
#define | GPIOD_API __attribute__((visibility("default"))) |
Makes symbol visible. | |
#define | GPIOD_UNUSED __attribute__((unused)) |
Marks a function argument or variable as potentially unused. | |
#define | GPIOD_BIT(nr) (1UL << (nr)) |
Shift 1 by given offset. More... | |
#define | GPIOD_DEPRECATED __attribute__((deprecated)) |
Marks a public function as deprecated. | |
#define | GPIOD_LINE_BULK_MAX_LINES 64 |
Maximum number of GPIO lines that can be requested at once. | |
#define | GPIOD_LINE_BULK_INITIALIZER { { NULL }, 0 } |
Static initializer for GPIO bulk objects. More... | |
#define | gpiod_line_bulk_foreach_line(bulk, line, lineptr) |
Iterate over all line handles held by a line bulk object. More... | |
#define | gpiod_line_bulk_foreach_line_off(bulk, line, offset) |
Iterate over all line handles held by a line bulk object (integer counter variant). More... | |
#define | gpiod_foreach_chip(iter, chip) |
Iterate over all GPIO chips present in the system. More... | |
#define | gpiod_foreach_chip_noclose(iter, chip) |
Iterate over all chips present in the system without closing them. More... | |
#define | gpiod_foreach_line(iter, line) |
Iterate over all GPIO lines of a single chip. More... | |
Typedefs | |
typedef void(* | gpiod_ctxless_set_value_cb) (void *) |
Simple set value callback signature. | |
typedef int(* | gpiod_ctxless_event_handle_cb) (int, unsigned int, const struct timespec *, void *) |
Simple event callback signature. More... | |
typedef int(* | gpiod_ctxless_event_poll_cb) (unsigned int, struct gpiod_ctxless_event_poll_fd *, const struct timespec *, void *) |
Simple event poll callback signature. More... | |
Functions | |
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_ext (const char *device, unsigned int offset, bool active_low, const char *consumer, int flags) 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_get_value_multiple_ext (const char *device, const unsigned int *offsets, int *values, unsigned int num_lines, bool active_low, const char *consumer, int flags) 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_ext (const char *device, unsigned int offset, int value, bool active_low, const char *consumer, gpiod_ctxless_set_value_cb cb, void *data, int flags) 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_set_value_multiple_ext (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, int flags) 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_ext (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, int flags) 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_event_monitor_multiple_ext (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, int flags) 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... | |
struct gpiod_chip * | gpiod_chip_open (const char *path) GPIOD_API |
Open a gpiochip by path. More... | |
struct gpiod_chip * | gpiod_chip_open_by_name (const char *name) GPIOD_API |
Open a gpiochip by name. More... | |
struct gpiod_chip * | gpiod_chip_open_by_number (unsigned int num) GPIOD_API |
Open a gpiochip by number. More... | |
struct gpiod_chip * | gpiod_chip_open_by_label (const char *label) GPIOD_API |
Open a gpiochip by label. More... | |
struct gpiod_chip * | gpiod_chip_open_lookup (const char *descr) GPIOD_API |
Open a gpiochip based on the best guess what the path is. More... | |
void | gpiod_chip_close (struct gpiod_chip *chip) GPIOD_API |
Close a GPIO chip handle and release all allocated resources. More... | |
const char * | gpiod_chip_name (struct gpiod_chip *chip) GPIOD_API |
Get the GPIO chip name as represented in the kernel. More... | |
const char * | gpiod_chip_label (struct gpiod_chip *chip) GPIOD_API |
Get the GPIO chip label as represented in the kernel. More... | |
unsigned int | gpiod_chip_num_lines (struct gpiod_chip *chip) GPIOD_API |
Get the number of GPIO lines exposed by this chip. More... | |
struct gpiod_line * | gpiod_chip_get_line (struct gpiod_chip *chip, unsigned int offset) GPIOD_API |
Get the handle to the GPIO line at given offset. More... | |
int | gpiod_chip_get_lines (struct gpiod_chip *chip, unsigned int *offsets, unsigned int num_offsets, struct gpiod_line_bulk *bulk) GPIOD_API |
Retrieve a set of lines and store them in a line bulk object. More... | |
int | gpiod_chip_get_all_lines (struct gpiod_chip *chip, struct gpiod_line_bulk *bulk) GPIOD_API |
Retrieve all lines exposed by a chip and store them in a bulk object. More... | |
struct gpiod_line * | gpiod_chip_find_line (struct gpiod_chip *chip, const char *name) GPIOD_API |
Find a GPIO line by name among lines associated with given GPIO chip. More... | |
int | gpiod_chip_find_lines (struct gpiod_chip *chip, const char **names, struct gpiod_line_bulk *bulk) GPIOD_API |
Find a set of GPIO lines by names among lines exposed by this chip. More... | |
static void | gpiod_line_bulk_init (struct gpiod_line_bulk *bulk) |
Initialize a GPIO bulk object. More... | |
static void | gpiod_line_bulk_add (struct gpiod_line_bulk *bulk, struct gpiod_line *line) |
Add a single line to a GPIO bulk object. More... | |
static struct gpiod_line * | gpiod_line_bulk_get_line (struct gpiod_line_bulk *bulk, unsigned int offset) |
Retrieve the line handle from a line bulk object at given offset. More... | |
static unsigned int | gpiod_line_bulk_num_lines (struct gpiod_line_bulk *bulk) |
Retrieve the number of GPIO lines held by this line bulk object. More... | |
unsigned int | gpiod_line_offset (struct gpiod_line *line) GPIOD_API |
Read the GPIO line offset. More... | |
const char * | gpiod_line_name (struct gpiod_line *line) GPIOD_API |
Read the GPIO line name. More... | |
const char * | gpiod_line_consumer (struct gpiod_line *line) GPIOD_API |
Read the GPIO line consumer name. More... | |
int | gpiod_line_direction (struct gpiod_line *line) GPIOD_API |
Read the GPIO line direction setting. More... | |
int | gpiod_line_active_state (struct gpiod_line *line) GPIOD_API |
Read the GPIO line active state setting. More... | |
int | gpiod_line_bias (struct gpiod_line *line) GPIOD_API |
Read the GPIO line bias setting. More... | |
bool | gpiod_line_is_used (struct gpiod_line *line) GPIOD_API |
Check if the line is currently in use. More... | |
bool | gpiod_line_is_open_drain (struct gpiod_line *line) GPIOD_API |
Check if the line is an open-drain GPIO. More... | |
bool | gpiod_line_is_open_source (struct gpiod_line *line) GPIOD_API |
Check if the line is an open-source GPIO. More... | |
int | gpiod_line_update (struct gpiod_line *line) GPIOD_API |
Re-read the line info. More... | |
bool | gpiod_line_needs_update (struct gpiod_line *line) GPIOD_API GPIOD_DEPRECATED |
Check if the line info needs to be updated. More... | |
int | gpiod_line_request (struct gpiod_line *line, const struct gpiod_line_request_config *config, int default_val) GPIOD_API |
Reserve a single line. More... | |
int | gpiod_line_request_input (struct gpiod_line *line, const char *consumer) GPIOD_API |
Reserve a single line, set the direction to input. More... | |
int | gpiod_line_request_output (struct gpiod_line *line, const char *consumer, int default_val) GPIOD_API |
Reserve a single line, set the direction to output. More... | |
int | gpiod_line_request_rising_edge_events (struct gpiod_line *line, const char *consumer) GPIOD_API |
Request rising edge event notifications on a single line. More... | |
int | gpiod_line_request_falling_edge_events (struct gpiod_line *line, const char *consumer) GPIOD_API |
Request falling edge event notifications on a single line. More... | |
int | gpiod_line_request_both_edges_events (struct gpiod_line *line, const char *consumer) GPIOD_API |
Request all event type notifications on a single line. More... | |
int | gpiod_line_request_input_flags (struct gpiod_line *line, const char *consumer, int flags) GPIOD_API |
Reserve a single line, set the direction to input. More... | |
int | gpiod_line_request_output_flags (struct gpiod_line *line, const char *consumer, int flags, int default_val) GPIOD_API |
Reserve a single line, set the direction to output. More... | |
int | gpiod_line_request_rising_edge_events_flags (struct gpiod_line *line, const char *consumer, int flags) GPIOD_API |
Request rising edge event notifications on a single line. More... | |
int | gpiod_line_request_falling_edge_events_flags (struct gpiod_line *line, const char *consumer, int flags) GPIOD_API |
Request falling edge event notifications on a single line. More... | |
int | gpiod_line_request_both_edges_events_flags (struct gpiod_line *line, const char *consumer, int flags) GPIOD_API |
Request all event type notifications on a single line. More... | |
int | gpiod_line_request_bulk (struct gpiod_line_bulk *bulk, const struct gpiod_line_request_config *config, const int *default_vals) GPIOD_API |
Reserve a set of GPIO lines. More... | |
int | gpiod_line_request_bulk_input (struct gpiod_line_bulk *bulk, const char *consumer) GPIOD_API |
Reserve a set of GPIO lines, set the direction to input. More... | |
int | gpiod_line_request_bulk_output (struct gpiod_line_bulk *bulk, const char *consumer, const int *default_vals) GPIOD_API |
Reserve a set of GPIO lines, set the direction to output. More... | |
int | gpiod_line_request_bulk_rising_edge_events (struct gpiod_line_bulk *bulk, const char *consumer) GPIOD_API |
Request rising edge event notifications on a set of lines. More... | |
int | gpiod_line_request_bulk_falling_edge_events (struct gpiod_line_bulk *bulk, const char *consumer) GPIOD_API |
Request falling edge event notifications on a set of lines. More... | |
int | gpiod_line_request_bulk_both_edges_events (struct gpiod_line_bulk *bulk, const char *consumer) GPIOD_API |
Request all event type notifications on a set of lines. More... | |
int | gpiod_line_request_bulk_input_flags (struct gpiod_line_bulk *bulk, const char *consumer, int flags) GPIOD_API |
Reserve a set of GPIO lines, set the direction to input. More... | |
int | gpiod_line_request_bulk_output_flags (struct gpiod_line_bulk *bulk, const char *consumer, int flags, const int *default_vals) GPIOD_API |
Reserve a set of GPIO lines, set the direction to output. More... | |
int | gpiod_line_request_bulk_rising_edge_events_flags (struct gpiod_line_bulk *bulk, const char *consumer, int flags) GPIOD_API |
Request rising edge event notifications on a set of lines. More... | |
int | gpiod_line_request_bulk_falling_edge_events_flags (struct gpiod_line_bulk *bulk, const char *consumer, int flags) GPIOD_API |
Request falling edge event notifications on a set of lines. More... | |
int | gpiod_line_request_bulk_both_edges_events_flags (struct gpiod_line_bulk *bulk, const char *consumer, int flags) GPIOD_API |
Request all event type notifications on a set of lines. More... | |
void | gpiod_line_release (struct gpiod_line *line) GPIOD_API |
Release a previously reserved line. More... | |
void | gpiod_line_release_bulk (struct gpiod_line_bulk *bulk) GPIOD_API |
Release a set of previously reserved lines. More... | |
bool | gpiod_line_is_requested (struct gpiod_line *line) GPIOD_API |
Check if the calling user has ownership of this line. More... | |
bool | gpiod_line_is_free (struct gpiod_line *line) GPIOD_API |
Check if the calling user has neither requested ownership of this line nor configured any event notifications. More... | |
int | gpiod_line_get_value (struct gpiod_line *line) GPIOD_API |
Read current value of a single GPIO line. More... | |
int | gpiod_line_get_value_bulk (struct gpiod_line_bulk *bulk, int *values) GPIOD_API |
Read current values of a set of GPIO lines. More... | |
int | gpiod_line_set_value (struct gpiod_line *line, int value) GPIOD_API |
Set the value of a single GPIO line. More... | |
int | gpiod_line_set_value_bulk (struct gpiod_line_bulk *bulk, const int *values) GPIOD_API |
Set the values of a set of GPIO lines. More... | |
int | gpiod_line_set_config (struct gpiod_line *line, int direction, int flags, int value) GPIOD_API |
Update the configuration of a single GPIO line. More... | |
int | gpiod_line_set_config_bulk (struct gpiod_line_bulk *bulk, int direction, int flags, const int *values) GPIOD_API |
Update the configuration of a set of GPIO lines. More... | |
int | gpiod_line_set_flags (struct gpiod_line *line, int flags) GPIOD_API |
Update the configuration flags of a single GPIO line. More... | |
int | gpiod_line_set_flags_bulk (struct gpiod_line_bulk *bulk, int flags) GPIOD_API |
Update the configuration flags of a set of GPIO lines. More... | |
int | gpiod_line_set_direction_input (struct gpiod_line *line) GPIOD_API |
Set the direction of a single GPIO line to input. More... | |
int | gpiod_line_set_direction_input_bulk (struct gpiod_line_bulk *bulk) GPIOD_API |
Set the direction of a set of GPIO lines to input. More... | |
int | gpiod_line_set_direction_output (struct gpiod_line *line, int value) GPIOD_API |
Set the direction of a single GPIO line to output. More... | |
int | gpiod_line_set_direction_output_bulk (struct gpiod_line_bulk *bulk, const int *values) GPIOD_API |
Set the direction of a set of GPIO lines to output. 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_bulk *event_bulk) GPIOD_API |
Wait for events 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_read_multiple (struct gpiod_line *line, struct gpiod_line_event *events, unsigned int num_events) GPIOD_API |
Read up to a certain number of events 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... | |
int | gpiod_line_event_read_fd_multiple (int fd, struct gpiod_line_event *events, unsigned int num_events) GPIOD_API |
Read up to a certain number of events directly from a file descriptor. More... | |
struct gpiod_line * | gpiod_line_get (const char *device, unsigned int offset) GPIOD_API |
Get a GPIO line handle by GPIO chip description and offset. More... | |
struct gpiod_line * | gpiod_line_find (const char *name) GPIOD_API |
Find a GPIO line by its name. More... | |
void | gpiod_line_close_chip (struct gpiod_line *line) GPIOD_API |
Close a GPIO chip owning this line and release all resources. More... | |
struct gpiod_chip * | gpiod_line_get_chip (struct gpiod_line *line) GPIOD_API |
Get the handle to the GPIO chip controlling this line. More... | |
struct gpiod_chip_iter * | gpiod_chip_iter_new (void) GPIOD_API |
Create a new gpiochip iterator. More... | |
void | gpiod_chip_iter_free (struct gpiod_chip_iter *iter) GPIOD_API |
Release all resources allocated for the gpiochip iterator and close the most recently opened gpiochip (if any). More... | |
void | gpiod_chip_iter_free_noclose (struct gpiod_chip_iter *iter) GPIOD_API |
Release all resources allocated for the gpiochip iterator but don't close the most recently opened gpiochip (if any). More... | |
struct gpiod_chip * | gpiod_chip_iter_next (struct gpiod_chip_iter *iter) GPIOD_API |
Get the next gpiochip handle. More... | |
struct gpiod_chip * | gpiod_chip_iter_next_noclose (struct gpiod_chip_iter *iter) GPIOD_API |
Get the next gpiochip handle without closing the previous one. More... | |
struct gpiod_line_iter * | gpiod_line_iter_new (struct gpiod_chip *chip) GPIOD_API |
Create a new line iterator. More... | |
void | gpiod_line_iter_free (struct gpiod_line_iter *iter) GPIOD_API |
Free all resources associated with a GPIO line iterator. More... | |
struct gpiod_line * | gpiod_line_iter_next (struct gpiod_line_iter *iter) GPIOD_API |
Get the next GPIO line handle. More... | |
const char * | gpiod_version_string (void) GPIOD_API |
Get the API version of the library as a human-readable string. More... | |
GPIOD_API line | gpiod::find_line (const ::std::string &name) |
Find a GPIO line by name. More... | |
GPIOD_API chip_iter | gpiod::make_chip_iter (void) |
Create a new chip_iter. More... | |
GPIOD_API chip_iter | gpiod::begin (chip_iter iter) noexcept |
Support for range-based loops for chip iterators. More... | |
GPIOD_API chip_iter | gpiod::end (const chip_iter &iter) noexcept |
Support for range-based loops for chip iterators. More... | |
GPIOD_API line_iter | gpiod::begin (line_iter iter) noexcept |
Support for range-based loops for line iterators. More... | |
GPIOD_API line_iter | gpiod::end (const line_iter &iter) noexcept |
Support for range-based loops for line iterators. More... | |
Commonly used utility macros.
Various libgpiod-related functions.
These functions and data structures allow easy iterating over GPIO chips and lines.
Functions and data structures dealing with GPIO lines.
Functions and data structures dealing with GPIO chips.
Simple high-level routines for straightforward GPIO manipulation without the need to use the gpiod_* structures or to keep track of resources.
#define GPIOD_BIT | ( | nr | ) | (1UL << (nr)) |
#define gpiod_foreach_chip | ( | iter, | |
chip | |||
) |
Iterate over all GPIO chips present in the system.
iter | An initialized GPIO chip iterator. |
chip | Pointer to a GPIO chip handle. On each iteration the newly opened chip handle is assigned to this argument. |
The user must not close the GPIO chip manually - instead the previous chip handle is closed automatically on the next iteration. The last chip to be opened is closed internally by gpiod_chip_iter_free.
#define gpiod_foreach_chip_noclose | ( | iter, | |
chip | |||
) |
Iterate over all chips present in the system without closing them.
iter | An initialized GPIO chip iterator. |
chip | Pointer to a GPIO chip handle. On each iteration the newly opened chip handle is assigned to this argument. |
The user must close all the GPIO chips manually after use, until then, the chips remain open. Free the iterator by calling gpiod_chip_iter_free_noclose to avoid closing the last chip automatically.
#define gpiod_foreach_line | ( | iter, | |
line | |||
) |
Iterate over all GPIO lines of a single chip.
iter | An initialized GPIO line iterator. |
line | Pointer to a GPIO line handle - on each iteration, the next GPIO line will be assigned to this argument. |
#define gpiod_line_bulk_foreach_line | ( | bulk, | |
line, | |||
lineptr | |||
) |
Iterate over all line handles held by a line bulk object.
bulk | Line bulk object. |
line | GPIO line handle. On each iteration, the subsequent line handle is assigned to this pointer. |
lineptr | Pointer to a GPIO line handle used to store the loop state. |
#define gpiod_line_bulk_foreach_line_off | ( | bulk, | |
line, | |||
offset | |||
) |
Iterate over all line handles held by a line bulk object (integer counter variant).
bulk | Line bulk object. |
line | GPIO line handle. On each iteration, the subsequent line handle is assigned to this pointer. |
offset | An integer variable used to store the loop state. |
This is a variant of gpiod_line_bulk_foreach_line which uses an integer variable (either signed or unsigned) to store the loop state. This offset variable is guaranteed to correspond to the offset of the current line in the bulk->lines array.
#define GPIOD_LINE_BULK_INITIALIZER { { NULL }, 0 } |
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.
typedef int(* gpiod_ctxless_event_poll_cb) (unsigned int, struct gpiod_ctxless_event_poll_fd *, const struct timespec *, void *) |
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.
anonymous enum |
Miscellaneous GPIO flags.
anonymous enum |
anonymous enum |
anonymous enum |
anonymous enum |
anonymous enum |
Return status values that the ctxless event poll callback can return.
Positive value returned from the polling callback indicates the number of events that occurred on the set of monitored lines.
anonymous enum |
anonymous enum |
anonymous enum |
anonymous enum |
Available types of requests.
anonymous enum |
Miscellaneous GPIO request flags.
Support for range-based loops for chip iterators.
iter | A chip iterator. |
Support for range-based loops for line iterators.
iter | A line iterator. |
Support for range-based loops for chip iterators.
iter | A chip iterator. |
Support for range-based loops for line iterators.
iter | A line iterator. |
Find a GPIO line by name.
Search all GPIO chips present on the system.
name | Name of the line. |
void gpiod_chip_close | ( | struct gpiod_chip * | chip | ) |
Close a GPIO chip handle and release all allocated resources.
chip | The GPIO chip object. |
struct gpiod_line* gpiod_chip_find_line | ( | struct gpiod_chip * | chip, |
const char * | name | ||
) |
Find a GPIO line by name among lines associated with given GPIO chip.
chip | The GPIO chip object. |
name | The name of the GPIO line. |
int gpiod_chip_find_lines | ( | struct gpiod_chip * | chip, |
const char ** | names, | ||
struct gpiod_line_bulk * | bulk | ||
) |
Find a set of GPIO lines by names among lines exposed by this chip.
chip | The GPIO chip object. |
names | Array of pointers to C-strings containing the names of the lines to lookup. Must end with a NULL-pointer. |
bulk | Line bulk object in which the located lines will be stored. |
int gpiod_chip_get_all_lines | ( | struct gpiod_chip * | chip, |
struct gpiod_line_bulk * | bulk | ||
) |
Retrieve all lines exposed by a chip and store them in a bulk object.
chip | The GPIO chip object. |
bulk | Line bulk object in which to store the line handles. |
struct gpiod_line* gpiod_chip_get_line | ( | struct gpiod_chip * | chip, |
unsigned int | offset | ||
) |
Get the handle to the GPIO line at given offset.
chip | The GPIO chip object. |
offset | The offset of the GPIO line. |
int gpiod_chip_get_lines | ( | struct gpiod_chip * | chip, |
unsigned int * | offsets, | ||
unsigned int | num_offsets, | ||
struct gpiod_line_bulk * | bulk | ||
) |
Retrieve a set of lines and store them in a line bulk object.
chip | The GPIO chip object. |
offsets | Array of offsets of lines to retrieve. |
num_offsets | Number of lines to retrieve. |
bulk | Line bulk object in which to store the line handles. |
void gpiod_chip_iter_free | ( | struct gpiod_chip_iter * | iter | ) |
Release all resources allocated for the gpiochip iterator and close the most recently opened gpiochip (if any).
iter | The gpiochip iterator object. |
void gpiod_chip_iter_free_noclose | ( | struct gpiod_chip_iter * | iter | ) |
Release all resources allocated for the gpiochip iterator but don't close the most recently opened gpiochip (if any).
iter | The gpiochip iterator object. |
Users may want to break the loop when iterating over gpiochips and keep the most recently opened chip active while freeing the iterator data. This routine enables that.
struct gpiod_chip_iter* gpiod_chip_iter_new | ( | void | ) |
Create a new gpiochip iterator.
Internally this routine scans the /dev/ directory for GPIO chip device files, opens them and stores their the handles until gpiod_chip_iter_free or gpiod_chip_iter_free_noclose is called.
struct gpiod_chip* gpiod_chip_iter_next | ( | struct gpiod_chip_iter * | iter | ) |
Get the next gpiochip handle.
iter | The gpiochip iterator object. |
struct gpiod_chip* gpiod_chip_iter_next_noclose | ( | struct gpiod_chip_iter * | iter | ) |
Get the next gpiochip handle without closing the previous one.
iter | The gpiochip iterator object. |
const char* gpiod_chip_label | ( | struct gpiod_chip * | chip | ) |
Get the GPIO chip label as represented in the kernel.
chip | The GPIO chip object. |
const char* gpiod_chip_name | ( | struct gpiod_chip * | chip | ) |
Get the GPIO chip name as represented in the kernel.
chip | The GPIO chip object. |
unsigned int gpiod_chip_num_lines | ( | struct gpiod_chip * | chip | ) |
Get the number of GPIO lines exposed by this chip.
chip | The GPIO chip object. |
struct gpiod_chip* gpiod_chip_open | ( | const char * | path | ) |
Open a gpiochip by path.
path | Path to the gpiochip device file. |
struct gpiod_chip* gpiod_chip_open_by_label | ( | const char * | label | ) |
Open a gpiochip by label.
label | Label of the gpiochip to open. |
struct gpiod_chip* gpiod_chip_open_by_name | ( | const char * | name | ) |
Open a gpiochip by name.
name | Name of the gpiochip to open. |
This routine appends name to '/dev/' to create the path.
struct gpiod_chip* gpiod_chip_open_by_number | ( | unsigned int | num | ) |
Open a gpiochip by number.
num | Number of the gpiochip. |
This routine appends num to '/dev/gpiochip' to create the path.
struct gpiod_chip* gpiod_chip_open_lookup | ( | const char * | descr | ) |
Open a gpiochip based on the best guess what the path is.
descr | String describing the gpiochip. |
This routine tries to figure out whether the user passed it the path to the GPIO chip, its name, label or number as a string. Then it tries to open it using one of the gpiod_chip_open** variants.
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 | ||
) |
Wait for events on a single GPIO line.
device | Name, path, number or label of the gpiochip. |
offset | GPIO line offset 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. |
event_cb | Callback function to call for each line event. |
data | User data passed to the callback. |
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 | ||
) |
Wait for events on multiple GPIO lines.
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. |
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 | ( | 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 | ||
) |
Wait for events on a single GPIO line.
device | Name, path, number or label of the gpiochip. |
event_type | Type of events to listen for. |
offset | GPIO line offset 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. |
event_cb | Callback function to call for each line event. |
data | User data passed to the callback. |
int gpiod_ctxless_event_monitor_ext | ( | 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, | ||
int | flags | ||
) |
Wait for events on a single GPIO line.
device | Name, path, number or label of the gpiochip. |
event_type | Type of events to listen for. |
offset | GPIO line offset 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. |
event_cb | Callback function to call for each line event. |
data | User data passed to the callback. |
flags | The flags for the line. |
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.
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. |
Internally this routine opens the GPIO chip, requests the set of lines for the type of events specified in the event_type parameter 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_ext | ( | 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, | ||
int | flags | ||
) |
Wait for events on multiple GPIO lines.
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. |
flags | The flags for the lines. |
Internally this routine opens the GPIO chip, requests the set of lines for the type of events specified in the event_type parameter 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_find_line | ( | const char * | name, |
char * | chipname, | ||
size_t | chipname_size, | ||
unsigned int * | offset | ||
) |
Determine the chip name and line offset of a line with given name.
name | The name of the GPIO line to lookup. |
chipname | Buffer in which the name of the GPIO chip will be stored. |
chipname_size | Size of the chip name buffer. |
offset | Pointer to an integer in which the line offset will be stored. |
int gpiod_ctxless_get_value | ( | const char * | device, |
unsigned int | offset, | ||
bool | active_low, | ||
const char * | consumer | ||
) |
Read current value from a single GPIO line.
device | Name, path, number or label of the gpiochip. |
offset | Offset of the GPIO line. |
active_low | The active state of this line - true if low. |
consumer | Name of the consumer. |
int gpiod_ctxless_get_value_ext | ( | const char * | device, |
unsigned int | offset, | ||
bool | active_low, | ||
const char * | consumer, | ||
int | flags | ||
) |
Read current value from a single GPIO line.
device | Name, path, number or label of the gpiochip. |
offset | Offset of the GPIO line. |
active_low | The active state of this line - true if low. |
consumer | Name of the consumer. |
flags | The flags for the line. |
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 | ||
) |
Read current values from a set of GPIO lines.
device | Name, path, number or label of the gpiochip. |
offsets | Array of offsets of lines whose values should be read. |
values | 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. |
consumer | Name of the consumer. |
int gpiod_ctxless_get_value_multiple_ext | ( | const char * | device, |
const unsigned int * | offsets, | ||
int * | values, | ||
unsigned int | num_lines, | ||
bool | active_low, | ||
const char * | consumer, | ||
int | flags | ||
) |
Read current values from a set of GPIO lines.
device | Name, path, number or label of the gpiochip. |
offsets | Array of offsets of lines whose values should be read. |
values | Buffer in which the values will be stored. |
num_lines | Number of lines, must be > 0. |
active_low | The active state of this line - true if low. |
consumer | Name of the consumer. |
flags | The flags for the lines. |
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 | ||
) |
Set value of a single GPIO line.
device | Name, path, number or label of the gpiochip. |
offset | The offset of the GPIO line. |
value | New value (0 or 1). |
active_low | The active state of this line - true if low. |
consumer | Name of the consumer. |
cb | Optional callback function that will be called right after setting the value. Users can use this, for example, to pause the execution after toggling a GPIO. |
data | Optional user data that will be passed to the callback function. |
int gpiod_ctxless_set_value_ext | ( | const char * | device, |
unsigned int | offset, | ||
int | value, | ||
bool | active_low, | ||
const char * | consumer, | ||
gpiod_ctxless_set_value_cb | cb, | ||
void * | data, | ||
int | flags | ||
) |
Set value of a single GPIO line.
device | Name, path, number or label of the gpiochip. |
offset | The offset of the GPIO line. |
value | New value (0 or 1). |
active_low | The active state of this line - true if low. |
consumer | Name of the consumer. |
cb | Optional callback function that will be called right after setting the value. Users can use this, for example, to pause the execution after toggling a GPIO. |
data | Optional user data that will be passed to the callback function. |
flags | The flags for the line. |
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 | ||
) |
Set values of multiple GPIO lines.
device | Name, path, number or label of the gpiochip. |
offsets | Array of offsets of lines the values of which should be set. |
values | 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. |
consumer | Name of the consumer. |
cb | Optional callback function that will be called right after setting all values. Works the same as in gpiod_ctxless_set_value. |
data | Optional user data that will be passed to the callback function. |
int gpiod_ctxless_set_value_multiple_ext | ( | 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, | ||
int | flags | ||
) |
Set values of multiple GPIO lines.
device | Name, path, number or label of the gpiochip. |
offsets | Array of offsets of lines the values of which should be set. |
values | Array of integers containing new values. |
num_lines | Number of lines, must be > 0. |
active_low | The active state of this line - true if low. |
consumer | Name of the consumer. |
cb | Optional callback function that will be called right after setting all values. Works the same as in gpiod_ctxless_set_value. |
data | Optional user data that will be passed to the callback function. |
flags | The flags for the lines. |
int gpiod_line_active_state | ( | struct gpiod_line * | line | ) |
Read the GPIO line active state setting.
line | GPIO line object. |
int gpiod_line_bias | ( | struct gpiod_line * | line | ) |
Read the GPIO line bias setting.
line | GPIO line object. |
|
inlinestatic |
Add a single line to a GPIO bulk object.
bulk | Line bulk object. |
line | Line to add. |
Definition at line 730 of file gpiod.h.
References gpiod_line_bulk::lines, and gpiod_line_bulk::num_lines.
|
inlinestatic |
Retrieve the line handle from a line bulk object at given offset.
bulk | Line bulk object. |
offset | Line offset. |
Definition at line 743 of file gpiod.h.
References gpiod_line_bulk::lines.
|
inlinestatic |
Initialize a GPIO bulk object.
bulk | Line bulk object. |
This routine simply sets the internally held number of lines to 0.
Definition at line 720 of file gpiod.h.
References gpiod_line_bulk::num_lines.
|
inlinestatic |
Retrieve the number of GPIO lines held by this line bulk object.
bulk | Line bulk object. |
Definition at line 754 of file gpiod.h.
References gpiod_line_bulk::num_lines.
void gpiod_line_close_chip | ( | struct gpiod_line * | line | ) |
Close a GPIO chip owning this line and release all resources.
line | GPIO line object |
After this function returns, the line must no longer be used.
const char* gpiod_line_consumer | ( | struct gpiod_line * | line | ) |
Read the GPIO line consumer name.
line | GPIO line object. |
int gpiod_line_direction | ( | struct gpiod_line * | line | ) |
Read the GPIO line direction setting.
line | GPIO line object. |
int gpiod_line_event_get_fd | ( | struct gpiod_line * | line | ) |
Get the event file descriptor.
line | GPIO line object. |
Users may want to poll the event file descriptor on their own. This routine allows to access it.
int gpiod_line_event_read | ( | struct gpiod_line * | line, |
struct gpiod_line_event * | event | ||
) |
Read the last event from the GPIO line.
line | GPIO line object. |
event | Buffer to which the event data will be copied. |
int gpiod_line_event_read_fd | ( | int | fd, |
struct gpiod_line_event * | event | ||
) |
Read the last GPIO event directly from a file descriptor.
fd | File descriptor. |
event | Buffer in which the event data will be stored. |
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.
int gpiod_line_event_read_fd_multiple | ( | int | fd, |
struct gpiod_line_event * | events, | ||
unsigned int | num_events | ||
) |
Read up to a certain number of events directly from a file descriptor.
fd | File descriptor. |
events | Buffer to which the event data will be copied. Must hold at least the amount of events specified in num_events. |
num_events | Specifies how many events can be stored in the buffer. |
int gpiod_line_event_read_multiple | ( | struct gpiod_line * | line, |
struct gpiod_line_event * | events, | ||
unsigned int | num_events | ||
) |
Read up to a certain number of events from the GPIO line.
line | GPIO line object. |
events | Buffer to which the event data will be copied. Must hold at least the amount of events specified in num_events. |
num_events | Specifies how many events can be stored in the buffer. |
int gpiod_line_event_wait | ( | struct gpiod_line * | line, |
const struct timespec * | timeout | ||
) |
Wait for an event on a single line.
line | GPIO line object. |
timeout | Wait time limit. |
int gpiod_line_event_wait_bulk | ( | struct gpiod_line_bulk * | bulk, |
const struct timespec * | timeout, | ||
struct gpiod_line_bulk * | event_bulk | ||
) |
Wait for events on a set of lines.
bulk | Set of GPIO lines to monitor. |
timeout | Wait time limit. |
event_bulk | Bulk object in which to store the line handles on which events occurred. Can be NULL. |
struct gpiod_line* gpiod_line_find | ( | const char * | name | ) |
Find a GPIO line by its name.
name | Name of the GPIO line. |
If this routine succeeds, the user must manually close the GPIO chip owning this line to avoid memory leaks. If the line could not be found, this functions sets errno to ENOENT.
struct gpiod_line* gpiod_line_get | ( | const char * | device, |
unsigned int | offset | ||
) |
Get a GPIO line handle by GPIO chip description and offset.
device | String describing the gpiochip. |
offset | The offset of the GPIO line. |
This routine provides a shorter alternative to calling gpiod_chip_open_lookup and gpiod_chip_get_line.
If this function succeeds, the caller is responsible for closing the associated GPIO chip.
struct gpiod_chip* gpiod_line_get_chip | ( | struct gpiod_line * | line | ) |
Get the handle to the GPIO chip controlling this line.
line | The GPIO line object. |
int gpiod_line_get_value | ( | struct gpiod_line * | line | ) |
Read current value of a single GPIO line.
line | GPIO line object. |
int gpiod_line_get_value_bulk | ( | struct gpiod_line_bulk * | bulk, |
int * | values | ||
) |
Read current values of a set of GPIO lines.
bulk | Set of GPIO lines to reserve. |
values | An array big enough to hold line_bulk->num_lines values. |
If succeeds, this routine fills the values array with a set of values in the same order, the lines are added to line_bulk. If the lines were not previously requested together, the behavior is undefined.
bool gpiod_line_is_free | ( | struct gpiod_line * | line | ) |
Check if the calling user has neither requested ownership of this line nor configured any event notifications.
line | GPIO line object. |
bool gpiod_line_is_open_drain | ( | struct gpiod_line * | line | ) |
Check if the line is an open-drain GPIO.
line | GPIO line object. |
bool gpiod_line_is_open_source | ( | struct gpiod_line * | line | ) |
Check if the line is an open-source GPIO.
line | GPIO line object. |
bool gpiod_line_is_requested | ( | struct gpiod_line * | line | ) |
Check if the calling user has ownership of this line.
line | GPIO line object. |
bool gpiod_line_is_used | ( | struct gpiod_line * | line | ) |
Check if the line is currently in use.
line | GPIO line object. |
The user space can't know exactly why a line is busy. It may have been requested by another process or hogged by the kernel. It only matters that the line is used and we can't request it.
void gpiod_line_iter_free | ( | struct gpiod_line_iter * | iter | ) |
Free all resources associated with a GPIO line iterator.
iter | Line iterator object. |
struct gpiod_line_iter* gpiod_line_iter_new | ( | struct gpiod_chip * | chip | ) |
Create a new line iterator.
chip | Active gpiochip handle over the lines of which we want to iterate. |
struct gpiod_line* gpiod_line_iter_next | ( | struct gpiod_line_iter * | iter | ) |
Get the next GPIO line handle.
iter | The GPIO line iterator object. |
const char* gpiod_line_name | ( | struct gpiod_line * | line | ) |
Read the GPIO line name.
line | GPIO line object. |
bool gpiod_line_needs_update | ( | struct gpiod_line * | line | ) |
Check if the line info needs to be updated.
line | GPIO line object. |
unsigned int gpiod_line_offset | ( | struct gpiod_line * | line | ) |
Read the GPIO line offset.
line | GPIO line object. |
void gpiod_line_release | ( | struct gpiod_line * | line | ) |
Release a previously reserved line.
line | GPIO line object. |
void gpiod_line_release_bulk | ( | struct gpiod_line_bulk * | bulk | ) |
Release a set of previously reserved lines.
bulk | Set of GPIO lines to release. |
If the lines were not previously requested together, the behavior is undefined.
int gpiod_line_request | ( | struct gpiod_line * | line, |
const struct gpiod_line_request_config * | config, | ||
int | default_val | ||
) |
Reserve a single line.
line | GPIO line object. |
config | Request options. |
default_val | Initial line value - only relevant if we're setting the direction to output. |
If this routine succeeds, the caller takes ownership of the GPIO line until it's released.
int gpiod_line_request_both_edges_events | ( | struct gpiod_line * | line, |
const char * | consumer | ||
) |
Request all event type notifications on a single line.
line | GPIO line object. |
consumer | Name of the consumer. |
int gpiod_line_request_both_edges_events_flags | ( | struct gpiod_line * | line, |
const char * | consumer, | ||
int | flags | ||
) |
Request all event type notifications on a single line.
line | GPIO line object. |
consumer | Name of the consumer. |
flags | Additional request flags. |
int gpiod_line_request_bulk | ( | struct gpiod_line_bulk * | bulk, |
const struct gpiod_line_request_config * | config, | ||
const int * | default_vals | ||
) |
Reserve a set of GPIO lines.
bulk | Set of GPIO lines to reserve. |
config | Request options. |
default_vals | Initial line values - only relevant if we're setting the direction to output. |
If this routine succeeds, the caller takes ownership of the GPIO lines until they're released. All the requested lines must be prodivided by the same gpiochip.
int gpiod_line_request_bulk_both_edges_events | ( | struct gpiod_line_bulk * | bulk, |
const char * | consumer | ||
) |
Request all event type notifications on a set of lines.
bulk | Set of GPIO lines to request. |
consumer | Name of the consumer. |
int gpiod_line_request_bulk_both_edges_events_flags | ( | struct gpiod_line_bulk * | bulk, |
const char * | consumer, | ||
int | flags | ||
) |
Request all event type notifications on a set of lines.
bulk | Set of GPIO lines to request. |
consumer | Name of the consumer. |
flags | Additional request flags. |
int gpiod_line_request_bulk_falling_edge_events | ( | struct gpiod_line_bulk * | bulk, |
const char * | consumer | ||
) |
Request falling edge event notifications on a set of lines.
bulk | Set of GPIO lines to request. |
consumer | Name of the consumer. |
int gpiod_line_request_bulk_falling_edge_events_flags | ( | struct gpiod_line_bulk * | bulk, |
const char * | consumer, | ||
int | flags | ||
) |
Request falling edge event notifications on a set of lines.
bulk | Set of GPIO lines to request. |
consumer | Name of the consumer. |
flags | Additional request flags. |
int gpiod_line_request_bulk_input | ( | struct gpiod_line_bulk * | bulk, |
const char * | consumer | ||
) |
Reserve a set of GPIO lines, set the direction to input.
bulk | Set of GPIO lines to reserve. |
consumer | Name of the consumer. |
int gpiod_line_request_bulk_input_flags | ( | struct gpiod_line_bulk * | bulk, |
const char * | consumer, | ||
int | flags | ||
) |
Reserve a set of GPIO lines, set the direction to input.
bulk | Set of GPIO lines to reserve. |
consumer | Name of the consumer. |
flags | Additional request flags. |
int gpiod_line_request_bulk_output | ( | struct gpiod_line_bulk * | bulk, |
const char * | consumer, | ||
const int * | default_vals | ||
) |
Reserve a set of GPIO lines, set the direction to output.
bulk | Set of GPIO lines to reserve. |
consumer | Name of the consumer. |
default_vals | Initial line values. |
int gpiod_line_request_bulk_output_flags | ( | struct gpiod_line_bulk * | bulk, |
const char * | consumer, | ||
int | flags, | ||
const int * | default_vals | ||
) |
Reserve a set of GPIO lines, set the direction to output.
bulk | Set of GPIO lines to reserve. |
consumer | Name of the consumer. |
flags | Additional request flags. |
default_vals | Initial line values. |
int gpiod_line_request_bulk_rising_edge_events | ( | struct gpiod_line_bulk * | bulk, |
const char * | consumer | ||
) |
Request rising edge event notifications on a set of lines.
bulk | Set of GPIO lines to request. |
consumer | Name of the consumer. |
int gpiod_line_request_bulk_rising_edge_events_flags | ( | struct gpiod_line_bulk * | bulk, |
const char * | consumer, | ||
int | flags | ||
) |
Request rising edge event notifications on a set of lines.
bulk | Set of GPIO lines to request. |
consumer | Name of the consumer. |
flags | Additional request flags. |
int gpiod_line_request_falling_edge_events | ( | struct gpiod_line * | line, |
const char * | consumer | ||
) |
Request falling edge event notifications on a single line.
line | GPIO line object. |
consumer | Name of the consumer. |
int gpiod_line_request_falling_edge_events_flags | ( | struct gpiod_line * | line, |
const char * | consumer, | ||
int | flags | ||
) |
Request falling edge event notifications on a single line.
line | GPIO line object. |
consumer | Name of the consumer. |
flags | Additional request flags. |
int gpiod_line_request_input | ( | struct gpiod_line * | line, |
const char * | consumer | ||
) |
Reserve a single line, set the direction to input.
line | GPIO line object. |
consumer | Name of the consumer. |
int gpiod_line_request_input_flags | ( | struct gpiod_line * | line, |
const char * | consumer, | ||
int | flags | ||
) |
Reserve a single line, set the direction to input.
line | GPIO line object. |
consumer | Name of the consumer. |
flags | Additional request flags. |
int gpiod_line_request_output | ( | struct gpiod_line * | line, |
const char * | consumer, | ||
int | default_val | ||
) |
Reserve a single line, set the direction to output.
line | GPIO line object. |
consumer | Name of the consumer. |
default_val | Initial line value. |
int gpiod_line_request_output_flags | ( | struct gpiod_line * | line, |
const char * | consumer, | ||
int | flags, | ||
int | default_val | ||
) |
Reserve a single line, set the direction to output.
line | GPIO line object. |
consumer | Name of the consumer. |
flags | Additional request flags. |
default_val | Initial line value. |
int gpiod_line_request_rising_edge_events | ( | struct gpiod_line * | line, |
const char * | consumer | ||
) |
Request rising edge event notifications on a single line.
line | GPIO line object. |
consumer | Name of the consumer. |
int gpiod_line_request_rising_edge_events_flags | ( | struct gpiod_line * | line, |
const char * | consumer, | ||
int | flags | ||
) |
Request rising edge event notifications on a single line.
line | GPIO line object. |
consumer | Name of the consumer. |
flags | Additional request flags. |
int gpiod_line_set_config | ( | struct gpiod_line * | line, |
int | direction, | ||
int | flags, | ||
int | value | ||
) |
Update the configuration of a single GPIO line.
line | GPIO line object. |
direction | Updated direction which may be one of GPIOD_LINE_REQUEST_DIRECTION_AS_IS, GPIOD_LINE_REQUEST_DIRECTION_INPUT, or GPIOD_LINE_REQUEST_DIRECTION_OUTPUT. |
flags | Replacement flags. |
value | The new output value for the line when direction is GPIOD_LINE_REQUEST_DIRECTION_OUTPUT. |
int gpiod_line_set_config_bulk | ( | struct gpiod_line_bulk * | bulk, |
int | direction, | ||
int | flags, | ||
const int * | values | ||
) |
Update the configuration of a set of GPIO lines.
bulk | Set of GPIO lines. |
direction | Updated direction which may be one of GPIOD_LINE_REQUEST_DIRECTION_AS_IS, GPIOD_LINE_REQUEST_DIRECTION_INPUT, or GPIOD_LINE_REQUEST_DIRECTION_OUTPUT. |
flags | Replacement flags. |
values | An array holding line_bulk->num_lines new logical values for lines when direction is GPIOD_LINE_REQUEST_DIRECTION_OUTPUT. A NULL pointer is interpreted as a logical low for all lines. |
If the lines were not previously requested together, the behavior is undefined.
int gpiod_line_set_direction_input | ( | struct gpiod_line * | line | ) |
Set the direction of a single GPIO line to input.
line | GPIO line object. |
int gpiod_line_set_direction_input_bulk | ( | struct gpiod_line_bulk * | bulk | ) |
Set the direction of a set of GPIO lines to input.
bulk | Set of GPIO lines. |
If the lines were not previously requested together, the behavior is undefined.
int gpiod_line_set_direction_output | ( | struct gpiod_line * | line, |
int | value | ||
) |
Set the direction of a single GPIO line to output.
line | GPIO line object. |
value | The logical value output on the line. |
int gpiod_line_set_direction_output_bulk | ( | struct gpiod_line_bulk * | bulk, |
const int * | values | ||
) |
Set the direction of a set of GPIO lines to output.
bulk | Set of GPIO lines. |
values | An array holding line_bulk->num_lines new logical values for lines. A NULL pointer is interpreted as a logical low for all lines. |
If the lines were not previously requested together, the behavior is undefined.
int gpiod_line_set_flags | ( | struct gpiod_line * | line, |
int | flags | ||
) |
Update the configuration flags of a single GPIO line.
line | GPIO line object. |
flags | Replacement flags. |
int gpiod_line_set_flags_bulk | ( | struct gpiod_line_bulk * | bulk, |
int | flags | ||
) |
Update the configuration flags of a set of GPIO lines.
bulk | Set of GPIO lines. |
flags | Replacement flags. |
If the lines were not previously requested together, the behavior is undefined.
int gpiod_line_set_value | ( | struct gpiod_line * | line, |
int | value | ||
) |
Set the value of a single GPIO line.
line | GPIO line object. |
value | New value. |
int gpiod_line_set_value_bulk | ( | struct gpiod_line_bulk * | bulk, |
const int * | values | ||
) |
Set the values of a set of GPIO lines.
bulk | Set of GPIO lines to reserve. |
values | An array holding line_bulk->num_lines new values for lines. A NULL pointer is interpreted as a logical low for all lines. |
If the lines were not previously requested together, the behavior is undefined.
int gpiod_line_update | ( | struct gpiod_line * | line | ) |
Re-read the line info.
line | GPIO line object. |
The line info is initially retrieved from the kernel by gpiod_chip_get_line() and is later re-read after every successful request. Users can use this function to manually re-read the line info when needed.
We currently have no mechanism provided by the kernel for keeping the line info synchronized and for the sake of speed and simplicity of this low-level library we don't want to re-read the line info automatically everytime a property is retrieved. Any daemon using this library must track the state of lines on its own and call this routine if needed.
The state of requested lines is kept synchronized (or rather cannot be changed by external agents while the ownership of the line is taken) so there's no need to call this function in that case.
const char* gpiod_version_string | ( | void | ) |
Get the API version of the library as a human-readable string.
Create a new chip_iter.