From ea2f2323c3ca479d63a0623233a4cc526ace6584 Mon Sep 17 00:00:00 2001 From: mstroh76 Date: Fri, 22 Mar 2024 19:42:16 +0100 Subject: [PATCH] #204 --- gpio/gpio.c | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/gpio/gpio.c b/gpio/gpio.c index 5989fbf..36d1fc1 100644 --- a/gpio/gpio.c +++ b/gpio/gpio.c @@ -43,6 +43,7 @@ #include "../version.h" extern int wiringPiDebug ; +int gpioDebug ; // 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 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) { globalCounter++; - //printf("irq count %d/%d\n", globalCounter , iterations); if(globalCounter>=iterations) { - printf("finished\n"); + printgpio("finished\n"); exit (0) ; } else { - printf("I"); fflush(stdout); + printgpioflush("I"); } } @@ -606,12 +620,12 @@ void doWfi (int argc, char *argv []) exit (1) ; } - printf("wait for interrupt function call \n"); + printgpio("wait for interrupt function call \n"); for (int Sec=0; Sec