-
-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathrefclk.hpp
73 lines (66 loc) · 2.02 KB
/
refclk.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
#pragma once
//=====================================================================//
/*! @file
@brief リファレンス・クロック制御クラス @n
※「GLFW_SIM」を有効にする事で、各種動作をシュミレートする。
@author 平松邦仁 ([email protected])
@copyright Copyright (C) 2020 Kunihito Hiramatsu @n
Released under the MIT license @n
https://github.com/hirakuni45/RX/blob/master/LICENSE
*/
//=====================================================================//
// GLFW_SIM for simulate MTU conversion
#ifndef GLFW_SIM
#include "common/renesas.hpp"
#include "common/mtu_io.hpp"
#endif
namespace dsos {
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
/*!
@brief リファレンス・クロック・クラス
*/
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
class refclk {
#ifndef GLFW_SIM
#if defined(SIG_RX65N)
// CN13 (1): PD1_AN109_IRQ1 (MTIOC4B)
typedef device::MTU4 MTU;
static constexpr auto PSEL = device::port_map_mtu::ORDER::FIFTH;
#elif defined(SIG_RX72N)
// Pmod2 (8): PD1_RESET (MTIOC4B)
typedef device::MTU4 MTU;
static constexpr auto PSEL = device::port_map_mtu::ORDER::FIFTH;
#endif
typedef device::mtu_io<MTU, utils::null_task, utils::null_task, PSEL> MTU_IO;
#else
class MTU_IO {
public:
};
#endif
MTU_IO mtu_io_;
public:
//-----------------------------------------------------------------//
/*!
@brief コンストラクタ
*/
//-----------------------------------------------------------------//
refclk() noexcept : mtu_io_()
{ }
//-----------------------------------------------------------------//
/*!
@brief 開始(1KHz の出力)
@return 成功なら「true」
*/
//-----------------------------------------------------------------//
bool start() noexcept
{
#ifndef GLFW_SIM
uint32_t freq = 1'000;
auto ret = mtu_io_.start_normal(MTU::CHANNEL::B, freq, MTU_IO::OUTPUT::L_TOGGLE);
return ret;
#else
return true;
#endif
}
};
}