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.cpp
00001 #include "mbed.h" 00002 #include "InterruptIn.h" 00003 #include "PulseWidthCounter.h" 00004 00005 PulseWidthCounter::PulseWidthCounter(PinName inpin,bool positive) : pulsein(inpin) //constructa 00006 { 00007 if ( positive ) 00008 { pulsein.rise(callback(this,&PulseWidthCounter::start)); 00009 pulsein.fall(callback(this,&PulseWidthCounter::stop)); 00010 } 00011 else 00012 { pulsein.fall(callback(this,&PulseWidthCounter::start)); 00013 pulsein.rise(callback(this,&PulseWidthCounter::stop)); 00014 } 00015 } 00016 00017 void PulseWidthCounter::start() 00018 { 00019 _time.reset(); 00020 _time.start(); 00021 } 00022 00023 void PulseWidthCounter::stop() 00024 { 00025 _time.stop(); 00026 count = _time.read_us(); 00027 } 00028
Generated on Wed Jul 13 2022 09:20:34 by
1.7.2