libgpiod  1.0
gpiod.h
1 /*
2  * This file is part of libgpiod.
3  *
4  * Copyright (C) 2017-2018 Bartosz Golaszewski <bartekgola@gmail.com>
5  *
6  * This program is free software; you can redistribute it and/or modify it
7  * under the terms of the GNU Lesser General Public License as published by
8  * the Free Software Foundation; either version 2.1 of the License, or (at
9  * your option) any later version.
10  */
11 
12 #ifndef __LIBGPIOD_GPIOD_H__
13 #define __LIBGPIOD_GPIOD_H__
14 
15 #include <stdlib.h>
16 #include <stdbool.h>
17 #include <time.h>
18 
19 #ifdef __cplusplus
20 extern "C" {
21 #endif
22 
46 struct gpiod_chip;
47 struct gpiod_line;
48 struct gpiod_chip_iter;
49 struct gpiod_line_iter;
50 
61 #define GPIOD_API __attribute__((visibility("default")))
62 
66 #define GPIOD_UNUSED __attribute__((unused))
67 
73 #define GPIOD_BIT(nr) (1UL << (nr))
74 
93 int gpiod_ctxless_get_value(const char *device, unsigned int offset,
94  bool active_low, const char *consumer) GPIOD_API;
95 
106 int gpiod_ctxless_get_value_multiple(const char *device,
107  const unsigned int *offsets, int *values,
108  unsigned int num_lines, bool active_low,
109  const char *consumer) GPIOD_API;
110 
114 typedef void (*gpiod_ctxless_set_value_cb)(void *);
115 
129 int gpiod_ctxless_set_value(const char *device, unsigned int offset, int value,
130  bool active_low, const char *consumer,
132  void *data) GPIOD_API;
133 
147 int gpiod_ctxless_set_value_multiple(const char *device,
148  const unsigned int *offsets,
149  const int *values, unsigned int num_lines,
150  bool active_low, const char *consumer,
152  void *data) GPIOD_API;
153 
157 enum {
164 };
165 
169 enum {
176 };
177 
189 typedef int (*gpiod_ctxless_event_handle_cb)(int, unsigned int,
190  const struct timespec *, void *);
191 
198 enum {
205 };
206 
211  int fd;
213  bool event;
215 };
216 
229 typedef int (*gpiod_ctxless_event_poll_cb)(unsigned int,
231  const struct timespec *, void *);
232 
248 int gpiod_ctxless_event_loop(const char *device, unsigned int offset,
249  bool active_low, const char *consumer,
250  const struct timespec *timeout,
253  void *data) GPIOD_API;
254 
283 int gpiod_ctxless_event_loop_multiple(const char *device,
284  const unsigned int *offsets,
285  unsigned int num_lines, bool active_low,
286  const char *consumer,
287  const struct timespec *timeout,
290  void *data) GPIOD_API;
291 
303 int gpiod_ctxless_find_line(const char *name, char *chipname,
304  size_t chipname_size,
305  unsigned int *offset) GPIOD_API;
306 
321 struct gpiod_chip *gpiod_chip_open(const char *path) GPIOD_API;
322 
330 struct gpiod_chip *gpiod_chip_open_by_name(const char *name) GPIOD_API;
331 
339 struct gpiod_chip *gpiod_chip_open_by_number(unsigned int num) GPIOD_API;
340 
349 struct gpiod_chip *gpiod_chip_open_by_label(const char *label) GPIOD_API;
350 
360 struct gpiod_chip *gpiod_chip_open_lookup(const char *descr) GPIOD_API;
361 
366 void gpiod_chip_close(struct gpiod_chip *chip) GPIOD_API;
367 
373 const char *gpiod_chip_name(struct gpiod_chip *chip) GPIOD_API;
374 
380 const char *gpiod_chip_label(struct gpiod_chip *chip) GPIOD_API;
381 
387 unsigned int gpiod_chip_num_lines(struct gpiod_chip *chip) GPIOD_API;
388 
395 struct gpiod_line *
396 gpiod_chip_get_line(struct gpiod_chip *chip, unsigned int offset) GPIOD_API;
397 
407 struct gpiod_line *
408 gpiod_chip_find_line(struct gpiod_chip *chip, const char *name) GPIOD_API;
409 
425 #define GPIOD_LINE_BULK_MAX_LINES 64
426 
435  struct gpiod_line *lines[GPIOD_LINE_BULK_MAX_LINES];
437  unsigned int num_lines;
439 };
440 
446 #define GPIOD_LINE_BULK_INITIALIZER { { NULL }, 0 }
447 
454 static inline void gpiod_line_bulk_init(struct gpiod_line_bulk *bulk)
455 {
456  bulk->num_lines = 0;
457 }
458 
464 static inline void gpiod_line_bulk_add(struct gpiod_line_bulk *bulk,
465  struct gpiod_line *line)
466 {
467  bulk->lines[bulk->num_lines++] = line;
468 }
469 
476 static inline struct gpiod_line *
477 gpiod_line_bulk_get_line(struct gpiod_line_bulk *bulk, unsigned int offset)
478 {
479  return bulk->lines[offset];
480 }
481 
487 static inline unsigned int
489 {
490  return bulk->num_lines;
491 }
492 
500 #define gpiod_line_bulk_foreach_line(bulk, line, lineptr) \
501  for ((lineptr) = (bulk)->lines, (line) = *(lineptr); \
502  (lineptr) <= (bulk)->lines + ((bulk)->num_lines - 1); \
503  (lineptr)++, (line) = *(lineptr))
504 
518 #define gpiod_line_bulk_foreach_line_off(bulk, line, offset) \
519  for ((offset) = 0, (line) = (bulk)->lines[0]; \
520  (offset) < (bulk)->num_lines; \
521  (offset)++, (line) = (bulk)->lines[(offset)])
522 
533 enum {
538 };
539 
543 enum {
548 };
549 
555 unsigned int gpiod_line_offset(struct gpiod_line *line) GPIOD_API;
556 
564 const char *gpiod_line_name(struct gpiod_line *line) GPIOD_API;
565 
573 const char *gpiod_line_consumer(struct gpiod_line *line) GPIOD_API;
574 
580 int gpiod_line_direction(struct gpiod_line *line) GPIOD_API;
581 
587 int gpiod_line_active_state(struct gpiod_line *line) GPIOD_API;
588 
598 bool gpiod_line_is_used(struct gpiod_line *line) GPIOD_API;
599 
605 bool gpiod_line_is_open_drain(struct gpiod_line *line) GPIOD_API;
606 
612 bool gpiod_line_is_open_source(struct gpiod_line *line) GPIOD_API;
613 
624 int gpiod_line_update(struct gpiod_line *line) GPIOD_API;
625 
639 bool gpiod_line_needs_update(struct gpiod_line *line) GPIOD_API;
640 
651 enum {
664 };
665 
669 enum {
676 };
677 
682  const char *consumer;
686  int flags;
688 };
689 
702 int gpiod_line_request(struct gpiod_line *line,
703  const struct gpiod_line_request_config *config,
704  int default_val) GPIOD_API;
705 
712 int gpiod_line_request_input(struct gpiod_line *line,
713  const char *consumer) GPIOD_API;
714 
722 int gpiod_line_request_output(struct gpiod_line *line,
723  const char *consumer, int default_val) GPIOD_API;
724 
731 int gpiod_line_request_rising_edge_events(struct gpiod_line *line,
732  const char *consumer) GPIOD_API;
733 
740 int gpiod_line_request_falling_edge_events(struct gpiod_line *line,
741  const char *consumer) GPIOD_API;
742 
749 int gpiod_line_request_both_edges_events(struct gpiod_line *line,
750  const char *consumer) GPIOD_API;
751 
759 int gpiod_line_request_input_flags(struct gpiod_line *line,
760  const char *consumer, int flags) GPIOD_API;
761 
770 int gpiod_line_request_output_flags(struct gpiod_line *line,
771  const char *consumer, int flags,
772  int default_val) GPIOD_API;
773 
781 int gpiod_line_request_rising_edge_events_flags(struct gpiod_line *line,
782  const char *consumer,
783  int flags) GPIOD_API;
784 
792 int gpiod_line_request_falling_edge_events_flags(struct gpiod_line *line,
793  const char *consumer,
794  int flags) GPIOD_API;
795 
803 int gpiod_line_request_both_edges_events_flags(struct gpiod_line *line,
804  const char *consumer,
805  int flags) GPIOD_API;
806 
821  const struct gpiod_line_request_config *config,
822  const int *default_vals) GPIOD_API;
823 
831  const char *consumer) GPIOD_API;
832 
841  const char *consumer,
842  const int *default_vals) GPIOD_API;
843 
851  const char *consumer) GPIOD_API;
852 
860  const char *consumer) GPIOD_API;
861 
869  const char *consumer) GPIOD_API;
870 
879  const char *consumer,
880  int flags) GPIOD_API;
881 
891  const char *consumer, int flags,
892  const int *default_vals) GPIOD_API;
893 
902  struct gpiod_line_bulk *bulk,
903  const char *consumer,
904  int flags) GPIOD_API;
905 
914  struct gpiod_line_bulk *bulk,
915  const char *consumer,
916  int flags) GPIOD_API;
917 
926  struct gpiod_line_bulk *bulk,
927  const char *consumer,
928  int flags) GPIOD_API;
929 
934 void gpiod_line_release(struct gpiod_line *line) GPIOD_API;
935 
944 
950 bool gpiod_line_is_requested(struct gpiod_line *line) GPIOD_API;
951 
958 bool gpiod_line_is_free(struct gpiod_line *line) GPIOD_API;
959 
973 int gpiod_line_get_value(struct gpiod_line *line) GPIOD_API;
974 
987  int *values) GPIOD_API;
988 
996 int gpiod_line_set_value(struct gpiod_line *line, int value) GPIOD_API;
997 
1009  const int *values) GPIOD_API;
1010 
1021 enum {
1026 };
1027 
1032  struct timespec ts;
1036 };
1037 
1045 int gpiod_line_event_wait(struct gpiod_line *line,
1046  const struct timespec *timeout) GPIOD_API;
1047 
1058  const struct timespec *timeout,
1059  struct gpiod_line_bulk *event_bulk) GPIOD_API;
1060 
1068 int gpiod_line_event_read(struct gpiod_line *line,
1069  struct gpiod_line_event *event) GPIOD_API;
1070 
1081 int gpiod_line_event_get_fd(struct gpiod_line *line) GPIOD_API;
1082 
1094 
1114 struct gpiod_line *
1115 gpiod_line_get(const char *device, unsigned int offset) GPIOD_API;
1116 
1127 struct gpiod_line *gpiod_line_find(const char *name) GPIOD_API;
1128 
1135 void gpiod_line_close_chip(struct gpiod_line *line) GPIOD_API;
1136 
1142 struct gpiod_chip *gpiod_line_get_chip(struct gpiod_line *line) GPIOD_API;
1143 
1164 struct gpiod_chip_iter *gpiod_chip_iter_new(void) GPIOD_API;
1165 
1171 void gpiod_chip_iter_free(struct gpiod_chip_iter *iter) GPIOD_API;
1172 
1182 void gpiod_chip_iter_free_noclose(struct gpiod_chip_iter *iter) GPIOD_API;
1183 
1191 struct gpiod_chip *
1192 gpiod_chip_iter_next(struct gpiod_chip_iter *iter) GPIOD_API;
1193 
1202 struct gpiod_chip *
1203 gpiod_chip_iter_next_noclose(struct gpiod_chip_iter *iter) GPIOD_API;
1204 
1215 #define gpiod_foreach_chip(iter, chip) \
1216  for ((chip) = gpiod_chip_iter_next(iter); \
1217  (chip); \
1218  (chip) = gpiod_chip_iter_next(iter))
1219 
1230 #define gpiod_foreach_chip_noclose(iter, chip) \
1231  for ((chip) = gpiod_chip_iter_next_noclose(iter); \
1232  (chip); \
1233  (chip) = gpiod_chip_iter_next_noclose(iter))
1234 
1241 struct gpiod_line_iter *
1242 gpiod_line_iter_new(struct gpiod_chip *chip) GPIOD_API;
1243 
1248 void gpiod_line_iter_free(struct gpiod_line_iter *iter) GPIOD_API;
1249 
1256 struct gpiod_line *
1257 gpiod_line_iter_next(struct gpiod_line_iter *iter) GPIOD_API;
1258 
1265 #define gpiod_foreach_line(iter, line) \
1266  for ((line) = gpiod_line_iter_next(iter); \
1267  (line); \
1268  (line) = gpiod_line_iter_next(iter))
1269 
1283 const char *gpiod_version_string(void) GPIOD_API;
1284 
1289 #ifdef __cplusplus
1290 } /* extern "C" */
1291 #endif
1292 
1293 #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:229
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:210
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:477
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:1022
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:1024
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:672
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:488
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:437
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:660
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:174
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:464
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:425
#define GPIOD_API
Makes symbol visible.
Definition: gpiod.h:61
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:454
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:114
The active state of a GPIO is active-high.
Definition: gpiod.h:544
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:1031
bool event
Indicates whether an event occurred on this file descriptor.
Definition: gpiod.h:213
int fd
File descriptor number.
Definition: gpiod.h:211
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:189
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:73
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:435
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:658
Helper structure for storing a set of GPIO line objects.
Definition: gpiod.h:434
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:546
int event_type
Type of the event that occurred.
Definition: gpiod.h:1034
int request_type
Request type.
Definition: gpiod.h:684
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:670
Request the line(s) for setting the GPIO line state.
Definition: gpiod.h:656
const char * consumer
Name of the consumer.
Definition: gpiod.h:682
Request the line(s) for reading the GPIO line state.
Definition: gpiod.h:654
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:172
The active state of the line is low (high is the default).
Definition: gpiod.h:674
int flags
Other configuration flags.
Definition: gpiod.h:686
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:201
Only watch falling edge events.
Definition: gpiod.h:662
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:158
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:652
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:534
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:536
Falling edge event occured.
Definition: gpiod.h:162
Rising edge event occured.
Definition: gpiod.h:160
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:681
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 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:199
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:170
unsigned int gpiod_chip_num_lines(struct gpiod_chip *chip) GPIOD_API
Get the number of GPIO lines exposed by this chip.