-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathRTCTimer.hpp
More file actions
81 lines (62 loc) · 1.71 KB
/
Copy pathRTCTimer.hpp
File metadata and controls
81 lines (62 loc) · 1.71 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#ifndef EVT_TIMER_H
#define EVT_TIMER_H
#include <core/dev/RTC.hpp>
#include <core/dev/Timer.hpp>
#include <core/utils/time.hpp>
namespace time = core::time;
namespace core::dev {
class RTCTimer : public Timer {
public:
/**
* Create instance of RTCTimer.
* clock period defaults to 1s.
*
* @param r
*/
RTCTimer(RTC& r);
/**
* Create instance of RTCTimer.
*
* @param[in] r Instance of on-board
* @param[in] clock Amount of time it takes for the time to go off in ms
*/
RTCTimer(RTC& r, uint32_t clock);
/**
* not implemented.
*
* @param[in] irqHandler The IRQ Handler function pointer. Sets a new interrupt handler function
*/
void startTimer(void (*irqHandler)(void* htim)) override {}
void startTimer() override;
void stopTimer() override;
void reloadTimer() override;
void setPeriod(uint32_t clock, uint32_t clockPrescaler) override;
/**
* Gets the time since the RTC clock began in seconds
*
* @return the time since the RTC clock began
*/
uint32_t getTime();
/**
* Gets whether the timer has gone off
*
* @return whether the time has gone off
*/
bool hasGoneOff();
private:
/** Instance of on-board*/
RTC& rtc;
/**
* The amount of seconds that have elapsed while the timer is running.
* Only updates when stopTimer() is called.
*/
uint32_t time;
/** The amount of time it takes the timer to go off in SECONDS */
uint32_t clockPeriod;
/** The epoc time the clock started */
uint32_t startTime;
/** true if timer has been stopped */
bool bTimerStopped;
};
} // namespace core::dev
#endif // EVT_TIMER_H