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.
pulse_decoder.cpp
00001 #include "mbed.h" 00002 #include "pulse_decoder.h" 00003 00004 pulse_decoder::pulse_decoder(PinName pin) 00005 : interrupt(pin), high_period(0), low_period(false) 00006 { 00007 interrupt.rise(this, &pulse_decoder::rising_edge); 00008 interrupt.fall(this, &pulse_decoder::falling_edge); 00009 } 00010 00011 void pulse_decoder::rising_edge() 00012 { 00013 high_timer.start(); 00014 low_timer.stop(); 00015 00016 low_period = low_timer.read_us(); 00017 low_timer.reset(); 00018 } 00019 00020 void pulse_decoder::falling_edge() 00021 { 00022 high_timer.stop(); 00023 low_timer.start(); 00024 00025 high_period = high_timer.read_us(); 00026 high_timer.reset(); 00027 }
Generated on Tue Jul 12 2022 21:48:04 by
1.7.2