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 _interrupt,bool positive=true) : interrupt(_interrupt) //constructa 00006 { 00007 if ( positive ) 00008 { interrupt.rise(this,&PulseWidthCounter::start); 00009 interrupt.fall(this,&PulseWidthCounter::stop); 00010 } 00011 else 00012 { interrupt.fall(this,&PulseWidthCounter::start); 00013 interrupt.rise(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 }
Generated on Thu Jul 21 2022 20:24:32 by
1.7.2