This commit is contained in:
mstroh76
2024-03-22 19:42:16 +01:00
parent c1a86f41f2
commit ea2f2323c3

View File

@@ -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)
{ {