Frequency Counter Library. Only for mbed LPC1768, mbed LPC1114FN28, Nucleo-F401 and Nucleo-F411. No way to change pin assign.
Dependents: Frequency_Counter Frequency_wind_speed_measure Frequency_counter_wind_speed
Please refer following page.
http://developer.mbed.org/users/kenjiArai/notebook/simple-frequency-counter/
Diff: freq_counter.h
- Revision:
- 4:9a726b997366
- Parent:
- 3:61bea8bfe404
diff -r 61bea8bfe404 -r 9a726b997366 freq_counter.h --- a/freq_counter.h Wed Oct 22 00:35:23 2014 +0000 +++ b/freq_counter.h Tue Aug 04 03:59:07 2020 +0000 @@ -2,17 +2,12 @@ * mbed Library program * Frequency Counter Hardware relataed program * - * Copyright (c) 2014 Kenji Arai / JH1PJL - * http://www.page.sannet.ne.jp/kenjia/index.html - * http://mbed.org/users/kenjiArai/ - * Created: October 18th, 2014 - * Revised: October 22nd, 2014 - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, - * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE - * AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * Copyright (c) 2014,'20 Kenji Arai / JH1PJL + * http://www7b.biglobe.ne.jp/~kenjia/ + * https://os.mbed.com/users/kenjiArai/ + * Additional functions and modification + * started: October 18th, 2014 + * Revised: August 4th, 2020 */ #ifndef MBED_F_COUNTER @@ -26,21 +21,21 @@ * No way to change pin assign and timer module, * mbed LPC1768 -> p30, * mbed LPC1114FN28 -> dp14, - * Nucleo F401RE & Nucleo F411RE -> PA_0/A0 + * Nucleo F401RE,F411RE & F446RE -> PA_0/A0 * * @code * #include "mbed.h" * #include "freq_counter.h" * - * F_COUNTER fc(p30); // for LPC1768 + * //F_COUNTER fc(p30); // for LPC1768 * //F_COUNTER fc(dp14); // for LPC1114 - * //F_COUNTER fc(PA_0); // for F401 & F411 + * F_COUNTER fc(PA_0); // for F401,F411,F446 * * int main() { * uint32_t frequency = 0; * * while(true) { - * freqency = fc.read_frequency(1.0); // gate time: 1 sec + * freqency = fc.read_frequency(1000000); // gate time: 1 sec * printf("%d [Hz]", frequency); * } * } @@ -56,15 +51,17 @@ F_COUNTER(PinName f_in); /** Read measured frequency - * @param gate time + * @param gate time (uSec) gate = 1sec -> set 1000000 * @return measured frequency */ - uint32_t read_frequency(float gate_time); + uint32_t read_frequency(uint32_t gate_time); protected: DigitalIn _pin; + Timer _t; void initialize(void); + uint32_t rd_frq(uint32_t gate_time); private: uint32_t freq;