-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTimer.hpp
63 lines (41 loc) · 1.07 KB
/
Timer.hpp
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
#pragma once
//Timer2/Timer3/Timer4/Timer5
#include <cstdint>
#include "Reg.hpp"
class Timer : private Reg {
public:
enum
TMRX { TMR2, TMR3, TMR4, TMR5 };
//instantiate with timer number
Timer (TMRX);
auto
count (uint32_t) -> void;
auto
count () -> uint32_t;
auto
period (uint32_t) -> void;
auto
period () -> uint32_t;
auto
on (bool) -> void;
auto
stop_idle (bool) -> void;
auto
gate (bool) -> void;
enum
PRESCALE { PS1, PS2, PS4, PS8, PS16, PS32, PS64, PS256 = 8 };
auto
prescale (PRESCALE) -> void;
auto
prescale () -> PRESCALE;
auto
mode32 (bool) -> void; //T2 and T4 only (harmless for T3 and T5)
enum
CLK { PBCLK, TxCK };
auto
clk_src (CLK) -> void;
private:
volatile uint32_t* m_txcon;
volatile uint32_t& m_tmrx;
volatile uint32_t& m_prx;
};