-
-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathda.hpp
113 lines (97 loc) · 3.26 KB
/
da.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
#pragma once
//=========================================================================//
/*! @file
@brief RX621/RX62N グループ・D/A 定義
@author 平松邦仁 (hira@rvf-rc45.net)
@copyright Copyright (C) 2022, 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 D/A コンバータ(DA)
@param[in] per ペリフェラル型
*/
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
template <peripheral per>
struct da_t {
static constexpr auto PERIPHERAL = per; ///< ペリフェラル型
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
/*!
@brief アナログ入出力型
*/
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
enum class ANALOG : uint8_t {
DA0,
DA1,
};
//-----------------------------------------------------------------//
/*!
@brief D/A ポートをアナログ出力に設定
@param[in] an アナログ型
@param[in] ena 不許可の場合は「false」
*/
//-----------------------------------------------------------------//
static void enable(ANALOG an, bool f = true) noexcept
{
switch(an) {
case ANALOG::DA0: // P03
break;
case ANALOG::DA1: // P05
break;
default:
break;
}
}
//-----------------------------------------------------------------//
/*!
@brief D/A データレジスタ 0(DADR0)
*/
//-----------------------------------------------------------------//
static inline rw16_t<0x0008'80C0> DADR0;
//-----------------------------------------------------------------//
/*!
@brief D/A データレジスタ 1(DADR1)
*/
//-----------------------------------------------------------------//
static inline rw16_t<0x0008'80C2> DADR1;
//-----------------------------------------------------------------//
/*!
@brief D/A 制御レジスタ(DACR)
@param[in] ofs オフセット
*/
//-----------------------------------------------------------------//
template <uint32_t ofs>
struct dacr_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::B5> DAE;
bit_rw_t<io_, bitpos::B6> DAOE0;
bit_rw_t<io_, bitpos::B7> DAOE1;
};
static inline dacr_t<0x0008'80C4> DACR;
//-----------------------------------------------------------------//
/*!
@brief DADR0 フォーマット選択レジスタ(DADPR)
@param[in] ofs オフセット
*/
//-----------------------------------------------------------------//
template <uint32_t ofs>
struct dadpr_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::B7> DPSEL;
};
static inline dadpr_t<0x0008'80C5> DADPR;
};
typedef da_t<peripheral::DA> DA;
}