This commit is contained in:
31
gpio/gpio.c
31
gpio/gpio.c
@@ -43,6 +43,7 @@
|
|||||||
#include "../version.h"
|
#include "../version.h"
|
||||||
|
|
||||||
extern int wiringPiDebug ;
|
extern int wiringPiDebug ;
|
||||||
|
int gpioDebug ;
|
||||||
|
|
||||||
// External functions I can't be bothered creating a separate .h file for:
|
// External functions I can't be bothered creating a separate .h file for:
|
||||||
|
|
||||||
@@ -559,14 +560,27 @@ void doExport (int argc, char *argv [])
|
|||||||
static volatile int iterations ;
|
static volatile int iterations ;
|
||||||
static volatile int globalCounter ;
|
static volatile int globalCounter ;
|
||||||
|
|
||||||
|
void printgpioflush(const char* text) {
|
||||||
|
if (gpioDebug) {
|
||||||
|
printf(text);
|
||||||
|
fflush(stdout);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void printgpio(const char* text) {
|
||||||
|
if (gpioDebug) {
|
||||||
|
printf(text);
|
||||||
|
fflush(stdout);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void wfi (void) {
|
static void wfi (void) {
|
||||||
globalCounter++;
|
globalCounter++;
|
||||||
//printf("irq count %d/%d\n", globalCounter , iterations);
|
|
||||||
if(globalCounter>=iterations) {
|
if(globalCounter>=iterations) {
|
||||||
printf("finished\n");
|
printgpio("finished\n");
|
||||||
exit (0) ;
|
exit (0) ;
|
||||||
} else {
|
} else {
|
||||||
printf("I"); fflush(stdout);
|
printgpioflush("I");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -606,12 +620,12 @@ void doWfi (int argc, char *argv [])
|
|||||||
exit (1) ;
|
exit (1) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("wait for interrupt function call \n");
|
printgpio("wait for interrupt function call \n");
|
||||||
for (int Sec=0; Sec<timeoutSec; ++Sec) {
|
for (int Sec=0; Sec<timeoutSec; ++Sec) {
|
||||||
printf("."); fflush(stdout);
|
printgpioflush(".");
|
||||||
delay (999);
|
delay (999);
|
||||||
}
|
}
|
||||||
printf("\nstopping wait for interrupt\n");
|
printgpio("\nstopping wait for interrupt\n");
|
||||||
wiringPiISRStop (pin);
|
wiringPiISRStop (pin);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1385,6 +1399,11 @@ int main (int argc, char *argv [])
|
|||||||
printf ("gpio: wiringPi debug mode enabled\n") ;
|
printf ("gpio: wiringPi debug mode enabled\n") ;
|
||||||
wiringPiDebug = TRUE ;
|
wiringPiDebug = TRUE ;
|
||||||
}
|
}
|
||||||
|
if (getenv ("GPIO_DEBUG") != NULL)
|
||||||
|
{
|
||||||
|
printf ("gpio: gpio debug mode enabled\n") ;
|
||||||
|
gpioDebug = TRUE ;
|
||||||
|
}
|
||||||
|
|
||||||
if (argc == 1)
|
if (argc == 1)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user