These functions and data structures allow easy iterating over GPIO chips and lines.
More...
These functions and data structures allow easy iterating over GPIO chips and lines.
◆ gpiod_foreach_chip
#define gpiod_foreach_chip |
( |
|
iter, |
|
|
|
chip |
|
) |
| |
Value:
Iterate over all GPIO chips present in the system.
- Parameters
-
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.
Definition at line 1697 of file gpiod.h.
◆ gpiod_foreach_chip_noclose
#define gpiod_foreach_chip_noclose |
( |
|
iter, |
|
|
|
chip |
|
) |
| |
Value:
Iterate over all chips present in the system without closing them.
- Parameters
-
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.
Definition at line 1712 of file gpiod.h.
◆ gpiod_foreach_line
#define gpiod_foreach_line |
( |
|
iter, |
|
|
|
line |
|
) |
| |
Value:
Iterate over all GPIO lines of a single chip.
- Parameters
-
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. |
Definition at line 1747 of file gpiod.h.
◆ gpiod_chip_iter_free()
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).
- Parameters
-
iter | The gpiochip iterator object. |
◆ gpiod_chip_iter_free_noclose()
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).
- Parameters
-
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.
◆ gpiod_chip_iter_new()
struct gpiod_chip_iter* gpiod_chip_iter_new |
( |
void |
| ) |
|
Create a new gpiochip iterator.
- Returns
- Pointer to a new chip iterator object or NULL if an error occurred.
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.
◆ gpiod_chip_iter_next()
struct gpiod_chip* gpiod_chip_iter_next |
( |
struct gpiod_chip_iter * |
iter | ) |
|
Get the next gpiochip handle.
- Parameters
-
iter | The gpiochip iterator object. |
- Returns
- Pointer to the next open gpiochip handle or NULL if no more chips are present in the system.
- Note
- The previous chip handle will be closed using gpiod_chip_iter_free.
◆ gpiod_chip_iter_next_noclose()
struct gpiod_chip* gpiod_chip_iter_next_noclose |
( |
struct gpiod_chip_iter * |
iter | ) |
|
Get the next gpiochip handle without closing the previous one.
- Parameters
-
iter | The gpiochip iterator object. |
- Returns
- Pointer to the next open gpiochip handle or NULL if no more chips are present in the system.
- Note
- This function works just like gpiod_chip_iter_next but doesn't close the most recently opened chip handle.
◆ gpiod_line_iter_free()
void gpiod_line_iter_free |
( |
struct gpiod_line_iter * |
iter | ) |
|
Free all resources associated with a GPIO line iterator.
- Parameters
-
iter | Line iterator object. |
◆ gpiod_line_iter_new()
struct gpiod_line_iter* gpiod_line_iter_new |
( |
struct gpiod_chip * |
chip | ) |
|
Create a new line iterator.
- Parameters
-
chip | Active gpiochip handle over the lines of which we want to iterate. |
- Returns
- New line iterator or NULL if an error occurred.
◆ gpiod_line_iter_next()
struct gpiod_line* gpiod_line_iter_next |
( |
struct gpiod_line_iter * |
iter | ) |
|
Get the next GPIO line handle.
- Parameters
-
iter | The GPIO line iterator object. |
- Returns
- Pointer to the next GPIO line handle or NULL if there are no more lines left.