-
-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathclock_profile.hpp
79 lines (69 loc) · 3.66 KB
/
clock_profile.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
#pragma once
#ifndef NO_CLOCK_PROFILE
//=========================================================================//
/*! @file
@brief RX220 グループ・クロック。プロファイル @n
クロックジェネレータで発生させる周波数の定義 @n
RX220 は PLL 回路が無いので、外部にクリスタルを接続する場合、 @n
最大 20MHz 動作となる。 @n
外部クロック入力でも最大は 20MHz となる。 @n
最大速度を出す場合は、HOCO を利用する事になる。
@author 平松邦仁 ([email protected])
@copyright Copyright (C) 2022, 2024 Kunihito Hiramatsu @n
Released under the MIT license @n
https://github.com/hirakuni45/RX/blob/master/LICENSE
*/
//=========================================================================//
#include <cstdint>
namespace device {
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
/*!
@brief クロック・プロファイル・クラス @n
・選択出来ない値を指定すると、コンパイルエラーとなる @n
・詳細はハードウェアーマニュアル参照の事
*/
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
class clock_profile {
public:
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
/*!
@brief 発信器タイプ @n
LOCO は、起動時のモードなので、設定する事はない。
*/
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
enum class OSC_TYPE : uint8_t {
XTAL, ///< クリスタル接続(1~20MHz)
CERA, ///< セラミック発振子リード品(16MHz ~ 20MHz)
EXT, ///< 外部クロック入力(最大 20MHz)
HOCO, ///< 内蔵高速オンチップオシレーター(BASE: 32MHz, 36.864MHz, 40MHz, 50MHz)
LOCO, ///< 内蔵低速オンチップオシレーター (125KHz)
};
#if 1
static constexpr auto OSCT = OSC_TYPE::HOCO; ///< オシレーターの選択
static constexpr bool TURN_SBC = false; ///< サブクロックを利用する場合「true」
#if 1
static constexpr uint32_t BASE = 32'000'000; ///< ベースクロック
static constexpr uint32_t ICLK = 32'000'000; ///< ICLK 周波数(最大32MHz)
static constexpr uint32_t PCLKB = 32'000'000; ///< PCLKB 周波数(最大32MHz)
static constexpr uint32_t PCLKD = 32'000'000; ///< PCLKD 周波数(最大32MHz)
static constexpr uint32_t FCLK = 32'000'000; ///< FCLK 周波数(最大4 ~ 32MHz)
#else
// オーバークロック
static constexpr uint32_t BASE = 50'000'000; ///< ベースクロック
static constexpr uint32_t ICLK = 50'000'000; ///< ICLK 周波数(最大32MHz)
static constexpr uint32_t PCLKB = 50'000'000; ///< PCLKB 周波数(最大32MHz)
static constexpr uint32_t PCLKD = 50'000'000; ///< PCLKD 周波数(最大32MHz)
static constexpr uint32_t FCLK = 25'000'000; ///< FCLK 周波数(最大4 ~ 32MHz)
#endif
#else
static constexpr auto OSCT = OSC_TYPE::XTAL; ///< オシレーターの選択
static constexpr uint32_t BASE = 20'000'000; ///< ベースクロック
static constexpr uint32_t ICLK = 20'000'000; ///< ICLK 周波数(最大32MHz)
static constexpr uint32_t PCLKB = 20'000'000; ///< PCLKB 周波数(最大32MHz)
static constexpr uint32_t PCLKD = 20'000'000; ///< PCLKD 周波数(最大32MHz)
static constexpr uint32_t FCLK = 20'000'000; ///< FCLK 周波数(最大4 ~ 32MHz)
#endif
static constexpr uint32_t DELAY_MS = (ICLK / 1'000'000 / 4) - 1; ///< ソフトウェアー遅延における定数(1マイクロ秒)
};
}
#endif