14 int fd = open(
GPIO_PATH "unexport", O_WRONLY);
22 int len = snprintf(buf,
sizeof(buf),
"%d",num);
39 int fd = open(
GPIO_PATH "export", O_WRONLY);
47 int len = snprintf(buf,
sizeof(buf),
"%d",num);
66 sprintf(file_name,
GPIO_PATH "gpio%d/direction",num);
67 int fd = open(file_name, O_WRONLY);
69 rl_log(
ERROR,
"could not open GPIO direction file");
96 sprintf(file_name,
GPIO_PATH "gpio%d/edge",num);
97 int fd = open(file_name, O_WRONLY);
106 write(fd,
"none", 5);
109 write(fd,
"rising", 7);
112 write(fd,
"falling", 8);
115 write(fd,
"both", 5);
136 sprintf(file_name,
GPIO_PATH "gpio%d/value",num);
137 int fd = open(file_name, O_WRONLY);
165 sprintf(file_name,
GPIO_PATH "gpio%d/value",num);
166 int fd = open(file_name, O_RDONLY);
192 sprintf(file_name,
GPIO_PATH "gpio%d/value",num);
193 int fd = open(file_name, O_RDONLY);
202 fds.events = POLLPRI;
208 read(fds.fd, &buf, 1);
211 ret = poll(&fds, nfds, timeout);
221 lseek(fds.fd, 0, SEEK_SET);
222 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