libgpiod  1.1.1
gpiod.h
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2 /*
3  * This file is part of libgpiod.
4  *
5  * Copyright (C) 2017-2018 Bartosz Golaszewski <bartekgola@gmail.com>
6  */
7 
8 #ifndef __LIBGPIOD_GPIOD_H__
9 #define __LIBGPIOD_GPIOD_H__
10 
11 #include <stdlib.h>
12 #include <stdbool.h>
13 #include <time.h>
14 
15 #ifdef __cplusplus
16 extern "C" {
17 #endif
18 
42 struct gpiod_chip;
43 struct gpiod_line;
44 struct gpiod_chip_iter;
45 struct gpiod_line_iter;
46 struct gpiod_line_bulk;
47 
58 #define GPIOD_API __attribute__((visibility("default")))
59 
63 #define GPIOD_UNUSED __attribute__((unused))
64 
70 #define GPIOD_BIT(nr) (1UL << (nr))
71 
90 int gpiod_ctxless_get_value(const char *device, unsigned int offset,
91  bool active_low, const char *consumer) GPIOD_API;
92 
103 int gpiod_ctxless_get_value_multiple(const char *device,
104  const unsigned int *offsets, int *values,
105  unsigned int num_lines, bool active_low,
106  const char *consumer) GPIOD_API;
107 
111 typedef void (*gpiod_ctxless_set_value_cb)(void *);
112 
126 int gpiod_ctxless_set_value(const char *device, unsigned int offset, int value,
127  bool active_low, const char *consumer,
129  void *data) GPIOD_API;
130 
144 int gpiod_ctxless_set_value_multiple(const char *device,
145  const unsigned int *offsets,
146  const int *values, unsigned int num_lines,
147  bool active_low, const char *consumer,
149  void *data) GPIOD_API;
150 
154 enum {
161 };
162 
166 enum {
173 };
174 
186 typedef int (*gpiod_ctxless_event_handle_cb)(int, unsigned int,
187  const struct timespec *, void *);
188 
195 enum {
202 };
203 
208  int fd;
210  bool event;
212 };
213 
226 typedef int (*gpiod_ctxless_event_poll_cb)(unsigned int,
228  const struct timespec *, void *);
229 
245 int gpiod_ctxless_event_loop(const char *device, unsigned int offset,
246  bool active_low, const char *consumer,
247  const struct timespec *timeout,
250  void *data) GPIOD_API;
251 
280 int gpiod_ctxless_event_loop_multiple(const char *device,
281  const unsigned int *offsets,
282  unsigned int num_lines, bool active_low,
283  const char *consumer,
284  const struct timespec *timeout,
287  void *data) GPIOD_API;
288 
300 int gpiod_ctxless_find_line(const char *name, char *chipname,
301  size_t chipname_size,
302  unsigned int *offset) GPIOD_API;
303 
318 struct gpiod_chip *gpiod_chip_open(const char *path) GPIOD_API;
319 
327 struct gpiod_chip *gpiod_chip_open_by_name(const char *name) GPIOD_API;
328 
336 struct gpiod_chip *gpiod_chip_open_by_number(unsigned int num) GPIOD_API;
337 
346 struct gpiod_chip *gpiod_chip_open_by_label(const char *label) GPIOD_API;
347 
357 struct gpiod_chip *gpiod_chip_open_lookup(const char *descr) GPIOD_API;
358 
363 void gpiod_chip_close(struct gpiod_chip *chip) GPIOD_API;
364 
370 const char *gpiod_chip_name(struct gpiod_chip *chip) GPIOD_API;
371 
377 const char *gpiod_chip_label(struct gpiod_chip *chip) GPIOD_API;
378 
384 unsigned int gpiod_chip_num_lines(struct gpiod_chip *chip) GPIOD_API;
385 
392 struct gpiod_line *
393 gpiod_chip_get_line(struct gpiod_chip *chip, unsigned int offset) GPIOD_API;
394 
403 int gpiod_chip_get_lines(struct gpiod_chip *chip,
404  unsigned int *offsets, unsigned int num_offsets,
405  struct gpiod_line_bulk *bulk) GPIOD_API;
406 
413 int gpiod_chip_get_all_lines(struct gpiod_chip *chip,
414  struct gpiod_line_bulk *bulk) GPIOD_API;
415 
425 struct gpiod_line *
426 gpiod_chip_find_line(struct gpiod_chip *chip, const char *name) GPIOD_API;
427 
438 int gpiod_chip_find_lines(struct gpiod_chip *chip, const char **names,
439  struct gpiod_line_bulk *bulk) GPIOD_API;
440 
456 #define GPIOD_LINE_BULK_MAX_LINES 64
457 
466  struct gpiod_line *lines[GPIOD_LINE_BULK_MAX_LINES];
468  unsigned int num_lines;
470 };
471 
477 #define GPIOD_LINE_BULK_INITIALIZER { { NULL }, 0 }
478 
485 static inline void gpiod_line_bulk_init(struct gpiod_line_bulk *bulk)
486 {
487  bulk->num_lines = 0;
488 }
489 
495 static inline void gpiod_line_bulk_add(struct gpiod_line_bulk *bulk,
496  struct gpiod_line *line)
497 {
498  bulk->lines[bulk->num_lines++] = line;
499 }
500 
507 static inline struct gpiod_line *
508 gpiod_line_bulk_get_line(struct gpiod_line_bulk *bulk, unsigned int offset)
509 {
510  return bulk->lines[offset];
511 }
512 
518 static inline unsigned int
520 {
521  return bulk->num_lines;
522 }
523 
531 #define gpiod_line_bulk_foreach_line(bulk, line, lineptr) \
532  for ((lineptr) = (bulk)->lines, (line) = *(lineptr); \
533  (lineptr) <= (bulk)->lines + ((bulk)->num_lines - 1); \
534  (lineptr)++, (line) = *(lineptr))
535 
549 #define gpiod_line_bulk_foreach_line_off(bulk, line, offset) \
550  for ((offset) = 0, (line) = (bulk)->lines[0]; \
551  (offset) < (bulk)->num_lines; \
552  (offset)++, (line) = (bulk)->lines[(offset)])
553 
564 enum {
569 };
570 
574 enum {
579 };
580 
586 unsigned int gpiod_line_offset(struct gpiod_line *line) GPIOD_API;
587 
595 const char *gpiod_line_name(struct gpiod_line *line) GPIOD_API;
596 
604 const char *gpiod_line_consumer(struct gpiod_line *line) GPIOD_API;
605 
611 int gpiod_line_direction(struct gpiod_line *line) GPIOD_API;
612 
618 int gpiod_line_active_state(struct gpiod_line *line) GPIOD_API;
619 
629 bool gpiod_line_is_used(struct gpiod_line *line) GPIOD_API;
630 
636 bool gpiod_line_is_open_drain(struct gpiod_line *line) GPIOD_API;
637 
643 bool gpiod_line_is_open_source(struct gpiod_line *line) GPIOD_API;
644 
655 int gpiod_line_update(struct gpiod_line *line) GPIOD_API;
656 
670 bool gpiod_line_needs_update(struct gpiod_line *line) GPIOD_API;
671 
682 enum {
695 };
696 
700 enum {
707 };
708 
713  const char *consumer;
717  int flags;
719 };
720 
733 int gpiod_line_request(struct gpiod_line *line,
734  const struct gpiod_line_request_config *config,
735  int default_val) GPIOD_API;
736 
743 int gpiod_line_request_input(struct gpiod_line *line,
744  const char *consumer) GPIOD_API;
745 
753 int gpiod_line_request_output(struct gpiod_line *line,
754  const char *consumer, int default_val) GPIOD_API;
755 
762 int gpiod_line_request_rising_edge_events(struct gpiod_line *line,
763  const char *consumer) GPIOD_API;
764 
771 int gpiod_line_request_falling_edge_events(struct gpiod_line *line,
772  const char *consumer) GPIOD_API;
773 
780 int gpiod_line_request_both_edges_events(struct gpiod_line *line,
781  const char *consumer) GPIOD_API;
782 
790 int gpiod_line_request_input_flags(struct gpiod_line *line,
791  const char *consumer, int flags) GPIOD_API;
792 
801 int gpiod_line_request_output_flags(struct gpiod_line *line,
802  const char *consumer, int flags,
803  int default_val) GPIOD_API;
804 
812 int gpiod_line_request_rising_edge_events_flags(struct gpiod_line *line,
813  const char *consumer,
814  int flags) GPIOD_API;
815 
823 int gpiod_line_request_falling_edge_events_flags(struct gpiod_line *line,
824  const char *consumer,
825  int flags) GPIOD_API;
826 
834 int gpiod_line_request_both_edges_events_flags(struct gpiod_line *line,
835  const char *consumer,
836  int flags) GPIOD_API;
837 
852  const struct gpiod_line_request_config *config,
853  const int *default_vals) GPIOD_API;
854 
862  const char *consumer) GPIOD_API;
863 
872  const char *consumer,
873  const int *default_vals) GPIOD_API;
874 
882  const char *consumer) GPIOD_API;
883 
891  const char *consumer) GPIOD_API;
892 
900  const char *consumer) GPIOD_API;
901 
910  const char *consumer,
911  int flags) GPIOD_API;
912 
922  const char *consumer, int flags,
923  const int *default_vals) GPIOD_API;
924 
933  struct gpiod_line_bulk *bulk,
934  const char *consumer,
935  int flags) GPIOD_API;
936 
945  struct gpiod_line_bulk *bulk,
946  const char *consumer,
947  int flags) GPIOD_API;
948 
957  struct gpiod_line_bulk *bulk,
958  const char *consumer,
959  int flags) GPIOD_API;
960 
965 void gpiod_line_release(struct gpiod_line *line) GPIOD_API;
966 
975 
981 bool gpiod_line_is_requested(struct gpiod_line *line) GPIOD_API;
982 
989 bool gpiod_line_is_free(struct gpiod_line *line) GPIOD_API;
990 
1004 int gpiod_line_get_value(struct gpiod_line *line) GPIOD_API;
1005 
1018  int *values) GPIOD_API;
1019 
1027 int gpiod_line_set_value(struct gpiod_line *line, int value) GPIOD_API;
1028 
1040  const int *values) GPIOD_API;
1041 
1052 enum {
1057 };
1058 
1063  struct timespec ts;
1067 };
1068 
1076 int gpiod_line_event_wait(struct gpiod_line *line,
1077  const struct timespec *timeout) GPIOD_API;
1078 
1089  const struct timespec *timeout,
1090  struct gpiod_line_bulk *event_bulk) GPIOD_API;
1091 
1099 int gpiod_line_event_read(struct gpiod_line *line,
1100  struct gpiod_line_event *event) GPIOD_API;
1101 
1112 int gpiod_line_event_get_fd(struct gpiod_line *line) GPIOD_API;
1113 
1125 
1145 struct gpiod_line *
1146 gpiod_line_get(const char *device, unsigned int offset) GPIOD_API;
1147 
1158 struct gpiod_line *gpiod_line_find(const char *name) GPIOD_API;
1159 
1166 void gpiod_line_close_chip(struct gpiod_line *line) GPIOD_API;
1167 
1173 struct gpiod_chip *gpiod_line_get_chip(struct gpiod_line *line) GPIOD_API;
1174 
1195 struct gpiod_chip_iter *gpiod_chip_iter_new(void) GPIOD_API;
1196 
1202 void gpiod_chip_iter_free(struct gpiod_chip_iter *iter) GPIOD_API;
1203 
1213 void gpiod_chip_iter_free_noclose(struct gpiod_chip_iter *iter) GPIOD_API;
1214 
1222 struct gpiod_chip *
1223 gpiod_chip_iter_next(struct gpiod_chip_iter *iter) GPIOD_API;
1224 
1233 struct gpiod_chip *
1234 gpiod_chip_iter_next_noclose(struct gpiod_chip_iter *iter) GPIOD_API;
1235 
1246 #define gpiod_foreach_chip(iter, chip) \
1247  for ((chip) = gpiod_chip_iter_next(iter); \
1248  (chip); \
1249  (chip) = gpiod_chip_iter_next(iter))
1250 
1261 #define gpiod_foreach_chip_noclose(iter, chip) \
1262  for ((chip) = gpiod_chip_iter_next_noclose(iter); \
1263  (chip); \
1264  (chip) = gpiod_chip_iter_next_noclose(iter))
1265 
1272 struct gpiod_line_iter *
1273 gpiod_line_iter_new(struct gpiod_chip *chip) GPIOD_API;
1274 
1279 void gpiod_line_iter_free(struct gpiod_line_iter *iter) GPIOD_API;
1280 
1287 struct gpiod_line *
1288 gpiod_line_iter_next(struct gpiod_line_iter *iter) GPIOD_API;
1289 
1296 #define gpiod_foreach_line(iter, line) \
1297  for ((line) = gpiod_line_iter_next(iter); \
1298  (line); \
1299  (line) = gpiod_line_iter_next(iter))
1300 
1314 const char *gpiod_version_string(void) GPIOD_API;
1315 
1320 #ifdef __cplusplus
1321 } /* extern "C" */
1322 #endif
1323 
1324 #endif /* __LIBGPIOD_GPIOD_H__ */
int(* gpiod_ctxless_event_poll_cb)(unsigned int, struct gpiod_ctxless_event_poll_fd *, const struct timespec *, void *)
Simple event poll callback signature.
Definition: gpiod.h:226
int gpiod_line_event_get_fd(struct gpiod_line *line) GPIOD_API
Get the event file descriptor.
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.
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.
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.
Helper structure for the ctxless event loop poll callback.
Definition: gpiod.h:207
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.
Definition: gpiod.h:508
int gpiod_line_get_value(struct gpiod_line *line) GPIOD_API
Read current value of a single GPIO line.
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.
Rising edge event.
Definition: gpiod.h:1053
const char * gpiod_chip_name(struct gpiod_chip *chip) GPIOD_API
Get the GPIO chip name as represented in the kernel.
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.
const char * gpiod_line_consumer(struct gpiod_line *line) GPIOD_API
Read the GPIO line consumer name.
struct gpiod_line_iter * gpiod_line_iter_new(struct gpiod_chip *chip) GPIOD_API
Create a new line iterator.
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.
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.
Falling edge event.
Definition: gpiod.h:1055
struct gpiod_chip * gpiod_chip_open_lookup(const char *descr) GPIOD_API
Open a gpiochip based on the best guess what the path is.
const char * gpiod_line_name(struct gpiod_line *line) GPIOD_API
Read the GPIO line name.
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.
The line is an open-source port.
Definition: gpiod.h:703
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.
Definition: gpiod.h:519
int gpiod_line_set_value(struct gpiod_line *line, int value) GPIOD_API
Set the value of a single GPIO line.
unsigned int num_lines
Number of lines currently held in this structure.
Definition: gpiod.h:468
void gpiod_chip_close(struct gpiod_chip *chip) GPIOD_API
Close a GPIO chip handle and release all allocated resources.
Only watch rising edge events.
Definition: gpiod.h:691
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.
Stop processing events.
Definition: gpiod.h:171
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.
static void gpiod_line_bulk_add(struct gpiod_line_bulk *bulk, struct gpiod_line *line)
Add a single line to a GPIO bulk object.
Definition: gpiod.h:495
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.
#define GPIOD_LINE_BULK_MAX_LINES
Maximum number of GPIO lines that can be requested at once.
Definition: gpiod.h:456
#define GPIOD_API
Makes symbol visible.
Definition: gpiod.h:58
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.
bool gpiod_line_is_used(struct gpiod_line *line) GPIOD_API
Check if the line is currently in use.
struct gpiod_chip * gpiod_chip_open_by_number(unsigned int num) GPIOD_API
Open a gpiochip by number.
static void gpiod_line_bulk_init(struct gpiod_line_bulk *bulk)
Initialize a GPIO bulk object.
Definition: gpiod.h:485
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.
int gpiod_line_active_state(struct gpiod_line *line) GPIOD_API
Read the GPIO line active state setting.
void(* gpiod_ctxless_set_value_cb)(void *)
Simple set value callback signature.
Definition: gpiod.h:111
The active state of a GPIO is active-high.
Definition: gpiod.h:575
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.
struct gpiod_chip * gpiod_chip_open(const char *path) GPIOD_API
Open a gpiochip by path.
Structure holding event info.
Definition: gpiod.h:1062
bool event
Indicates whether an event occurred on this file descriptor.
Definition: gpiod.h:210
int fd
File descriptor number.
Definition: gpiod.h:208
int gpiod_line_direction(struct gpiod_line *line) GPIOD_API
Read the GPIO line direction setting.
int(* gpiod_ctxless_event_handle_cb)(int, unsigned int, const struct timespec *, void *)
Simple event callack signature.
Definition: gpiod.h:186
bool gpiod_line_needs_update(struct gpiod_line *line) GPIOD_API
Check if the line info needs to be updated.
struct gpiod_chip_iter * gpiod_chip_iter_new(void) GPIOD_API
Create a new gpiochip iterator.
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...
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.
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
Wait for events on multiple GPIO lines.
#define GPIOD_BIT(nr)
Shift 1 by given offset.
Definition: gpiod.h:70
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 notif...
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.
struct gpiod_chip * gpiod_chip_open_by_name(const char *name) GPIOD_API
Open a gpiochip by name.
bool gpiod_line_is_requested(struct gpiod_line *line) GPIOD_API
Check if the calling user has ownership of this line.
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.
struct gpiod_line * lines[GPIOD_LINE_BULK_MAX_LINES]
Buffer for line pointers.
Definition: gpiod.h:466
void gpiod_line_iter_free(struct gpiod_line_iter *iter) GPIOD_API
Free all resources associated with a GPIO line iterator.
void gpiod_line_release_bulk(struct gpiod_line_bulk *bulk) GPIOD_API
Release a set of previously reserved lines.
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.
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.
Monitor both types of events.
Definition: gpiod.h:689
Helper structure for storing a set of GPIO line objects.
Definition: gpiod.h:465
int gpiod_line_request(struct gpiod_line *line, const struct gpiod_line_request_config *config, int default_val) GPIOD_API
Reserve a single line.
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.
The active state of a GPIO is active-low.
Definition: gpiod.h:577
int event_type
Type of the event that occurred.
Definition: gpiod.h:1065
int request_type
Request type.
Definition: gpiod.h:715
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.
The line is an open-drain port.
Definition: gpiod.h:701
Request the line(s) for setting the GPIO line state.
Definition: gpiod.h:687
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.
const char * consumer
Name of the consumer.
Definition: gpiod.h:713
Request the line(s) for reading the GPIO line state.
Definition: gpiod.h:685
bool gpiod_line_is_open_source(struct gpiod_line *line) GPIOD_API
Check if the line is an open-source GPIO.
Continue processing events.
Definition: gpiod.h:169
The active state of the line is low (high is the default).
Definition: gpiod.h:705
int flags
Other configuration flags.
Definition: gpiod.h:717
int gpiod_line_event_read(struct gpiod_line *line, struct gpiod_line_event *event) GPIOD_API
Read the last event from the GPIO line.
struct gpiod_chip * gpiod_chip_open_by_label(const char *label) GPIOD_API
Open a gpiochip by label.
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.
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.
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.
Polling error occurred (the polling function should set errno).
Definition: gpiod.h:198
Only watch falling edge events.
Definition: gpiod.h:693
int gpiod_line_event_wait(struct gpiod_line *line, const struct timespec *timeout) GPIOD_API
Wait for an event on a single line.
const char * gpiod_chip_label(struct gpiod_chip *chip) GPIOD_API
Get the GPIO chip label as represented in the kernel.
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.
struct gpiod_chip * gpiod_line_get_chip(struct gpiod_line *line) GPIOD_API
Get the handle to the GPIO chip controlling this line.
Waiting for events timed out.
Definition: gpiod.h:155
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.
Request the line(s), but don&#39;t change current direction.
Definition: gpiod.h:683
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.
void gpiod_line_release(struct gpiod_line *line) GPIOD_API
Release a previously reserved line.
Direction is input - we&#39;re reading the state of a GPIO line.
Definition: gpiod.h:565
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.
bool gpiod_line_is_open_drain(struct gpiod_line *line) GPIOD_API
Check if the line is an open-drain GPIO.
Direction is output - we&#39;re driving the GPIO line.
Definition: gpiod.h:567
Falling edge event occured.
Definition: gpiod.h:159
Rising edge event occured.
Definition: gpiod.h:157
unsigned int gpiod_line_offset(struct gpiod_line *line) GPIOD_API
Read the GPIO line offset.
struct gpiod_line * gpiod_line_find(const char *name) GPIOD_API
Find a GPIO line by its name.
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.
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.
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.
Structure holding configuration of a line request.
Definition: gpiod.h:712
int gpiod_line_request_input(struct gpiod_line *line, const char *consumer) GPIOD_API
Reserve a single line, set the direction to input.
const char * gpiod_version_string(void) GPIOD_API
Get the API version of the library as a human-readable string.
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.
struct gpiod_line * gpiod_line_iter_next(struct gpiod_line_iter *iter) GPIOD_API
Get the next GPIO line handle.
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
Wait for events on a single GPIO line.
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.
The event loop should stop processing events.
Definition: gpiod.h:196
void gpiod_line_close_chip(struct gpiod_line *line) GPIOD_API
Close a GPIO chip owning this line and release all resources.
void gpiod_chip_iter_free_noclose(struct gpiod_chip_iter *iter) GPIOD_API
Release all resources allocated for the gpiochip iterator but don&#39;t close the most recently opened gp...
int gpiod_line_get_value_bulk(struct gpiod_line_bulk *bulk, int *values) GPIOD_API
Read current values of a set of GPIO lines.
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.
struct gpiod_chip * gpiod_chip_iter_next(struct gpiod_chip_iter *iter) GPIOD_API
Get the next gpiochip handle.
int gpiod_line_update(struct gpiod_line *line) GPIOD_API
Re-read the line info.
Stop processing events and indicate an error.
Definition: gpiod.h:167
unsigned int gpiod_chip_num_lines(struct gpiod_chip *chip) GPIOD_API
Get the number of GPIO lines exposed by this chip.