12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
-
-
- #include <unistd.h>
- #include <iostream>
- #include <signal.h>
- #include "a110x.h"
-
- using namespace std;
-
- int shouldRun = true;
-
- void sig_handler(int signo)
- {
- if (signo == SIGINT)
- shouldRun = false;
- }
-
-
- volatile unsigned int counter = 0;
-
-
- void hallISR(void *arg)
- {
- counter++;
- }
-
- int main ()
- {
- signal(SIGINT, sig_handler);
-
-
-
- upm::A110X* hall = new upm::A110X(2);
-
-
-
-
-
-
- hall->installISR(hallISR, NULL);
-
- while (shouldRun)
- {
- cout << "Pulses detected: " << counter << endl;
-
- sleep(1);
- }
-
-
- cout << "Exiting..." << endl;
-
- delete hall;
- return 0;
- }
|