1
0
mirror of https://github.com/xtacocorex/CHIP_IO synced 2025-07-20 04:43:21 +00:00

Edge detection callback is now working for the XIO's. Blocking wait_for_edge works for both the AP-EINT1/3 and the XIO's. Need to figure out why AP-EINT1/3 don't work for the callback. This is to help fix issue #9.

This commit is contained in:
Robert Wolterman
2016-07-10 16:37:22 -05:00
parent db4493322d
commit 3d1ecb6b5e
2 changed files with 10 additions and 7 deletions

View File

@ -423,7 +423,7 @@ int gpio_get_value(int gpio, unsigned int *value)
int gpio_set_edge(int gpio, unsigned int edge)
{
int fd, e_no;
int fd;
char filename[MAX_FILENAME];
// DEBUG
@ -471,18 +471,18 @@ int open_edge_file(int gpio)
int gpio_get_edge(int gpio)
{
int e_no;
int fd = fd_lookup(gpio);
int fd; // = fd_lookup(gpio);
int rtnedge = -1;
if (!fd)
{
//if (!fd)
//{
if ((fd = open_edge_file(gpio)) == -1) {
char err[256];
snprintf(err, sizeof(err), "gpio_get_value: could not open GPIO %d edge file", gpio);
add_error_msg(err);
return -1;
}
}
//}
if (lseek(fd, 0, SEEK_SET) < 0) {
char err[256];
@ -519,6 +519,9 @@ int gpio_get_edge(int gpio)
rtnedge = 3;
}
// DEBUG
printf("DEBUG gpio_get_edge(%d -> %d)\n", gpio, rtnedge);
return rtnedge;
}
@ -577,6 +580,8 @@ void run_callbacks(int gpio)
int edge = gpio_get_edge(gpio);
unsigned int value = 0;
gpio_get_value(gpio, &value);
// DEBUG
printf("DEBUG run_callbacks(GPIO: %d, EDGE: %d, VALUE: %d)\n", gpio, cb->edge, value);
// Both Edge
if (cb->edge == 3)
{