gpio-utils.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /*
  2. * GPIO tools - utility helpers library for the GPIO tools
  3. *
  4. * Copyright (C) 2015 Linus Walleij
  5. *
  6. * Portions copied from iio_utils and lssio:
  7. * Copyright (c) 2010 Manuel Stahl <manuel.stahl@iis.fraunhofer.de>
  8. * Copyright (c) 2008 Jonathan Cameron
  9. * *
  10. * This program is free software; you can redistribute it and/or modify it
  11. * under the terms of the GNU General Public License version 2 as published by
  12. * the Free Software Foundation.
  13. */
  14. #ifndef _GPIO_UTILS_H_
  15. #define _GPIO_UTILS_H_
  16. #include <string.h>
  17. #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
  18. static inline int check_prefix(const char *str, const char *prefix)
  19. {
  20. return strlen(str) > strlen(prefix) &&
  21. strncmp(str, prefix, strlen(prefix)) == 0;
  22. }
  23. int gpiotools_request_linehandle(const char *device_name, unsigned int *lines,
  24. unsigned int nlines, unsigned int flag,
  25. struct gpiohandle_data *data,
  26. const char *consumer_label);
  27. int gpiotools_set_values(const int fd, struct gpiohandle_data *data);
  28. int gpiotools_get_values(const int fd, struct gpiohandle_data *data);
  29. int gpiotools_release_linehandle(const int fd);
  30. int gpiotools_get(const char *device_name, unsigned int line);
  31. int gpiotools_gets(const char *device_name, unsigned int *lines,
  32. unsigned int nlines, struct gpiohandle_data *data);
  33. int gpiotools_set(const char *device_name, unsigned int line,
  34. unsigned int value);
  35. int gpiotools_sets(const char *device_name, unsigned int *lines,
  36. unsigned int nlines, struct gpiohandle_data *data);
  37. #endif /* _GPIO_UTILS_H_ */