Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
PulseWidthCounter/PulseWidthCounter.cpp
- Committer:
- komaida424
- Date:
- 2013-11-15
- Revision:
- 2:59ac9df97701
- Child:
- 8:1db19b529b22
File content as of revision 2:59ac9df97701:
#include "mbed.h"
#include "InterruptIn.h"
#include "PulseWidthCounter.h"
PulseWidthCounter::PulseWidthCounter(PinName _interrupt,bool positive) : interrupt(_interrupt) //constructa
{
if ( positive )
{ interrupt.rise(this,&PulseWidthCounter::start);
interrupt.fall(this,&PulseWidthCounter::stop);
}
else
{ interrupt.fall(this,&PulseWidthCounter::start);
interrupt.rise(this,&PulseWidthCounter::stop);
}
}
void PulseWidthCounter::start()
{
_time.reset();
_time.start();
}
void PulseWidthCounter::stop()
{
_time.stop();
count = _time.read_us();
}