-
-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathcmtw.hpp
182 lines (153 loc) · 6.65 KB
/
cmtw.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
#pragma once
//=============================================================================//
/*! @file
@brief Compare Match Timer W / コンペアマッチタイマ W @n
RX26T @n
RX64M/RX71M @n
RX65N/RX651 @n
RX66N @n
RX660/RX671 @n
RX72N/RX72M
@author 平松邦仁 (hira@rvf-rc45.net)
@copyright Copyright (C) 2018, 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 CMPW class
@param[in] base ベース・アドレス
@param[in] per ペリフェラル
@param[in] cmwi コンペア・マッチ割り込みベクタ
@param[in] CIVT キャプチャ系・割り込み型
@param[in] ic0i インプット・キャプチャ 0 割り込みベクタ
@param[in] ic1i インプット・キャプチャ 1 割り込みベクタ
@param[in] oc0i アウトプット・キャプチャ 0 割り込みベクタ
@param[in] oc1i アウトプット・キャプチャ 1 割り込みベクタ
*/
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
template <uint32_t base, peripheral per, ICU::VECTOR cmwi, typename CIVT,
CIVT ic0i, CIVT ic1i, CIVT oc0i, CIVT oc1i>
struct cmtw_t {
static constexpr auto PERIPHERAL = per; ///< ペリフェラル型
static constexpr auto CMWI = cmwi; ///< コンペア・マッチ割り込みベクタ
static constexpr auto IC0I = ic0i; ///< インプット・キャプチャ 0 割り込みベクタ
static constexpr auto IC1I = ic1i; ///< インプット・キャプチャ 1 割り込みベクタ
static constexpr auto OC0I = oc0i; ///< アウトプット・キャプチャ 0 割り込みベクタ
static constexpr auto OC1I = oc1i; ///< アウトプット・キャプチャ 1 割り込みベクタ
static constexpr auto PCLK = clock_profile::PCLKB; ///< PCLK 周波数
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
/*!
@brief タイマスタートレジスタ(CMWSTR)
@param[in] ofs レジスタ・オフセット
*/
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
template <uint32_t ofs>
struct cmwstr_t : public rw16_t<ofs> {
typedef rw16_t<ofs> io_;
using io_::operator =;
using io_::operator ();
using io_::operator |=;
using io_::operator &=;
bit_rw_t <io_, bitpos::B0> STR;
};
static inline cmwstr_t<base + 0x00> CMWSTR;
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
/*!
@brief タイマコントロールレジスタ(CMWCR)
@param[in] ofs レジスタ・オフセット
*/
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
template <uint32_t ofs>
struct cmwcr_t : public rw16_t<ofs> {
typedef rw16_t<ofs> io_;
using io_::operator =;
using io_::operator ();
using io_::operator |=;
using io_::operator &=;
bits_rw_t<io_, bitpos::B0, 2> CKS;
bit_rw_t <io_, bitpos::B3> CMWIE;
bit_rw_t <io_, bitpos::B4> IC0IE;
bit_rw_t <io_, bitpos::B5> IC1IE;
bit_rw_t <io_, bitpos::B6> OC0IE;
bit_rw_t <io_, bitpos::B7> OC1IE;
bit_rw_t <io_, bitpos::B9> CMS;
bits_rw_t<io_, bitpos::B13, 3> CCLR;
};
static inline cmwcr_t<base + 0x04> CMWCR;
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
/*!
@brief タイマ I/O コントロールレジスタ(CMWIOR)
@param[in] ofs レジスタ・オフセット
*/
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
template <uint32_t ofs>
struct cmwior_t : public rw16_t<ofs> {
typedef rw16_t<ofs> io_;
using io_::operator =;
using io_::operator ();
using io_::operator |=;
using io_::operator &=;
bits_rw_t<io_, bitpos::B0, 2> IC0;
bits_rw_t<io_, bitpos::B2, 2> IC1;
bit_rw_t <io_, bitpos::B4> IC0E;
bit_rw_t <io_, bitpos::B5> IC1E;
bits_rw_t<io_, bitpos::B8, 2> OC0;
bits_rw_t<io_, bitpos::B10, 2> OC1;
bit_rw_t <io_, bitpos::B12> OC0E;
bit_rw_t <io_, bitpos::B13> OC1E;
bit_rw_t <io_, bitpos::B15> CMWE;
};
static inline cmwior_t<base + 0x08> CMWIOR;
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
/*!
@brief タイマカウンタ(CMWCNT)
*/
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
static inline rw32_t<base + 0x10> CMWCNT;
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
/*!
@brief コンペアマッチコンスタントレジスタ(CMWCOR)
*/
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
static inline rw32_t<base + 0x14> CMWCOR;
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
/*!
@brief インプットキャプチャレジスタ 0(CMWICR0)
*/
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
static inline rw32_t<base + 0x18> CMWICR0;
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
/*!
@brief インプットキャプチャレジスタ 1(CMWICR1)
*/
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
static inline rw32_t<base + 0x1C> CMWICR1;
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
/*!
@brief アウトプットコンペアレジスタ 0(CMWOCR0)
*/
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
static inline rw32_t<base + 0x20> CMWOCR0;
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
/*!
@brief アウトプットコンペアレジスタ 1(CMWOCR1)
*/
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
static inline rw32_t<base + 0x24> CMWOCR1;
};
#if defined (SIG_RX26T)
typedef cmtw_t<0x0009'4200, peripheral::CMTW0, ICU::VECTOR::CMWI0, ICU::VECTOR,
ICU::VECTOR::IC0I0, ICU::VECTOR::IC1I0, ICU::VECTOR::OC0I0, ICU::VECTOR::OC1I0> CMTW0;
typedef cmtw_t<0x0009'4280, peripheral::CMTW1, ICU::VECTOR::CMWI1, ICU::VECTOR,
ICU::VECTOR::IC0I1, ICU::VECTOR::IC1I1, ICU::VECTOR::OC0I1, ICU::VECTOR::OC1I1> CMTW1;
#else
typedef cmtw_t<0x0009'4200, peripheral::CMTW0, ICU::VECTOR::CMWI0, ICU::SELECTB,
ICU::SELECTB::IC0I0, ICU::SELECTB::IC1I0, ICU::SELECTB::OC0I0, ICU::SELECTB::OC1I0> CMTW0;
typedef cmtw_t<0x0009'4280, peripheral::CMTW1, ICU::VECTOR::CMWI1, ICU::SELECTB,
ICU::SELECTB::IC0I1, ICU::SELECTB::IC1I1, ICU::SELECTB::OC0I1, ICU::SELECTB::OC1I1> CMTW1;
#endif
}