Advertisement
victorocampo

gpio_sysfs.h

Nov 9th, 2019
500
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.83 KB | None | 0 0
  1. #ifndef __GPIO_SYSFS_H
  2. #define __GPIO_SYSFS_H
  3.  
  4. typedef enum bool_enum { false, true } bool;
  5.  
  6. #include <stdint.h>
  7.  
  8. #define IN              false
  9. #define OUT             true
  10.  
  11. #define GPIO_FILENAME_CHAR_SIZE     7
  12.  
  13. #define GPIODIR             "/sys/class/gpio/"
  14. #define EXPORTFILE          GPIODIR"export"
  15. #define UNEXPORTFILE            GPIODIR"unexport"
  16.  
  17. #define GPIO_OUT            "out"
  18. #define GPIO_IN             "in"
  19.  
  20. #define FILE_ERROR          2
  21. #define GPIO_WRONG_DIRECTION_ERROR  3
  22. #define GPIO_NOT_EXPORTED_ERROR     4
  23. #define GPIO_ALREADY_EXPORTED_ERROR 5
  24.  
  25. bool is_gpio_exported(uint8_t gpio);
  26. uint8_t gpio_export(uint8_t gpio);
  27. uint8_t gpio_unexport(uint8_t gpio);
  28. uint8_t gpio_change_direction(uint8_t gpio, char *direction);
  29. uint8_t gpio_read_direction(uint8_t gpio, char *d);
  30. uint8_t gpio_write(uint8_t gpio, bool value);
  31. uint8_t gpio_read(uint8_t gpio, uint8_t *v);
  32.  
  33. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement