Finished working initial version Co-authored-by: Andis Zīle <andis.jarganns@gmail.com> Reviewed-on: #4 Co-authored-by: Andis Zīle <andis.jargans@gmail.com> Co-committed-by: Andis Zīle <andis.jargans@gmail.com>
42 lines
635 B
C++
42 lines
635 B
C++
#ifndef VIRTUAL_COUNTER_H_
|
|
#define VIRTUAL_COUNTER_H_
|
|
|
|
/**** Includes ****/
|
|
#include <stdint.h>
|
|
|
|
namespace util {
|
|
|
|
/**** Public definitions ****/
|
|
class VCounter
|
|
{
|
|
public:
|
|
VCounter(void);
|
|
~VCounter(void);
|
|
|
|
void init(uint16_t top, uint16_t step_us);
|
|
|
|
uint8_t disabled;
|
|
|
|
void reset(void);
|
|
void increment(void);
|
|
uint16_t read(void);
|
|
uint32_t read_ms(void);
|
|
uint16_t read_top(void);
|
|
uint32_t convert_ms(uint16_t raw);
|
|
|
|
#ifndef TESTING
|
|
protected:
|
|
#endif
|
|
uint16_t step_us;
|
|
uint16_t counter;
|
|
uint16_t top;
|
|
};
|
|
|
|
/**** Public function declarations ****/
|
|
|
|
#ifdef TESTING
|
|
#endif
|
|
|
|
} //namespace
|
|
|
|
#endif /* VIRTUAL_COUNTER_H_ */ |