positive or negative pulse width counter
Diff: PulseCounter.cpp
- Revision:
- 1:d37d6388c179
- Parent:
- 0:89bd4ad6027d
--- a/PulseCounter.cpp Wed Jul 10 15:24:37 2013 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,27 +0,0 @@ -#include "mbed.h" -#include "InterruptIn.h" -#include "PulseCounter.h" - -PulseCounter::PulseCounter(PinName _interrupt,bool positive=true) : interrupt(_interrupt) //constructa -{ - if ( positive ) - { interrupt.rise(this,&PulseCounter::start); - interrupt.fall(this,&PulseCounter::stop); - } - else - { interrupt.fall(this,&PulseCounter::start); - interrupt.rise(this,&PulseCounter::stop); - } -} - -void PulseCounter::start() -{ - _time.reset(); - _time.start(); -} - -void PulseCounter::stop() -{ - _time.stop(); - count = _time.read_us(); -} \ No newline at end of file