Test code for interfacing to megasquirt ECU.

Dependencies:   jtlcd mbed

Committer:
jont
Date:
Mon Feb 16 08:34:14 2015 +0000
Revision:
4:50203a03ccd2
Parent:
0:cf99a7b873b3
Changed greeting message

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jont 0:cf99a7b873b3 1 #ifndef COUNTER_
jont 0:cf99a7b873b3 2 #define COUNTER_
jont 0:cf99a7b873b3 3
jont 0:cf99a7b873b3 4 #define DEBOUNCING_INTERVAL 200 // Debouncing interval (in mili-seconds)
jont 0:cf99a7b873b3 5 /*=====================================================================================*/
jont 0:cf99a7b873b3 6 // Counter object, which also setups up irq
jont 0:cf99a7b873b3 7 /*=====================================================================================*/
jont 0:cf99a7b873b3 8
jont 0:cf99a7b873b3 9 //from http://mbed.org/handbook/InterruptIn, modified to add debouncing
jont 0:cf99a7b873b3 10 class Counter
jont 0:cf99a7b873b3 11 {
jont 0:cf99a7b873b3 12 public:
jont 0:cf99a7b873b3 13 Counter(PinName pin, void (*function)(void));
jont 0:cf99a7b873b3 14
jont 0:cf99a7b873b3 15 void increment();
jont 0:cf99a7b873b3 16
jont 0:cf99a7b873b3 17 int read();
jont 0:cf99a7b873b3 18
jont 0:cf99a7b873b3 19 int set(int val);
jont 0:cf99a7b873b3 20
jont 0:cf99a7b873b3 21 void reset();
jont 0:cf99a7b873b3 22
jont 0:cf99a7b873b3 23 private:
jont 0:cf99a7b873b3 24 InterruptIn _interrupt;
jont 0:cf99a7b873b3 25 volatile int _count;
jont 0:cf99a7b873b3 26 Timer t; // To manage debounce by menchanical switch
jont 0:cf99a7b873b3 27 protected:
jont 0:cf99a7b873b3 28 //the callback
jont 0:cf99a7b873b3 29 FunctionPointer jim;
jont 0:cf99a7b873b3 30 };
jont 0:cf99a7b873b3 31
jont 0:cf99a7b873b3 32
jont 0:cf99a7b873b3 33
jont 0:cf99a7b873b3 34 #endif