-
Notifications
You must be signed in to change notification settings - Fork 852
/
Copy pathIRtimer.h
40 lines (33 loc) · 915 Bytes
/
IRtimer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// Copyright 2017 David Conran
#ifndef IRTIMER_H_
#define IRTIMER_H_
#define __STDC_LIMIT_MACROS
#include <stdint.h>
// Classes
/// This class offers a simple counter in micro-seconds since instantiated.
/// @note Handles when the system timer wraps around (once).
class IRtimer {
public:
IRtimer();
void reset();
uint32_t elapsed();
#ifdef UNIT_TEST
static void add(uint32_t usecs);
#endif // UNIT_TEST
private:
uint32_t start; ///< Time in uSeconds when the class was instantiated/reset.
};
/// This class offers a simple counter in milli-seconds since instantiated.
/// @note Handles when the system timer wraps around (once).
class TimerMs {
public:
TimerMs();
void reset();
uint32_t elapsed();
#ifdef UNIT_TEST
static void add(uint32_t msecs);
#endif // UNIT_TEST
private:
uint32_t start; ///< Time in mSeconds when the class was instantiated/reset.
};
#endif // IRTIMER_H_