counts digital frequency based on interrupt and timer, triggers on rising edge
FrequencyCounter.h@0:91a906dbf731, 2016-08-09 (annotated)
- Committer:
- awmiller
- Date:
- Tue Aug 09 20:03:10 2016 +0000
- Revision:
- 0:91a906dbf731
first edition;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
awmiller | 0:91a906dbf731 | 1 | #ifndef FREQUENCY_COUNTER_H_DECL |
awmiller | 0:91a906dbf731 | 2 | #define FREQUENCY_COUNTER_H_DECL |
awmiller | 0:91a906dbf731 | 3 | |
awmiller | 0:91a906dbf731 | 4 | #include <mbed.h> |
awmiller | 0:91a906dbf731 | 5 | |
awmiller | 0:91a906dbf731 | 6 | class FrequencyCounter { |
awmiller | 0:91a906dbf731 | 7 | //mbed classes |
awmiller | 0:91a906dbf731 | 8 | Timer _mtime; |
awmiller | 0:91a906dbf731 | 9 | InterruptIn _cPin; |
awmiller | 0:91a906dbf731 | 10 | |
awmiller | 0:91a906dbf731 | 11 | double _lastTime; |
awmiller | 0:91a906dbf731 | 12 | double _fq; |
awmiller | 0:91a906dbf731 | 13 | double _iircoef; |
awmiller | 0:91a906dbf731 | 14 | void _irqs(void); |
awmiller | 0:91a906dbf731 | 15 | |
awmiller | 0:91a906dbf731 | 16 | public: |
awmiller | 0:91a906dbf731 | 17 | |
awmiller | 0:91a906dbf731 | 18 | FrequencyCounter(PinName); |
awmiller | 0:91a906dbf731 | 19 | double getFrequency(); |
awmiller | 0:91a906dbf731 | 20 | double getTime(); |
awmiller | 0:91a906dbf731 | 21 | void setIIRCoeff(double); |
awmiller | 0:91a906dbf731 | 22 | void start(); |
awmiller | 0:91a906dbf731 | 23 | void stop(); |
awmiller | 0:91a906dbf731 | 24 | }; |
awmiller | 0:91a906dbf731 | 25 | #endif |
awmiller | 0:91a906dbf731 | 26 |