-
-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathcmpc.hpp
216 lines (189 loc) · 7.6 KB
/
cmpc.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
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
#pragma once
//=========================================================================//
/*! @file
@brief Comparator C / コンパレータ C @n
・RX13T @n
・RX23T @n
・RX24T/RX24U @n
・RX26T @n
・RX66T/RX72T @n
・RX660
@author 平松邦仁 ([email protected])
@copyright Copyright (C) 2016, 2024 Kunihito Hiramatsu @n
Released under the MIT license @n
https://github.com/hirakuni45/RX/blob/master/LICENSE
*/
//=========================================================================//
#include "common/device.hpp"
namespace device {
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
/*!
@brief CMPC class
@param[in] base ベース・アドレス
@param[in] per ペリフェラル型
@param[in] IVT 割り込み型
@param[in] ivec 割り込みベクタ型
*/
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
template <uint32_t base, peripheral per, typename IVT, IVT ivec>
struct cmpc_t {
static constexpr auto PERIPHERAL = per; ///< ペリフェラル型
static constexpr auto IVEC = ivec; ///< 割り込みベクター
//-----------------------------------------------------------------//
/*!
@brief コンパレータ制御レジスタ(CMPCTL)
@param[in] ofs オフセット
*/
//-----------------------------------------------------------------//
template <uint32_t ofs>
struct cmpctl_t : public rw8_t<ofs> {
typedef rw8_t<ofs> io_;
using io_::operator =;
using io_::operator ();
using io_::operator |=;
using io_::operator &=;
bit_rw_t <io_, bitpos::B0> CINV;
bit_rw_t <io_, bitpos::B1> COE;
bits_rw_t<io_, bitpos::B3, 2> CEG;
bits_rw_t<io_, bitpos::B5, 2> CDFS;
bit_rw_t <io_, bitpos::B7> HCMPON;
};
static inline cmpctl_t<base + 0x00> CMPCTL;
//-----------------------------------------------------------------//
/*!
@brief コンパレータ入力切り替えレジスタ(CMPSEL0)
@param[in] ofs オフセット
*/
//-----------------------------------------------------------------//
template <uint32_t ofs>
struct cmpsel0_t : public rw8_t<ofs> {
typedef rw8_t<ofs> io_;
using io_::operator =;
using io_::operator ();
using io_::operator |=;
using io_::operator &=;
bits_rw_t<io_, bitpos::B0, 4> CMPSEL;
};
static inline cmpsel0_t<base + 0x04> CMPSEL0;
//-----------------------------------------------------------------//
/*!
@brief コンパレータ入力切り替えレジスタ(CMPSEL1)
@param[in] ofs オフセット
*/
//-----------------------------------------------------------------//
template <uint32_t ofs>
struct cmpsel1_t : public rw8_t<ofs> {
typedef rw8_t<ofs> io_;
using io_::operator =;
using io_::operator ();
using io_::operator |=;
using io_::operator &=;
bits_rw_t<io_, bitpos::B0, 4> CVRS;
};
static inline cmpsel1_t<base + 0x08> CMPSEL1;
//-----------------------------------------------------------------//
/*!
@brief コンパレータ出力モニタレジスタ(CMPMON)
@param[in] ofs オフセット
*/
//-----------------------------------------------------------------//
template <uint32_t ofs>
struct cmpmon_t : public rw8_t<ofs> {
typedef rw8_t<ofs> io_;
using io_::operator =;
using io_::operator ();
using io_::operator |=;
using io_::operator &=;
bit_rw_t<io_, bitpos::B0> CMPMON0;
};
static inline cmpmon_t<base + 0x0C> CMPMON;
//-----------------------------------------------------------------//
/*!
@brief コンパレータ外部出力許可レジスタ(CMPIOC)
@param[in] ofs オフセット
*/
//-----------------------------------------------------------------//
template <uint32_t ofs>
struct cmpioc_t : public rw8_t<ofs> {
typedef rw8_t<ofs> io_;
using io_::operator =;
using io_::operator ();
using io_::operator |=;
using io_::operator &=;
bit_rw_t<io_, bitpos::B0> CPOE;
};
static inline cmpioc_t<base + 0x10> CMPIOC;
};
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
/*!
@brief コンパレータ C(CMPC)
@param[in] base ベース・アドレス
@param[in] per ペリフェラル型
@param[in] ivec 割り込みベクタ型
*/
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
template <uint32_t base, peripheral per, ICU::VECTOR ivec>
struct cmpca_t : public cmpc_t<base, per, ICU::VECTOR, ivec> {
//-----------------------------------------------------------------//
/*!
@brief コンパレータ入力切り替えレジスタ(CMPSEL1)
@param[in] ofs オフセット
*/
//-----------------------------------------------------------------//
template <uint32_t ofs>
struct cmpsel1_t : public rw8_t<ofs> {
typedef rw8_t<ofs> io_;
using io_::operator =;
using io_::operator ();
using io_::operator |=;
using io_::operator &=;
bits_rw_t<io_, bitpos::B0, 4> CVRS;
};
static inline cmpsel1_t<base + 0x08> CMPSEL1;
//-----------------------------------------------------------------//
/*!
@brief コンパレータ制御レジスタ 2 (CMPCTL2)
@param[in] ofs オフセット
*/
//-----------------------------------------------------------------//
template <uint32_t ofs>
struct cmpctl2_t : public rw8_t<ofs> {
typedef rw8_t<ofs> io_;
using io_::operator =;
using io_::operator ();
using io_::operator |=;
using io_::operator &=;
bit_rw_t<io_, bitpos::B0> CNFS;
};
static inline cmpctl2_t<base + 0x18> CMPCTL2;
};
#if defined(SIG_RX13T) || defined(SIG_RX23T)
typedef cmpc_t<0x000A'0C80, peripheral::CMPC0, ICU::VECTOR, ICU::VECTOR::CMPC0> CMPC0;
typedef cmpc_t<0x000A'0CA0, peripheral::CMPC1, ICU::VECTOR, ICU::VECTOR::CMPC1> CMPC1;
typedef cmpc_t<0x000A'0CC0, peripheral::CMPC2, ICU::VECTOR, ICU::VECTOR::CMPC2> CMPC2;
#elif defined(SIG_RX24T) || defined(SIG_RX24U)
typedef cmpc_t<0x000A'0C80, peripheral::CMPC0, ICU::VECTOR, ICU::VECTOR::CMPC0> CMPC0;
typedef cmpc_t<0x000A'0CA0, peripheral::CMPC1, ICU::VECTOR, ICU::VECTOR::CMPC1> CMPC1;
typedef cmpc_t<0x000A'0CC0, peripheral::CMPC2, ICU::VECTOR, ICU::VECTOR::CMPC2> CMPC2;
typedef cmpc_t<0x000A'0CE0, peripheral::CMPC3, ICU::VECTOR, ICU::VECTOR::CMPC3> CMPC3;
#elif defined(SIG_RX26T)
typedef cmpca_t<0x000A'0C80, peripheral::CMPC0, ICU::VECTOR::CMPC0> CMPC0;
typedef cmpca_t<0x000A'0CA0, peripheral::CMPC1, ICU::VECTOR::CMPC1> CMPC1;
typedef cmpca_t<0x000A'0CC0, peripheral::CMPC2, ICU::VECTOR::CMPC2> CMPC2;
typedef cmpca_t<0x000A'0CE0, peripheral::CMPC3, ICU::VECTOR::CMPC3> CMPC3;
typedef cmpca_t<0x000A'0D00, peripheral::CMPC4, ICU::VECTOR::CMPC4> CMPC4;
typedef cmpca_t<0x000A'0D20, peripheral::CMPC5, ICU::VECTOR::CMPC5> CMPC5;
#elif defined(SIG_RX66T) || defined(SIG_RX72T)
typedef cmpc_t<0x000A'0C80, peripheral::CMPC0, ICU::VECTOR, ICU::VECTOR::CMPC0> CMPC0;
typedef cmpc_t<0x000A'0CA0, peripheral::CMPC1, ICU::VECTOR, ICU::VECTOR::CMPC1> CMPC1;
typedef cmpc_t<0x000A'0CC0, peripheral::CMPC2, ICU::VECTOR, ICU::VECTOR::CMPC2> CMPC2;
typedef cmpc_t<0x000A'0CE0, peripheral::CMPC3, ICU::VECTOR, ICU::VECTOR::CMPC3> CMPC3;
typedef cmpc_t<0x000A'0D00, peripheral::CMPC4, ICU::VECTOR, ICU::VECTOR::CMPC4> CMPC4;
typedef cmpc_t<0x000A'0D20, peripheral::CMPC5, ICU::VECTOR, ICU::VECTOR::CMPC5> CMPC5;
#elif defined(SIG_RX660)
typedef cmpc_t<0x000A'0C80, peripheral::CMPC0, ICU::SELECTB, ICU::SELECTB::CMPC0> CMPC0;
typedef cmpc_t<0x000A'0CA0, peripheral::CMPC1, ICU::SELECTB, ICU::SELECTB::CMPC1> CMPC1;
typedef cmpc_t<0x000A'0CC0, peripheral::CMPC2, ICU::SELECTB, ICU::SELECTB::CMPC2> CMPC2;
typedef cmpc_t<0x000A'0CE0, peripheral::CMPC3, ICU::SELECTB, ICU::SELECTB::CMPC3> CMPC3;
#endif
}