This commit is contained in:
@@ -395,9 +395,6 @@ int wiringPiReturnCodes = FALSE ;
|
||||
|
||||
int wiringPiTryGpioMem = FALSE ;
|
||||
|
||||
// sysFds:
|
||||
// Map a file descriptor from the /sys/class/gpio/gpioX/value
|
||||
|
||||
static unsigned int lineFlags [64] =
|
||||
{
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
@@ -414,7 +411,7 @@ static int lineFds [64] =
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
} ;
|
||||
|
||||
static int sysFds [64] =
|
||||
static int isrFds [64] =
|
||||
{
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
@@ -2323,7 +2320,7 @@ int waitForInterrupt (int pin, int mS)
|
||||
else if (wiringPiMode == WPI_MODE_PHYS)
|
||||
pin = physToGpio [pin] ;
|
||||
|
||||
if ((fd = sysFds [pin]) == -1)
|
||||
if ((fd = isrFds [pin]) == -1)
|
||||
return -2 ;
|
||||
|
||||
// Setup poll structure
|
||||
@@ -2338,10 +2335,10 @@ int waitForInterrupt (int pin, int mS)
|
||||
} else {
|
||||
//if (polls.revents & POLLIN)
|
||||
if (wiringPiDebug) {
|
||||
printf ("wiringPi: IRQ line %d received %d, fd=%d\n", pin, ret, sysFds [pin]) ;
|
||||
printf ("wiringPi: IRQ line %d received %d, fd=%d\n", pin, ret, isrFds[pin]) ;
|
||||
}
|
||||
/* read event data */
|
||||
int readret = read(sysFds [pin], &evdata, sizeof(evdata));
|
||||
int readret = read(isrFds [pin], &evdata, sizeof(evdata));
|
||||
if (readret == sizeof(evdata)) {
|
||||
if (wiringPiDebug) {
|
||||
printf ("wiringPi: IRQ data id: %d, timestamp: %lld\n", evdata.id, evdata.timestamp) ;
|
||||
@@ -2407,7 +2404,7 @@ int waitForInterruptInit (int pin, int mode)
|
||||
|
||||
/* set event fd nonbloack read */
|
||||
int fd_line = req.fd;
|
||||
sysFds [pin] = fd_line;
|
||||
isrFds [pin] = fd_line;
|
||||
int flags = fcntl(fd_line, F_GETFL);
|
||||
flags |= O_NONBLOCK;
|
||||
ret = fcntl(fd_line, F_SETFL, flags);
|
||||
@@ -2421,7 +2418,7 @@ int waitForInterruptInit (int pin, int mode)
|
||||
|
||||
|
||||
int waitForInterruptClose (int pin) {
|
||||
if (sysFds[pin]>0) {
|
||||
if (isrFds[pin]>0) {
|
||||
if (wiringPiDebug) {
|
||||
printf ("wiringPi: waitForInterruptClose close thread 0x%lX\n", (unsigned long)isrThreads[pin]) ;
|
||||
}
|
||||
@@ -2434,9 +2431,9 @@ int waitForInterruptClose (int pin) {
|
||||
fprintf (stderr, "wiringPi: waitForInterruptClose could not cancel thread\n");
|
||||
}
|
||||
}
|
||||
close(sysFds [pin]);
|
||||
close(isrFds [pin]);
|
||||
}
|
||||
sysFds [pin] = -1;
|
||||
isrFds [pin] = -1;
|
||||
isrFunctions [pin] = NULL;
|
||||
|
||||
/* -not closing so far - other isr may be using it - only close if no other is using - will code later
|
||||
|
||||
@@ -186,66 +186,3 @@ int piGpioLayoutLegacy (void)
|
||||
|
||||
return gpioLayout ;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* wiringPiSetupSys:
|
||||
* Must be called once at the start of your program execution.
|
||||
*
|
||||
* Initialisation (again), however this time we are using the /sys/class/gpio
|
||||
* interface to the GPIO systems - slightly slower, but always usable as
|
||||
* a non-root user, assuming the devices are already exported and setup correctly.
|
||||
*/
|
||||
|
||||
/*
|
||||
int wiringPiSetupSys (void)
|
||||
{
|
||||
char fName [128] ;
|
||||
|
||||
if (wiringPiSetuped)
|
||||
return 0 ;
|
||||
|
||||
wiringPiSetuped = TRUE ;
|
||||
|
||||
if (getenv (ENV_DEBUG) != NULL)
|
||||
wiringPiDebug = TRUE ;
|
||||
|
||||
if (getenv (ENV_CODES) != NULL)
|
||||
wiringPiReturnCodes = TRUE ;
|
||||
|
||||
if (wiringPiDebug)
|
||||
printf ("wiringPi: wiringPiSetupSys called\n") ;
|
||||
|
||||
int model, rev, mem, maker, overVolted ;
|
||||
piBoardId (&model, &rev, &mem, &maker, &overVolted) ;
|
||||
|
||||
if (piGpioLayout () == GPIO_LAYOUT_PI1_REV1)
|
||||
{
|
||||
pinToGpio = pinToGpioR1 ;
|
||||
physToGpio = physToGpioR1 ;
|
||||
}
|
||||
else
|
||||
{
|
||||
pinToGpio = pinToGpioR2 ;
|
||||
physToGpio = physToGpioR2 ;
|
||||
}
|
||||
|
||||
// Open and scan the directory, looking for exported GPIOs, and pre-open
|
||||
// the 'value' interface to speed things up for later
|
||||
|
||||
for (int pin = 0, maxpin=GetMaxPin() ; pin <= maxpin ; ++pin)
|
||||
{
|
||||
int pinFS = GPIOToSysFS(pin);
|
||||
if (pinFS>=0) {
|
||||
sprintf (fName, "/sys/class/gpio/gpio%d/value", pinFS) ;
|
||||
sysFds [pin] = open (fName, O_RDWR) ;
|
||||
}
|
||||
}
|
||||
|
||||
initialiseEpoch () ;
|
||||
|
||||
wiringPiMode = WPI_MODE_GPIO_SYS ;
|
||||
|
||||
return 0 ;
|
||||
}
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user