Used to read incoming PWM signals from RC channels

Dependents:   A-Quad

PulseIn.cpp

Committer:
KarimAzzouz
Date:
2012-12-19
Revision:
0:1a57c7f88422
Child:
1:eaf70ff4df07

File content as of revision 0:1a57c7f88422:

#include "PulseIn.h"
#include "mbed.h"
 
PulseIn::PulseIn(PinName p) : _k(p)
{
    _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();
}