wiringPi.c ; waitForInterrupt releases fd and line itself, wiringPiISRStop not necessary to be called
This commit is contained in:
@@ -2782,34 +2782,35 @@ long long int waitForInterrupt (int pin, int edgeMode, int mS, unsigned long deb
|
||||
}
|
||||
|
||||
/*
|
||||
* waitForInterruptClose:
|
||||
* wait for thread interruptHandler to be stopped.
|
||||
* wiringPiISRStop:
|
||||
* stop interruptHandler thread and
|
||||
* wait untill stopped.
|
||||
* close isrFds[pin], reset isrFds[pin], isrFunction[pin] and isrDebouncePeriodUs[pin]
|
||||
*
|
||||
*********************************************************************************
|
||||
*/
|
||||
|
||||
int waitForInterruptClose (int pin) {
|
||||
int wiringPiISRStop (int pin) {
|
||||
void *res;
|
||||
|
||||
if (isrFds[pin] > 0) {
|
||||
if (wiringPiDebug)
|
||||
printf ("waitForInterruptClose: close thread 0x%lX\n", (unsigned long)isrThreads[pin]) ;
|
||||
printf ("wiringPiISRStop: close thread 0x%lX\n", (unsigned long)isrThreads[pin]) ;
|
||||
|
||||
if (isrThreads[pin] != 0) {
|
||||
if (pthread_cancel(isrThreads[pin]) == 0) {
|
||||
pthread_join(isrThreads[pin], &res);
|
||||
if (res == PTHREAD_CANCELED) {
|
||||
if (wiringPiDebug)
|
||||
printf("waitForInterruptClose: thread was canceled\n");
|
||||
printf("wiringPiISRStop: thread was canceled\n");
|
||||
}
|
||||
else {
|
||||
if (wiringPiDebug)
|
||||
printf("waitForInterruptClose: thread was not canceled\n");
|
||||
printf("wiringPiISRStop: thread was not canceled\n");
|
||||
}
|
||||
} else {
|
||||
if (wiringPiDebug)
|
||||
printf ("waitForInterruptClose: waitForInterruptClose could not cancel thread\n");
|
||||
printf ("wiringPiISRStop: could not cancel thread\n");
|
||||
}
|
||||
}
|
||||
close(isrFds [pin]);
|
||||
@@ -2830,17 +2831,6 @@ int waitForInterruptClose (int pin) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* wiringPiISRStop:
|
||||
* stop thread interruptHandler
|
||||
*
|
||||
*********************************************************************************
|
||||
*/
|
||||
|
||||
int wiringPiISRStop (int pin) {
|
||||
return waitForInterruptClose (pin);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* interruptHandler:
|
||||
|
||||
@@ -144,6 +144,7 @@ extern const char *piRevisionNames [16] ;
|
||||
extern const char *piMakerNames [16] ;
|
||||
extern const int piMemorySize [ 8] ;
|
||||
|
||||
|
||||
// Intended for the GPIO program Use at your own risk.
|
||||
|
||||
// Threads
|
||||
@@ -301,7 +302,6 @@ extern void digitalWriteByte2 (int value) ;
|
||||
extern long long int waitForInterrupt (int pin, int edgeMode, int mS, unsigned long debounce_period_us) ; // V3.14 phylax
|
||||
extern int wiringPiISR (int pin, int mode, void (*function)(unsigned int, long long int), unsigned long debounce_period_us) ; // v3.14 phylax
|
||||
extern int wiringPiISRStop (int pin) ; //V3.2
|
||||
extern int waitForInterruptClose(int pin) ; //V3.2
|
||||
|
||||
// Threads
|
||||
|
||||
|
||||
Reference in New Issue
Block a user