Update interupt handler callback, enabling argument passing. see: https://www.raspberrypi.org/forums/viewtopic.php?f=33&t=104814 see: demopadgithub/HELPERMONKEYS@2090e9bpull/60/head
@@ -33,7 +33,9 @@ endif | |||||
#DEBUG = -g -O0 | #DEBUG = -g -O0 | ||||
DEBUG = -O2 | DEBUG = -O2 | ||||
CC = gcc | CC = gcc | ||||
INCLUDE = -I$(DESTDIR)$(PREFIX)/include | |||||
#INCLUDE = -I$(DESTDIR)$(PREFIX)/include | |||||
ROOT_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))) | |||||
INCLUDE = -I$(DESTDIR)$(PREFIX)/include -I$(ROOT_DIR)/devLib | |||||
CFLAGS = $(DEBUG) -Wall -Wextra $(INCLUDE) -Winline -pipe | CFLAGS = $(DEBUG) -Wall -Wextra $(INCLUDE) -Winline -pipe | ||||
LDFLAGS = -L$(DESTDIR)$(PREFIX)/lib | LDFLAGS = -L$(DESTDIR)$(PREFIX)/lib | ||||
@@ -541,7 +541,7 @@ void doExport (int argc, char *argv []) | |||||
********************************************************************************* | ********************************************************************************* | ||||
*/ | */ | ||||
static void wfi (void) | |||||
static void wfi (void* arg) | |||||
{ exit (0) ; } | { exit (0) ; } | ||||
void doWfi (int argc, char *argv []) | void doWfi (int argc, char *argv []) | ||||
@@ -565,7 +565,7 @@ void doWfi (int argc, char *argv []) | |||||
exit (1) ; | exit (1) ; | ||||
} | } | ||||
if (wiringPiISR (pin, mode, &wfi) < 0) | |||||
if (wiringPiISR (pin, mode, &wfi,NULL) < 0) | |||||
{ | { | ||||
fprintf (stderr, "%s: wfi: Unable to setup ISR: %s\n", argv [1], strerror (errno)) ; | fprintf (stderr, "%s: wfi: Unable to setup ISR: %s\n", argv [1], strerror (errno)) ; | ||||
exit (1) ; | exit (1) ; | ||||
@@ -322,7 +322,7 @@ static int sysFds [64] = | |||||
// ISR Data | // ISR Data | ||||
static void (*isrFunctions [64])(void) ; | |||||
static void (*isrFunctions [64])(void*) ; | |||||
// Doing it the Arduino way with lookup tables... | // Doing it the Arduino way with lookup tables... | ||||
@@ -1933,7 +1933,7 @@ static void *interruptHandler (UNU void *arg) | |||||
for (;;) | for (;;) | ||||
if (waitForInterrupt (myPin, -1) > 0) | if (waitForInterrupt (myPin, -1) > 0) | ||||
isrFunctions [myPin] () ; | |||||
isrFunctions [myPin] (arg) ; | |||||
return NULL ; | return NULL ; | ||||
} | } | ||||
@@ -1947,7 +1947,7 @@ static void *interruptHandler (UNU void *arg) | |||||
********************************************************************************* | ********************************************************************************* | ||||
*/ | */ | ||||
int wiringPiISR (int pin, int mode, void (*function)(void)) | |||||
int wiringPiISR (int pin, int mode, void (*function)(void), void* userData) | |||||
{ | { | ||||
pthread_t threadId ; | pthread_t threadId ; | ||||
const char *modeS ; | const char *modeS ; | ||||
@@ -2029,7 +2029,7 @@ int wiringPiISR (int pin, int mode, void (*function)(void)) | |||||
pthread_mutex_lock (&pinMutex) ; | pthread_mutex_lock (&pinMutex) ; | ||||
pinPass = pin ; | pinPass = pin ; | ||||
pthread_create (&threadId, NULL, interruptHandler, NULL) ; | |||||
pthread_create (&threadId, NULL, interruptHandler, userData) ; | |||||
while (pinPass != -1) | while (pinPass != -1) | ||||
delay (1) ; | delay (1) ; | ||||
pthread_mutex_unlock (&pinMutex) ; | pthread_mutex_unlock (&pinMutex) ; | ||||
@@ -238,7 +238,7 @@ extern void digitalWriteByte2 (int value) ; | |||||
// (Also Pi hardware specific) | // (Also Pi hardware specific) | ||||
extern int waitForInterrupt (int pin, int mS) ; | extern int waitForInterrupt (int pin, int mS) ; | ||||
extern int wiringPiISR (int pin, int mode, void (*function)(void)) ; | |||||
extern int wiringPiISR (int pin, int mode, void (*function)(void), void *userData) ; | |||||
// Threads | // Threads | ||||