#include #include #include #include #include #define IN_PIN 6 static volatile int globalCounter = 0 ; void myInterrupt (void) { ++globalCounter ; } int main (void) { int myCounter = 0 ; int lastCounter = 0 ; if (wiringPiSetup () < 0) { fprintf (stderr, "Unable to setup wiringPi: %s\n", strerror (errno)) ; return 1 ; } pinMode (IN_PIN, INPUT) ; if (wiringPiISR (IN_PIN, INT_EDGE_FALLING, &myInterrupt) < 0) { fprintf (stderr, "Unable to setup ISR: %s\n", strerror (errno)) ; return 1 ; } for (;;) { printf ("Waiting ... ") ; fflush (stdout) ; while (myCounter == globalCounter) delay (1000) ; printf (" Done. counter: %6d: %6d\n", globalCounter, myCounter - lastCounter) ; lastCounter = myCounter ; myCounter = globalCounter ; } return 0 ; }