This is a very tiny library which counts DigitalIn rising , using "Ticker" interrupts.

Dependents:   mgnetswitch2-NaoKondo

Committer:
MBE13170
Date:
Thu Dec 23 14:56:50 2010 +0000
Revision:
1:a0eb75ae437f
Parent:
0:0bc10e1c0685

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
MBE13170 0:0bc10e1c0685 1 #include "mbed.h"
MBE13170 0:0bc10e1c0685 2
MBE13170 0:0bc10e1c0685 3 class Pswitch {
MBE13170 0:0bc10e1c0685 4 public:
MBE13170 0:0bc10e1c0685 5 Pswitch(PinName in);
MBE13170 0:0bc10e1c0685 6
MBE13170 0:0bc10e1c0685 7 int read (void);
MBE13170 0:0bc10e1c0685 8 int count (void);
MBE13170 0:0bc10e1c0685 9 operator int();
MBE13170 0:0bc10e1c0685 10
MBE13170 0:0bc10e1c0685 11 private :
MBE13170 0:0bc10e1c0685 12 // objects
MBE13170 0:0bc10e1c0685 13 DigitalIn _in;
MBE13170 0:0bc10e1c0685 14 Ticker _ticker;
MBE13170 0:0bc10e1c0685 15
MBE13170 0:0bc10e1c0685 16 // function to take a sample, and update flags
MBE13170 0:0bc10e1c0685 17 void _sample(void);
MBE13170 0:0bc10e1c0685 18
MBE13170 0:0bc10e1c0685 19 // counters and flags
MBE13170 0:0bc10e1c0685 20 int _samples;
MBE13170 0:0bc10e1c0685 21 int _output;
MBE13170 0:0bc10e1c0685 22 int _output_last;
MBE13170 0:0bc10e1c0685 23 int _rising_flag;
MBE13170 0:0bc10e1c0685 24
MBE13170 0:0bc10e1c0685 25 };
MBE13170 0:0bc10e1c0685 26