A simple tachometer implementation. This used to be a sub-module in another project.
It works by setting up a periodic timer and an interrupt. The interrupt increases a counter each time the GPIO alters state. The timer calculates the number of alternations over time and presents the frequency [Hz] to the 'clients'.
###Public API
Setup the GPIO,interrupt and timer:
void tachometer_init(uint8_t ioPin);
Returns the frequency from the last timer period:
uint32_t tachometer_getSample(void);
###Example
See esp8266_digoleserial demo.
###Todo
- remove hardcoded timer period
- Implementation uses global static data so there can only be on call to
tachometer_init()