#346 irq status var name ajust
This commit is contained in:
@@ -2685,7 +2685,7 @@ struct WPIWfiStatus waitForInterrupt2(int pin, int edgeMode, int ms, unsigned lo
|
||||
|
||||
/* open gpio */
|
||||
if (wiringPiGpioDeviceGetFd()<0) {
|
||||
wfiStatus.status = -1;
|
||||
wfiStatus.statusOK = -1;
|
||||
return wfiStatus;
|
||||
}
|
||||
|
||||
@@ -2701,7 +2701,7 @@ struct WPIWfiStatus waitForInterrupt2(int pin, int edgeMode, int ms, unsigned lo
|
||||
if (wiringPiDebug) {
|
||||
printf ("waitForInterrupt2: edgeMode INT_EDGE_SETUP - exiting\n") ;
|
||||
}
|
||||
wfiStatus.status = -1;
|
||||
wfiStatus.statusOK = -1;
|
||||
return wfiStatus;
|
||||
case INT_EDGE_FALLING:
|
||||
config.flags |= GPIO_V2_LINE_FLAG_EDGE_FALLING;
|
||||
@@ -2734,7 +2734,7 @@ struct WPIWfiStatus waitForInterrupt2(int pin, int edgeMode, int ms, unsigned lo
|
||||
status = ioctl(chipFd, GPIO_V2_GET_LINE_IOCTL, &req);
|
||||
if (status == -1) {
|
||||
ReportDeviceError("GPIO_V2_GET_LINE_IOCTL", pin , strmode, status);
|
||||
wfiStatus.status = -1;
|
||||
wfiStatus.statusOK = -1;
|
||||
return wfiStatus;
|
||||
}
|
||||
|
||||
@@ -2763,24 +2763,23 @@ struct WPIWfiStatus waitForInterrupt2(int pin, int edgeMode, int ms, unsigned lo
|
||||
polls.revents = 0;
|
||||
|
||||
ret = poll(&polls, 1, ms);
|
||||
|
||||
if (ret < 0) {
|
||||
if (wiringPiDebug) {
|
||||
fprintf(stderr, "waitForInterrupt2: ERROR: poll returned=%d\n", ret);
|
||||
}
|
||||
wfiStatus.status = -1;
|
||||
wfiStatus.statusOK = -1;
|
||||
} else if (ret == 0) {
|
||||
if (wiringPiDebug) {
|
||||
fprintf(stderr, "waitForInterrupt2: timeout: poll returned zero\n");
|
||||
}
|
||||
wfiStatus.status = 0;
|
||||
wfiStatus.statusOK = 0; // timeout
|
||||
}
|
||||
else {
|
||||
if (wiringPiDebug) {
|
||||
printf ("waitForInterrupt2: IRQ line %d received %d, fd=%d\n", pin, ret, isrFds[pin]);
|
||||
}
|
||||
if (polls.revents & POLLIN) {
|
||||
/* read event data */
|
||||
/* read event data */
|
||||
readret = read(isrFds [pin], &evdata, sizeof(evdata));
|
||||
if (readret == sizeof(evdata)) {
|
||||
if (wiringPiDebug) {
|
||||
@@ -2801,16 +2800,15 @@ struct WPIWfiStatus waitForInterrupt2(int pin, int edgeMode, int ms, unsigned lo
|
||||
break;
|
||||
}
|
||||
wfiStatus.timeStamp_us = evdata.timestamp_ns / 1000LL; // nanoseconds u64 to microseconds
|
||||
wfiStatus.pin = evdata.offset;
|
||||
wfiStatus.id = evdata.id;
|
||||
wfiStatus.status = 1;
|
||||
wfiStatus.pinBCM = evdata.offset;
|
||||
wfiStatus.statusOK = 1;
|
||||
}
|
||||
else {
|
||||
wfiStatus.status = -1;
|
||||
wfiStatus.statusOK = -1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
wfiStatus.status = -1;
|
||||
wfiStatus.statusOK = -1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2833,7 +2831,7 @@ int waitForInterrupt (int pin, int ms) {
|
||||
}
|
||||
status = waitForInterrupt2(pin, edgeMode, ms, 0);
|
||||
|
||||
return status.id;
|
||||
return status.statusOK;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -3015,8 +3013,8 @@ void *interruptHandlerV2(void *arg)
|
||||
if (isrFunctionsV2[pin]) {
|
||||
if (wiringPiDebug)
|
||||
printf( "interruptHandlerV2: GPIO EVENT at %llu on line %u (%u|%u) \n", evdat[i].timestamp_ns, evdat[i].offset, evdat[i].line_seqno, evdat[i].seqno);
|
||||
wfiStatus.status = 1;
|
||||
wfiStatus.pin = pin;
|
||||
wfiStatus.statusOK = 1;
|
||||
wfiStatus.pinBCM = pin;
|
||||
switch (evdat[i].id) {
|
||||
case GPIO_V2_LINE_EVENT_RISING_EDGE:
|
||||
wfiStatus.edge = INT_EDGE_RISING;
|
||||
|
||||
@@ -299,17 +299,16 @@ extern void digitalWriteByte2 (int value) ;
|
||||
// Interrupts
|
||||
// status returned from waitForInterruptV2 V3.16
|
||||
struct WPIWfiStatus {
|
||||
int id;
|
||||
int status; // -1: error, 0: timeout, 1: valud values for edge and timeStamp_us
|
||||
unsigned int pin; // gpio as BCM pin
|
||||
int edge; // One of INT_EDGE_FALLING or INT_EDGE_RISING
|
||||
long long int timeStamp_us; // time stamp in microseconds, when interrupt happened
|
||||
int statusOK; // -1: error (return of 'poll' command), 0: timeout, 1: irq processed, next data values are valid if needed
|
||||
unsigned int pinBCM; // gpio as BCM pin
|
||||
int edge; // INT_EDGE_FALLING or INT_EDGE_RISING
|
||||
long long int timeStamp_us; // time stamp in microseconds
|
||||
};
|
||||
|
||||
extern int waitForInterrupt (int pin, int ms) ;
|
||||
//extern int waitForInterrupt (int pin, int ms); unknown if still working, disabled for V3.16, please contact developer via github
|
||||
extern int wiringPiISR (int pin, int mode, void (*function)(void)) ;
|
||||
extern struct WPIWfiStatus waitForInterrupt2(int pin, int edgeMode, int ms, unsigned long debounce_period_us) ; // V3.16 phylax
|
||||
extern int wiringPiISR2 (int pin, int mode, void (*function)(struct WPIWfiStatus wfiStatus), unsigned long debounce_period_us) ; // v3.16 phylax
|
||||
extern struct WPIWfiStatus waitForInterrupt2(int pin, int edgeMode, int ms, unsigned long debounce_period_us) ; // V3.16
|
||||
extern int wiringPiISR2 (int pin, int mode, void (*function)(struct WPIWfiStatus wfiStatus), unsigned long debounce_period_us) ; // V3.16
|
||||
extern int wiringPiISRStop (int pin) ; //V3.2
|
||||
extern int waitForInterruptClose(int pin) ; //V3.2 legacy use wiringPiISRStop
|
||||
|
||||
|
||||
Reference in New Issue
Block a user