libgpiod
0.3.2
|
Functions and data structures dealing with GPIO lines. More...
![]() |
Modules | |
Line event operations | |
Functions and data structures for requesting and reading GPIO line events. | |
Data Structures | |
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... | |
Macros | |
#define | GPIOD_REQUEST_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... | |
Enumerations | |
enum | { GPIOD_DIRECTION_AS_IS, GPIOD_DIRECTION_INPUT, GPIOD_DIRECTION_OUTPUT } |
Available direction settings. More... | |
enum | { GPIOD_ACTIVE_STATE_HIGH, GPIOD_ACTIVE_STATE_LOW } |
Available active state settings. More... | |
enum | { GPIOD_REQUEST_OPEN_DRAIN = GPIOD_BIT(0), GPIOD_REQUEST_OPEN_SOURCE = GPIOD_BIT(1) } |
Miscellaneous GPIO flags. More... | |
Functions | |
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... | |
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... | |
bool | gpiod_line_is_used_by_kernel (struct gpiod_line *line) GPIOD_API |
Check if the line is used by the kernel. 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 |
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, bool active_low) GPIOD_API |
Reserve a single line, set the direction to input. More... | |
int | gpiod_line_request_output (struct gpiod_line *line, const char *consumer, bool active_low, int default_val) GPIOD_API |
Reserve a single line, set the direction to output. 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, bool active_low) 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, bool active_low, const int *default_vals) GPIOD_API |
Reserve a set of GPIO lines, set the direction to output. 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_reserved (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, int *values) GPIOD_API |
Set the values of a set of GPIO lines. More... | |
struct gpiod_line * | gpiod_line_find_by_name (const char *name) GPIOD_API |
Find a GPIO line by its name. 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... | |
Functions and data structures dealing with GPIO lines.
#define GPIOD_LINE_BULK_INITIALIZER { { NULL }, 0 } |
anonymous enum |
Available direction settings.
These values are used both when requesting lines and when retrieving line info.
anonymous enum |
anonymous enum |
int gpiod_line_active_state | ( | struct gpiod_line * | line | ) |
Read the GPIO line active state setting.
line | GPIO line object. |
Referenced by gpiod_line_bulk_add().
|
inlinestatic |
Add a single line to a GPIO bulk object.
bulk | Line bulk object. |
line | Line to add. |
Definition at line 339 of file gpiod.h.
References GPIOD_API, gpiod_line_active_state(), gpiod_line_consumer(), gpiod_line_direction(), gpiod_line_is_open_drain(), gpiod_line_is_open_source(), gpiod_line_is_used_by_kernel(), gpiod_line_name(), gpiod_line_needs_update(), gpiod_line_offset(), gpiod_line_update(), gpiod_line_bulk::lines, and gpiod_line_bulk::num_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 329 of file gpiod.h.
References gpiod_line_bulk::num_lines.
const char* gpiod_line_consumer | ( | struct gpiod_line * | line | ) |
Read the GPIO line consumer name.
line | GPIO line object. |
Referenced by gpiod_line_bulk_add().
int gpiod_line_direction | ( | struct gpiod_line * | line | ) |
Read the GPIO line direction setting.
line | GPIO line object. |
Referenced by gpiod_line_bulk_add().
struct gpiod_line* gpiod_line_find_by_name | ( | 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.
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. |
Referenced by gpiod_line_bulk_add().
bool gpiod_line_is_open_source | ( | struct gpiod_line * | line | ) |
Check if the line is an open-source GPIO.
line | GPIO line object. |
Referenced by gpiod_line_bulk_add().
bool gpiod_line_is_reserved | ( | struct gpiod_line * | line | ) |
Check if the calling user has ownership of this line.
line | GPIO line object. |
bool gpiod_line_is_used_by_kernel | ( | struct gpiod_line * | line | ) |
Check if the line is used by the kernel.
line | GPIO line object. |
Referenced by gpiod_line_bulk_add().
const char* gpiod_line_name | ( | struct gpiod_line * | line | ) |
Read the GPIO line name.
line | GPIO line object. |
Referenced by gpiod_line_bulk_add().
bool gpiod_line_needs_update | ( | struct gpiod_line * | line | ) |
Check if the line info needs to be updated.
line | GPIO line object. |
The line is updated by calling gpiod_line_update() from within gpiod_chip_get_line() and on every line request/release. However: an error returned from gpiod_line_update() only breaks the execution of the former. The request/release routines only set the internal up-to-date flag to false and continue their execution. This routine allows to check if a line info update failed at some point and we should call gpiod_line_update() explicitly.
Referenced by gpiod_line_bulk_add().
unsigned int gpiod_line_offset | ( | struct gpiod_line * | line | ) |
Read the GPIO line offset.
line | GPIO line object. |
Referenced by gpiod_line_bulk_add().
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 | Default 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_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 | Default 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_input | ( | struct gpiod_line_bulk * | bulk, |
const char * | consumer, | ||
bool | active_low | ||
) |
Reserve a set of GPIO lines, set the direction to input.
bulk | Set of GPIO lines to reserve. |
consumer | Name of the consumer. |
active_low | Active state of the lines (true if low). |
int gpiod_line_request_bulk_output | ( | struct gpiod_line_bulk * | bulk, |
const char * | consumer, | ||
bool | active_low, | ||
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. |
active_low | Active state of the lines (true if low). |
default_vals | Default line values. |
int gpiod_line_request_input | ( | struct gpiod_line * | line, |
const char * | consumer, | ||
bool | active_low | ||
) |
Reserve a single line, set the direction to input.
line | GPIO line object. |
consumer | Name of the consumer. |
active_low | Active state of the line (true if low). |
int gpiod_line_request_output | ( | struct gpiod_line * | line, |
const char * | consumer, | ||
bool | active_low, | ||
int | default_val | ||
) |
Reserve a single line, set the direction to output.
line | GPIO line object. |
consumer | Name of the consumer. |
active_low | Active state of the line (true if low). |
default_val | Default line value. |
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, |
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. |
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(). Users can use this line to manually re-read the line info.
Referenced by gpiod_line_bulk_add().