40 int fd = open(
GPIO_PATH "unexport", O_WRONLY);
48 int len = snprintf(buf,
sizeof(buf),
"%d", num);
64 int fd = open(
GPIO_PATH "export", O_WRONLY);
72 int len = snprintf(buf,
sizeof(buf),
"%d", num);
91 sprintf(file_name,
GPIO_PATH "gpio%d/direction", num);
92 int fd = open(file_name, O_WRONLY);
94 rl_log(
ERROR,
"could not open GPIO direction file");
120 sprintf(file_name,
GPIO_PATH "gpio%d/edge", num);
121 int fd = open(file_name, O_WRONLY);
130 write(fd,
"none", 5);
133 write(fd,
"rising", 7);
136 write(fd,
"falling", 8);
139 write(fd,
"both", 5);
159 sprintf(file_name,
GPIO_PATH "gpio%d/value", num);
160 int fd = open(file_name, O_WRONLY);
188 sprintf(file_name,
GPIO_PATH "gpio%d/value", num);
189 int fd = open(file_name, O_RDONLY);
215 sprintf(file_name,
GPIO_PATH "gpio%d/value", num);
216 int fd = open(file_name, O_RDONLY);
225 fds.events = POLLPRI;
231 read(fds.fd, &buf, 1);
234 ret = poll(&fds, nfds, timeout);
244 lseek(fds.fd, 0, SEEK_SET);
245 read(fds.fd, &buf, 1);
int gpio_get_value(int num)
#define GPIO_PATH
Path to linux GPIO device files.
void rl_log(rl_log_type type, const char *format,...)
Interrupt on falling edge.
Interrupt on rising edge.
#define MAX_PATH_LENGTH
Maximum path length in characters.
int gpio_interrupt(int num, rl_edge edge)
int gpio_set_value(int num, int val)
int gpio_wait_interrupt(int num, int timeout)
#define MIN_BUTTON_TIME
Minimal time a button needs to be pressed (in µs)
int gpio_unexport(int num)
int gpio_dir(int num, rl_direction dir)
enum direction rl_direction