Functions and data structures dealing with GPIO chips.
More...
Functions and data structures dealing with GPIO chips.
◆ gpiod_chip_close()
void gpiod_chip_close |
( |
struct gpiod_chip * |
chip | ) |
|
Close a GPIO chip handle and release all allocated resources.
- Parameters
-
chip | The GPIO chip object. |
◆ gpiod_chip_find_line()
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.
- Parameters
-
chip | The GPIO chip object. |
name | The name of the GPIO line. |
- Returns
- Pointer to the GPIO line handle or NULL if the line could not be found or an error occurred.
- Note
- In case a line with given name is not associated with given chip, the function sets errno to ENOENT.
- Attention
- GPIO line names are not unique in the linux kernel, neither globally nor within a single chip. This function finds the first line with given name.
◆ gpiod_chip_find_lines()
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.
- Parameters
-
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. |
- Returns
- 0 if all lines were located, -1 on error.
- Note
- If at least one line from the list could not be found among the lines exposed by this chip, the function sets errno to ENOENT.
- Attention
- GPIO line names are not unique in the linux kernel, neither globally nor within a single chip. This function finds the first line with given name.
◆ gpiod_chip_get_all_lines()
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.
- Parameters
-
chip | The GPIO chip object. |
bulk | Line bulk object in which to store the line handles. |
- Returns
- 0 on success, -1 on error.
◆ gpiod_chip_get_line()
struct gpiod_line* gpiod_chip_get_line |
( |
struct gpiod_chip * |
chip, |
|
|
unsigned int |
offset |
|
) |
| |
Get the handle to the GPIO line at given offset.
- Parameters
-
chip | The GPIO chip object. |
offset | The offset of the GPIO line. |
- Returns
- Pointer to the GPIO line handle or NULL if an error occured.
◆ gpiod_chip_get_lines()
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.
- Parameters
-
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. |
- Returns
- 0 on success, -1 on error.
◆ gpiod_chip_label()
const char* gpiod_chip_label |
( |
struct gpiod_chip * |
chip | ) |
|
Get the GPIO chip label as represented in the kernel.
- Parameters
-
chip | The GPIO chip object. |
- Returns
- Pointer to a human-readable string containing the chip label.
◆ gpiod_chip_name()
const char* gpiod_chip_name |
( |
struct gpiod_chip * |
chip | ) |
|
Get the GPIO chip name as represented in the kernel.
- Parameters
-
chip | The GPIO chip object. |
- Returns
- Pointer to a human-readable string containing the chip name.
◆ gpiod_chip_num_lines()
unsigned int gpiod_chip_num_lines |
( |
struct gpiod_chip * |
chip | ) |
|
Get the number of GPIO lines exposed by this chip.
- Parameters
-
chip | The GPIO chip object. |
- Returns
- Number of GPIO lines.
◆ gpiod_chip_open()
struct gpiod_chip* gpiod_chip_open |
( |
const char * |
path | ) |
|
Open a gpiochip by path.
- Parameters
-
path | Path to the gpiochip device file. |
- Returns
- GPIO chip handle or NULL if an error occurred.
◆ gpiod_chip_open_by_label()
struct gpiod_chip* gpiod_chip_open_by_label |
( |
const char * |
label | ) |
|
Open a gpiochip by label.
- Parameters
-
label | Label of the gpiochip to open. |
- Returns
- GPIO chip handle or NULL if the chip with given label was not found or an error occured.
- Note
- If the chip cannot be found but no other error occurred, errno is set to ENOENT.
◆ gpiod_chip_open_by_name()
struct gpiod_chip* gpiod_chip_open_by_name |
( |
const char * |
name | ) |
|
Open a gpiochip by name.
- Parameters
-
name | Name of the gpiochip to open. |
- Returns
- GPIO chip handle or NULL if an error occurred.
This routine appends name to '/dev/' to create the path.
◆ gpiod_chip_open_by_number()
struct gpiod_chip* gpiod_chip_open_by_number |
( |
unsigned int |
num | ) |
|
Open a gpiochip by number.
- Parameters
-
num | Number of the gpiochip. |
- Returns
- GPIO chip handle or NULL if an error occurred.
This routine appends num to '/dev/gpiochip' to create the path.
◆ gpiod_chip_open_lookup()
struct gpiod_chip* gpiod_chip_open_lookup |
( |
const char * |
descr | ) |
|
Open a gpiochip based on the best guess what the path is.
- Parameters
-
descr | String describing the gpiochip. |
- Returns
- GPIO chip handle or NULL if an error occurred.
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.