-
Notifications
You must be signed in to change notification settings - Fork 1
/
Clc.cpp
123 lines (108 loc) · 3.5 KB
/
Clc.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#include "Clc.hpp"
enum {
CLCXCON_SPACING = 32, //spacing in words
CLC1CON = 0xBF802480,
ON = 15,
SIDL = 13,
INTP = 11,
INTN = 10,
LCOE = 7,
LCOUT = 6,
LCPOL = 5,
CLCXSEL = 4, //offsets in words
CLCXGLS = 8, //offsets in words
};
//=============================================================================
Clc::
Clc (CLCX e)
: m_clcx_con((volatile uint32_t*)CLC1CON + (e * CLCXCON_SPACING))
{
}
//=============================================================================
auto Clc::
gate_inv (GXPOL e, bool tf) -> void
{
setbit(m_clcx_con, e, tf);
}
//=============================================================================
auto Clc::
on (bool tf) -> void
{
setbit(m_clcx_con, 1<<ON, tf);
}
//=============================================================================
auto Clc::
stop_idle (bool tf) -> void
{
setbit(m_clcx_con, 1<<SIDL, tf);
}
//=============================================================================
auto Clc::
intp (bool tf) -> void
{
setbit(m_clcx_con, 1<<INTP, tf);
}
//=============================================================================
auto Clc::
intn (bool tf) -> void
{
setbit(m_clcx_con, 1<<INTN, tf);
}
//=============================================================================
auto Clc::
out (bool tf) -> void
{
setbit(m_clcx_con, 1<<LCOE, tf);
}
//=============================================================================
auto Clc::
out () -> bool
{
return anybit(m_clcx_con, 1<<LCOUT);
}
//=============================================================================
auto Clc::
out_inv (bool tf) -> void
{
setbit(m_clcx_con, 1<<LCPOL, tf);
}
//=============================================================================
auto Clc::
mode (MODE e) -> void
{
clrbit(m_clcx_con, LSR);
setbit(m_clcx_con, e);
}
//input select (no change if v invalid value)
//=============================================================================
auto Clc::
in_sel (SELX e, uint8_t v) -> void
{
if(v > 7) return;
uint8_t n = e << 2;
clrbit(m_clcx_con + CLCXSEL, 7<<n);
setbit(m_clcx_con + CLCXSEL, v<<n);
}
//or precomputed value for all gates
//=============================================================================
auto Clc::
in_sel (uint32_t v) -> void
{
val(m_clcx_con + CLCXSEL, v);
}
//gate select setting fo one gate
//=============================================================================
auto Clc::
gate_sel (GLSX e, uint8_t v) -> void
{
uint8_t n = e << 3;
clrbit(m_clcx_con + CLCXGLS, 15<<n);
setbit(m_clcx_con + CLCXGLS, v<<n);
}
//or precomputed register value for all gates
//=============================================================================
auto Clc::
gate_sel (uint32_t v) -> void
{
val(m_clcx_con + CLCXGLS, v);
}