-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathComp.cpp
95 lines (83 loc) · 2.62 KB
/
Comp.cpp
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#include "Comp.hpp"
enum {
CMSTAT = 0xBF802300, //same for all
SIDL = 13,
CVREFSEL = 8,
CM1CON = 0xBF802310, CMXCON_SPACING = 8, //spacing in words
ON = 15,
COE = 14,
CPOL = 13,
CEVT = 9,
COUT = 8,
EVPOL_SHIFT = 6, EVPOL_CLR = 3,
CREF = 4
};
//=============================================================================
Comp::
Comp (CMX e)
: m_cmpx_con((volatile uint32_t*)CM1CON + (e * CMXCON_SPACING))
{
}
//=============================================================================
auto Comp::
on (bool tf) -> void
{
setbit(m_cmpx_con, 1<<ON, tf);
}
//=============================================================================
auto Comp::
out (bool tf) -> void
{
setbit(m_cmpx_con, 1<<COE, tf);
}
//=============================================================================
auto Comp::
out_inv (bool tf) -> void
{
setbit(m_cmpx_con, 1<<CPOL, tf);
}
//=============================================================================
auto Comp::
evt_bit () -> bool
{
return anybit(m_cmpx_con, 1<<CEVT);
}
//=============================================================================
auto Comp::
out_bit () -> bool
{
return anybit(m_cmpx_con, 1<<COUT);
}
//=============================================================================
auto Comp::
evt_sel (EVPOL e) -> void
{
clrbit(m_cmpx_con, EVPOL_CLR<<EVPOL_SHIFT);
setbit(m_cmpx_con, e<<EVPOL_SHIFT);
}
//=============================================================================
auto Comp::
cref_cxina (bool tf) -> void
{
setbit(m_cmpx_con, 1<<CREF, not tf);
}
//=============================================================================
auto Comp::
ch_sel (CCH e) -> void
{
clrbit(m_cmpx_con, BGAP);
setbit(m_cmpx_con, e);
}
//common static functions
//=============================================================================
auto Comp::
stop_idle (bool tf) -> void
{
setbit(CMSTAT, 1<<SIDL, tf);
}
//=============================================================================
auto Comp::
cref_sel (CVREF e) -> void
{
setbit(CMSTAT, 1<<CVREFSEL, e);
}