41 int fd = open(
GPIO_PATH "unexport", O_WRONLY);
49 int len = snprintf(buf,
sizeof(buf),
"%d", num);
65 int fd = open(
GPIO_PATH "export", O_WRONLY);
73 int len = snprintf(buf,
sizeof(buf),
"%d", num);
92 sprintf(file_name,
GPIO_PATH "gpio%d/direction", num);
93 int fd = open(file_name, O_WRONLY);
95 rl_log(
ERROR,
"could not open GPIO direction file");
121 sprintf(file_name,
GPIO_PATH "gpio%d/edge", num);
122 int fd = open(file_name, O_WRONLY);
131 write(fd,
"none", 5);
134 write(fd,
"rising", 7);
137 write(fd,
"falling", 8);
140 write(fd,
"both", 5);
160 sprintf(file_name,
GPIO_PATH "gpio%d/value", num);
161 int fd = open(file_name, O_WRONLY);
189 sprintf(file_name,
GPIO_PATH "gpio%d/value", num);
190 int fd = open(file_name, O_RDONLY);
216 sprintf(file_name,
GPIO_PATH "gpio%d/value", num);
217 int fd = open(file_name, O_RDONLY);
226 fds.events = POLLPRI;
232 read(fds.fd, &buf, 1);
235 ret = poll(&fds, nfds, timeout);
245 lseek(fds.fd, 0, SEEK_SET);
246 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