Used to read incoming PWM signals from RC channels
PulseIn.cpp
- Committer:
- KarimAzzouz
- Date:
- 2013-01-08
- Revision:
- 2:4abac72addb7
- Parent:
- 1:eaf70ff4df07
File content as of revision 2:4abac72addb7:
#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(); }