libgpiod  1.2
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 
75 #define GPIOD_DEPRECATED __attribute__((deprecated))
76 
95 int gpiod_ctxless_get_value(const char *device, unsigned int offset,
96  bool active_low, const char *consumer) GPIOD_API;
97 
108 int gpiod_ctxless_get_value_multiple(const char *device,
109  const unsigned int *offsets, int *values,
110  unsigned int num_lines, bool active_low,
111  const char *consumer) GPIOD_API;
112 
116 typedef void (*gpiod_ctxless_set_value_cb)(void *);
117 
131 int gpiod_ctxless_set_value(const char *device, unsigned int offset, int value,
132  bool active_low, const char *consumer,
134  void *data) GPIOD_API;
135 
149 int gpiod_ctxless_set_value_multiple(const char *device,
150  const unsigned int *offsets,
151  const int *values, unsigned int num_lines,
152  bool active_low, const char *consumer,
154  void *data) GPIOD_API;
155 
159 enum {
165  GPIOD_CTXLESS_EVENT_BOTH_EDGES,
166 };
167 
171 enum {
178 };
179 
183 enum {
190 };
191 
203 typedef int (*gpiod_ctxless_event_handle_cb)(int, unsigned int,
204  const struct timespec *, void *);
205 
212 enum {
219 };
220 
225  int fd;
227  bool event;
229 };
230 
243 typedef int (*gpiod_ctxless_event_poll_cb)(unsigned int,
245  const struct timespec *, void *);
246 
262 int gpiod_ctxless_event_loop(const char *device, unsigned int offset,
263  bool active_low, const char *consumer,
264  const struct timespec *timeout,
267  void *data) GPIOD_API GPIOD_DEPRECATED;
268 
297 int gpiod_ctxless_event_loop_multiple(const char *device,
298  const unsigned int *offsets,
299  unsigned int num_lines, bool active_low,
300  const char *consumer,
301  const struct timespec *timeout,
304  void *data) GPIOD_API GPIOD_DEPRECATED;
305 
322 int gpiod_ctxless_event_monitor(const char *device, int event_type,
323  unsigned int offset, bool active_low,
324  const char *consumer,
325  const struct timespec *timeout,
328  void *data) GPIOD_API;
329 
361  const char *device, int event_type,
362  const unsigned int *offsets,
363  unsigned int num_lines, bool active_low,
364  const char *consumer, const struct timespec *timeout,
367  void *data) GPIOD_API;
368 
380 int gpiod_ctxless_find_line(const char *name, char *chipname,
381  size_t chipname_size,
382  unsigned int *offset) GPIOD_API;
383 
398 struct gpiod_chip *gpiod_chip_open(const char *path) GPIOD_API;
399 
407 struct gpiod_chip *gpiod_chip_open_by_name(const char *name) GPIOD_API;
408 
416 struct gpiod_chip *gpiod_chip_open_by_number(unsigned int num) GPIOD_API;
417 
426 struct gpiod_chip *gpiod_chip_open_by_label(const char *label) GPIOD_API;
427 
437 struct gpiod_chip *gpiod_chip_open_lookup(const char *descr) GPIOD_API;
438 
443 void gpiod_chip_close(struct gpiod_chip *chip) GPIOD_API;
444 
450 const char *gpiod_chip_name(struct gpiod_chip *chip) GPIOD_API;
451 
457 const char *gpiod_chip_label(struct gpiod_chip *chip) GPIOD_API;
458 
464 unsigned int gpiod_chip_num_lines(struct gpiod_chip *chip) GPIOD_API;
465 
472 struct gpiod_line *
473 gpiod_chip_get_line(struct gpiod_chip *chip, unsigned int offset) GPIOD_API;
474 
483 int gpiod_chip_get_lines(struct gpiod_chip *chip,
484  unsigned int *offsets, unsigned int num_offsets,
485  struct gpiod_line_bulk *bulk) GPIOD_API;
486 
493 int gpiod_chip_get_all_lines(struct gpiod_chip *chip,
494  struct gpiod_line_bulk *bulk) GPIOD_API;
495 
505 struct gpiod_line *
506 gpiod_chip_find_line(struct gpiod_chip *chip, const char *name) GPIOD_API;
507 
518 int gpiod_chip_find_lines(struct gpiod_chip *chip, const char **names,
519  struct gpiod_line_bulk *bulk) GPIOD_API;
520 
536 #define GPIOD_LINE_BULK_MAX_LINES 64
537 
546  struct gpiod_line *lines[GPIOD_LINE_BULK_MAX_LINES];
548  unsigned int num_lines;
550 };
551 
557 #define GPIOD_LINE_BULK_INITIALIZER { { NULL }, 0 }
558 
565 static inline void gpiod_line_bulk_init(struct gpiod_line_bulk *bulk)
566 {
567  bulk->num_lines = 0;
568 }
569 
575 static inline void gpiod_line_bulk_add(struct gpiod_line_bulk *bulk,
576  struct gpiod_line *line)
577 {
578  bulk->lines[bulk->num_lines++] = line;
579 }
580 
587 static inline struct gpiod_line *
588 gpiod_line_bulk_get_line(struct gpiod_line_bulk *bulk, unsigned int offset)
589 {
590  return bulk->lines[offset];
591 }
592 
598 static inline unsigned int
600 {
601  return bulk->num_lines;
602 }
603 
611 #define gpiod_line_bulk_foreach_line(bulk, line, lineptr) \
612  for ((lineptr) = (bulk)->lines, (line) = *(lineptr); \
613  (lineptr) <= (bulk)->lines + ((bulk)->num_lines - 1); \
614  (lineptr)++, (line) = *(lineptr))
615 
629 #define gpiod_line_bulk_foreach_line_off(bulk, line, offset) \
630  for ((offset) = 0, (line) = (bulk)->lines[0]; \
631  (offset) < (bulk)->num_lines; \
632  (offset)++, (line) = (bulk)->lines[(offset)])
633 
644 enum {
649 };
650 
654 enum {
659 };
660 
666 unsigned int gpiod_line_offset(struct gpiod_line *line) GPIOD_API;
667 
675 const char *gpiod_line_name(struct gpiod_line *line) GPIOD_API;
676 
684 const char *gpiod_line_consumer(struct gpiod_line *line) GPIOD_API;
685 
691 int gpiod_line_direction(struct gpiod_line *line) GPIOD_API;
692 
698 int gpiod_line_active_state(struct gpiod_line *line) GPIOD_API;
699 
709 bool gpiod_line_is_used(struct gpiod_line *line) GPIOD_API;
710 
716 bool gpiod_line_is_open_drain(struct gpiod_line *line) GPIOD_API;
717 
723 bool gpiod_line_is_open_source(struct gpiod_line *line) GPIOD_API;
724 
735 int gpiod_line_update(struct gpiod_line *line) GPIOD_API;
736 
750 bool gpiod_line_needs_update(struct gpiod_line *line) GPIOD_API;
751 
762 enum {
775 };
776 
780 enum {
787 };
788 
793  const char *consumer;
797  int flags;
799 };
800 
813 int gpiod_line_request(struct gpiod_line *line,
814  const struct gpiod_line_request_config *config,
815  int default_val) GPIOD_API;
816 
823 int gpiod_line_request_input(struct gpiod_line *line,
824  const char *consumer) GPIOD_API;
825 
833 int gpiod_line_request_output(struct gpiod_line *line,
834  const char *consumer, int default_val) GPIOD_API;
835 
842 int gpiod_line_request_rising_edge_events(struct gpiod_line *line,
843  const char *consumer) GPIOD_API;
844 
851 int gpiod_line_request_falling_edge_events(struct gpiod_line *line,
852  const char *consumer) GPIOD_API;
853 
860 int gpiod_line_request_both_edges_events(struct gpiod_line *line,
861  const char *consumer) GPIOD_API;
862 
870 int gpiod_line_request_input_flags(struct gpiod_line *line,
871  const char *consumer, int flags) GPIOD_API;
872 
881 int gpiod_line_request_output_flags(struct gpiod_line *line,
882  const char *consumer, int flags,
883  int default_val) GPIOD_API;
884 
892 int gpiod_line_request_rising_edge_events_flags(struct gpiod_line *line,
893  const char *consumer,
894  int flags) GPIOD_API;
895 
903 int gpiod_line_request_falling_edge_events_flags(struct gpiod_line *line,
904  const char *consumer,
905  int flags) GPIOD_API;
906 
914 int gpiod_line_request_both_edges_events_flags(struct gpiod_line *line,
915  const char *consumer,
916  int flags) GPIOD_API;
917 
932  const struct gpiod_line_request_config *config,
933  const int *default_vals) GPIOD_API;
934 
942  const char *consumer) GPIOD_API;
943 
952  const char *consumer,
953  const int *default_vals) GPIOD_API;
954 
962  const char *consumer) GPIOD_API;
963 
971  const char *consumer) GPIOD_API;
972 
980  const char *consumer) GPIOD_API;
981 
990  const char *consumer,
991  int flags) GPIOD_API;
992 
1002  const char *consumer, int flags,
1003  const int *default_vals) GPIOD_API;
1004 
1013  struct gpiod_line_bulk *bulk,
1014  const char *consumer,
1015  int flags) GPIOD_API;
1016 
1025  struct gpiod_line_bulk *bulk,
1026  const char *consumer,
1027  int flags) GPIOD_API;
1028 
1037  struct gpiod_line_bulk *bulk,
1038  const char *consumer,
1039  int flags) GPIOD_API;
1040 
1045 void gpiod_line_release(struct gpiod_line *line) GPIOD_API;
1046 
1055 
1061 bool gpiod_line_is_requested(struct gpiod_line *line) GPIOD_API;
1062 
1069 bool gpiod_line_is_free(struct gpiod_line *line) GPIOD_API;
1070 
1084 int gpiod_line_get_value(struct gpiod_line *line) GPIOD_API;
1085 
1098  int *values) GPIOD_API;
1099 
1107 int gpiod_line_set_value(struct gpiod_line *line, int value) GPIOD_API;
1108 
1120  const int *values) GPIOD_API;
1121 
1132 enum {
1137 };
1138 
1143  struct timespec ts;
1147 };
1148 
1156 int gpiod_line_event_wait(struct gpiod_line *line,
1157  const struct timespec *timeout) GPIOD_API;
1158 
1169  const struct timespec *timeout,
1170  struct gpiod_line_bulk *event_bulk) GPIOD_API;
1171 
1179 int gpiod_line_event_read(struct gpiod_line *line,
1180  struct gpiod_line_event *event) GPIOD_API;
1181 
1192 int gpiod_line_event_get_fd(struct gpiod_line *line) GPIOD_API;
1193 
1205 
1225 struct gpiod_line *
1226 gpiod_line_get(const char *device, unsigned int offset) GPIOD_API;
1227 
1238 struct gpiod_line *gpiod_line_find(const char *name) GPIOD_API;
1239 
1246 void gpiod_line_close_chip(struct gpiod_line *line) GPIOD_API;
1247 
1253 struct gpiod_chip *gpiod_line_get_chip(struct gpiod_line *line) GPIOD_API;
1254 
1275 struct gpiod_chip_iter *gpiod_chip_iter_new(void) GPIOD_API;
1276 
1282 void gpiod_chip_iter_free(struct gpiod_chip_iter *iter) GPIOD_API;
1283 
1293 void gpiod_chip_iter_free_noclose(struct gpiod_chip_iter *iter) GPIOD_API;
1294 
1302 struct gpiod_chip *
1303 gpiod_chip_iter_next(struct gpiod_chip_iter *iter) GPIOD_API;
1304 
1313 struct gpiod_chip *
1314 gpiod_chip_iter_next_noclose(struct gpiod_chip_iter *iter) GPIOD_API;
1315 
1326 #define gpiod_foreach_chip(iter, chip) \
1327  for ((chip) = gpiod_chip_iter_next(iter); \
1328  (chip); \
1329  (chip) = gpiod_chip_iter_next(iter))
1330 
1341 #define gpiod_foreach_chip_noclose(iter, chip) \
1342  for ((chip) = gpiod_chip_iter_next_noclose(iter); \
1343  (chip); \
1344  (chip) = gpiod_chip_iter_next_noclose(iter))
1345 
1352 struct gpiod_line_iter *
1353 gpiod_line_iter_new(struct gpiod_chip *chip) GPIOD_API;
1354 
1359 void gpiod_line_iter_free(struct gpiod_line_iter *iter) GPIOD_API;
1360 
1367 struct gpiod_line *
1368 gpiod_line_iter_next(struct gpiod_line_iter *iter) GPIOD_API;
1369 
1376 #define gpiod_foreach_line(iter, line) \
1377  for ((line) = gpiod_line_iter_next(iter); \
1378  (line); \
1379  (line) = gpiod_line_iter_next(iter))
1380 
1394 const char *gpiod_version_string(void) GPIOD_API;
1395 
1400 #ifdef __cplusplus
1401 } /* extern "C" */
1402 #endif
1403 
1404 #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:243
Only watch falling edge events.
Definition: gpiod.h:773
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:224
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:588
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.
Direction is output - we&#39;re driving the GPIO line.
Definition: gpiod.h:647
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.
#define GPIOD_DEPRECATED
Marks a public function as deprecated.
Definition: gpiod.h:75
struct gpiod_chip * gpiod_chip_open_lookup(const char *descr) GPIOD_API
Open a gpiochip based on the best guess what the path is.
Stop processing events.
Definition: gpiod.h:188
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.
Stop processing events and indicate an error.
Definition: gpiod.h:184
Continue processing events.
Definition: gpiod.h:186
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:599
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:548
The active state of the line is low (high is the default).
Definition: gpiod.h:785
void gpiod_chip_close(struct gpiod_chip *chip) GPIOD_API
Close a GPIO chip handle and release all allocated resources.
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.
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.
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.
Polling error occurred (the polling function should set errno).
Definition: gpiod.h:215
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:575
The active state of a GPIO is active-low.
Definition: gpiod.h:657
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.
Only watch rising edge events.
Definition: gpiod.h:771
#define GPIOD_LINE_BULK_MAX_LINES
Maximum number of GPIO lines that can be requested at once.
Definition: gpiod.h:536
#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.
The line is an open-drain port.
Definition: gpiod.h:781
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:565
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.
Falling edge event.
Definition: gpiod.h:1135
int gpiod_line_active_state(struct gpiod_line *line) GPIOD_API
Read the GPIO line active state setting.
Request the line(s) for reading the GPIO line state.
Definition: gpiod.h:765
void(* gpiod_ctxless_set_value_cb)(void *)
Simple set value callback signature.
Definition: gpiod.h:116
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:1142
bool event
Indicates whether an event occurred on this file descriptor.
Definition: gpiod.h:227
int fd
File descriptor number.
Definition: gpiod.h:225
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:203
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.
#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.
Request the line(s), but don&#39;t change current direction.
Definition: gpiod.h:763
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:546
void gpiod_line_iter_free(struct gpiod_line_iter *iter) GPIOD_API
Free all resources associated with a GPIO line iterator.
Rising edge event.
Definition: gpiod.h:1133
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.
The line is an open-source port.
Definition: gpiod.h:783
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.
Waiting for events timed out.
Definition: gpiod.h:172
Helper structure for storing a set of GPIO line objects.
Definition: gpiod.h:545
int gpiod_line_request(struct gpiod_line *line, const struct gpiod_line_request_config *config, int default_val) GPIOD_API
Reserve a single line.
Falling edge event occured.
Definition: gpiod.h:176
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.
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 event loop should stop processing events.
Definition: gpiod.h:213
int event_type
Type of the event that occurred.
Definition: gpiod.h:1145
Wait for rising edge events only.
Definition: gpiod.h:161
int request_type
Request type.
Definition: gpiod.h:795
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.
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.
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:793
bool gpiod_line_is_open_source(struct gpiod_line *line) GPIOD_API
Check if the line is an open-source GPIO.
int flags
Other configuration flags.
Definition: gpiod.h:797
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.
Direction is input - we&#39;re reading the state of a GPIO line.
Definition: gpiod.h:645
Wait for both types of events.
Definition: gpiod.h:163
Request the line(s) for setting the GPIO line state.
Definition: gpiod.h:767
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.
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.
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.
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.
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.
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:792
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.
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.
Rising edge event occured.
Definition: gpiod.h:174
The active state of a GPIO is active-high.
Definition: gpiod.h:655
void gpiod_line_close_chip(struct gpiod_line *line) GPIOD_API
Close a GPIO chip owning this line and release all resources.
Monitor both types of events.
Definition: gpiod.h:769
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_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.
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.
unsigned int gpiod_chip_num_lines(struct gpiod_chip *chip) GPIOD_API
Get the number of GPIO lines exposed by this chip.