mirror of
https://github.com/xtacocorex/CHIP_IO
synced 2025-07-20 12:53:22 +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:
@ -423,7 +423,7 @@ int gpio_get_value(int gpio, unsigned int *value)
|
|||||||
|
|
||||||
int gpio_set_edge(int gpio, unsigned int edge)
|
int gpio_set_edge(int gpio, unsigned int edge)
|
||||||
{
|
{
|
||||||
int fd, e_no;
|
int fd;
|
||||||
char filename[MAX_FILENAME];
|
char filename[MAX_FILENAME];
|
||||||
|
|
||||||
// DEBUG
|
// DEBUG
|
||||||
@ -471,18 +471,18 @@ int open_edge_file(int gpio)
|
|||||||
int gpio_get_edge(int gpio)
|
int gpio_get_edge(int gpio)
|
||||||
{
|
{
|
||||||
int e_no;
|
int e_no;
|
||||||
int fd = fd_lookup(gpio);
|
int fd; // = fd_lookup(gpio);
|
||||||
int rtnedge = -1;
|
int rtnedge = -1;
|
||||||
|
|
||||||
if (!fd)
|
//if (!fd)
|
||||||
{
|
//{
|
||||||
if ((fd = open_edge_file(gpio)) == -1) {
|
if ((fd = open_edge_file(gpio)) == -1) {
|
||||||
char err[256];
|
char err[256];
|
||||||
snprintf(err, sizeof(err), "gpio_get_value: could not open GPIO %d edge file", gpio);
|
snprintf(err, sizeof(err), "gpio_get_value: could not open GPIO %d edge file", gpio);
|
||||||
add_error_msg(err);
|
add_error_msg(err);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
//}
|
||||||
|
|
||||||
if (lseek(fd, 0, SEEK_SET) < 0) {
|
if (lseek(fd, 0, SEEK_SET) < 0) {
|
||||||
char err[256];
|
char err[256];
|
||||||
@ -519,6 +519,9 @@ int gpio_get_edge(int gpio)
|
|||||||
rtnedge = 3;
|
rtnedge = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DEBUG
|
||||||
|
printf("DEBUG gpio_get_edge(%d -> %d)\n", gpio, rtnedge);
|
||||||
|
|
||||||
return rtnedge;
|
return rtnedge;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -577,6 +580,8 @@ void run_callbacks(int gpio)
|
|||||||
int edge = gpio_get_edge(gpio);
|
int edge = gpio_get_edge(gpio);
|
||||||
unsigned int value = 0;
|
unsigned int value = 0;
|
||||||
gpio_get_value(gpio, &value);
|
gpio_get_value(gpio, &value);
|
||||||
|
// DEBUG
|
||||||
|
printf("DEBUG run_callbacks(GPIO: %d, EDGE: %d, VALUE: %d)\n", gpio, cb->edge, value);
|
||||||
// Both Edge
|
// Both Edge
|
||||||
if (cb->edge == 3)
|
if (cb->edge == 3)
|
||||||
{
|
{
|
||||||
|
@ -10,7 +10,6 @@ DO_XIOP2_TEST = True
|
|||||||
|
|
||||||
num_callbacks = 0
|
num_callbacks = 0
|
||||||
|
|
||||||
|
|
||||||
def myfuncallback(channel):
|
def myfuncallback(channel):
|
||||||
global num_callbacks
|
global num_callbacks
|
||||||
num_callbacks += 1
|
num_callbacks += 1
|
||||||
@ -19,7 +18,6 @@ def myfuncallback(channel):
|
|||||||
|
|
||||||
loopfunction_exit = False
|
loopfunction_exit = False
|
||||||
|
|
||||||
|
|
||||||
def loopfunction():
|
def loopfunction():
|
||||||
print("LOOP FUNCTION")
|
print("LOOP FUNCTION")
|
||||||
for i in xrange(6):
|
for i in xrange(6):
|
||||||
|
Reference in New Issue
Block a user