Used to read incoming PWM signals from RC channels
Diff: PulseIn.cpp
- Revision:
- 3:c98b23d53e42
- Parent:
- 2:4abac72addb7
--- a/PulseIn.cpp Tue Jan 08 15:01:22 2013 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,28 +0,0 @@ -#include "PulseIn.h" - -PulseIn::PulseIn(PinName p) : _k(p) -{ - _k.mode(PullDown); - _k.rise(this, &PulseIn::rise); - _k.fall(this, &PulseIn::fall); - _duration=0; - -} - -int PulseIn::read() -{ - return _duration; -} - - -void PulseIn::rise() -{ - t.start(); -} - -void PulseIn::fall() -{ - t.stop(); - _duration = t.read_us(); - t.reset(); -}