mFrame
載入中...
搜尋中...
無符合項目
mcxa153/src/mcxa153/chip/clock/Clock.h
1
7#ifndef MCXA153_008A1453_A242_4775_9606_2ED0FF5092CA
8#define MCXA153_008A1453_A242_4775_9606_2ED0FF5092CA
9
10/* ***************************************************************************************
11 * Include
12 */
13#include "mframe.h"
14
15//----------------------------------------------------------------------------------------
16#include "./../Status.h"
17#include "./../clock/AttachID.h"
18#include "./../clock/Div.h"
19#include "./../clock/FircTrimConfig.h"
20#include "./../clock/GateName.h"
21#include "./../clock/MonitorMode.h"
22#include "./../clock/Name.h"
23#include "./../clock/SelectName.h"
24#include "./../clock/SircTrimConfig.h"
25#include "./../clock/SircTrimMode.h"
26#include "./../clock/SircTrimSource.h"
27#include "./../mrcc/MRCC.h"
28#include "./../syscon/SYSCON.h"
29
30//----------------------------------------------------------------------------------------
31
32/* ***************************************************************************************
33 * Namespace
34 */
35namespace mcxa153::chip::clock {
36 class Clock;
37}
38
39/* ***************************************************************************************
40 * Class/Interface/Struct/Enum
41 */
42
69 /* *************************************************************************************
70 * Variable
71 */
72
73 /* *************************************************************************************
74 * Abstract Method
75 */
76
77 /* *************************************************************************************
78 * Construct Method
79 */
80 protected:
88 virtual ~Clock(void) override = default;
89
90 /* *************************************************************************************
91 * Operator Method
92 */
93
94 /* *************************************************************************************
95 * Override Method
96 */
97
98 /* *************************************************************************************
99 * Public Method
100 */
101
102 /* *************************************************************************************
103 * Protected Method
104 */
105
106 /* *************************************************************************************
107 * Private Method
108 */
109
110 /* *************************************************************************************
111 * Static Variable
112 */
113 public:
114 /* *************************************************************************************
115 * Static Method
116 */
117 public:
132 static inline constexpr uint32 ATTACH_REG_OFFSET(AttachID attachID) {
133 return (+attachID >> 16U);
134 }
135
151 static inline bool getClockStatus(GateName clk) {
152 uint32 reg_offset = mcxa153::chip::clock::getGateNameOffset(clk);
153 uint32 bit_shift = mcxa153::chip::clock::getGateNameShift(clk);
154 volatile uint32 *pClkCtrl = reinterpret_cast<volatile uint32 *>(
155 reinterpret_cast<uint32>(&(mcxa153::chip::mrcc::MRCC0.mrcc_glb_cc0_set)) +
156 reg_offset);
157
158 if (clk == GateName::NOT_AVAIL) return false;
159
160 if (reg_offset == REG_PWM0SUBCTL)
161 return (mcxa153::chip::mrcc::MRCC0.mrcc_glb_cc0_set &
163
164 else
165 return (*pClkCtrl & (1UL << bit_shift));
166 }
167
182 static inline void enableClock(GateName clk) {
183 uint32 reg_offset = mcxa153::chip::clock::getGateNameOffset(clk);
184 uint32 bit_shift = mcxa153::chip::clock::getGateNameShift(clk);
185 volatile uint32 *pClkCtrl = reinterpret_cast<volatile uint32 *>(
186 reinterpret_cast<uint32>(&(mcxa153::chip::mrcc::MRCC0.mrcc_glb_cc0_set)) +
187 reg_offset);
188
189 if (clk == GateName::NOT_AVAIL) { return; }
190
191 /* Unlock clock configuration */
192 mcxa153::chip::syscon::SYSCON0.clkunlock &=
194
195 if (reg_offset == REG_PWM0SUBCTL) {
196 mcxa153::chip::syscon::SYSCON0.pwm0subctl |= (1UL << bit_shift);
197 mcxa153::chip::mrcc::MRCC0.mrcc_glb_cc0_set =
199 } else {
200 *pClkCtrl = (1UL << bit_shift);
201 }
202
203 /* Freeze clock configuration */
204 mcxa153::chip::syscon::SYSCON0.clkunlock |=
206 }
207
223 static inline void disableClock(GateName clk) {
224 uint32 reg_offset = getGateNameOffset(clk);
225 uint32 bit_shift = getGateNameShift(clk);
226 volatile uint32 *pClkCtrl = reinterpret_cast<volatile uint32 *>(
227 reinterpret_cast<uint32>(&(mcxa153::chip::mrcc::MRCC0.mrcc_glb_cc0_clr)) +
228 reg_offset);
229
230 if (clk == GateName::NOT_AVAIL) { return; }
231
232 /* Unlock clock configuration */
233 mcxa153::chip::syscon::SYSCON0.clkunlock &=
235
236 if (reg_offset == REG_PWM0SUBCTL) {
237 mcxa153::chip::syscon::SYSCON0.pwm0subctl &= ~(1UL << bit_shift);
238
239 if (0U == (mcxa153::chip::syscon::SYSCON0.pwm0subctl & 0xFU)) {
240 mcxa153::chip::mrcc::MRCC0.mrcc_glb_cc0_clr =
242 }
243 } else {
244 *pClkCtrl = (1UL << bit_shift);
245 }
246
247 /* Freeze clock configuration */
248 mcxa153::chip::syscon::SYSCON0.clkunlock |=
250 }
251
264 static void attachClock(AttachID connection);
265
282
295 static void setClockSelect(SelectName sel_name, uint32 value);
296
309 static uint32 getClockSelect(SelectName sel_name);
310
326 static void setClockDiv(Div div_name, uint32 value);
327
341 static uint32 getClockDiv(Div div_name);
342
355 static void haltClockDiv(Div div_name);
356
373 static mcxa153::chip::Status setupFROHFClocking(unsigned int iFreq);
374
389
409 static mcxa153::chip::Status setupFRO16KClocking(uint8 clk_16k_enable_mask);
410
427
444
459 static uint32 getFreq(Name clockName);
460
472 static uint32 getCoreSysClkFreq(void);
473
483 static uint32 getI3CFClkFreq(void);
484
496 static uint32 getCTimerClkFreq(uint32 id);
497
502 static uint32 getLpi2cClkFreq(void);
503
508 static uint32 getLpspiClkFreq(uint32 id);
509
514 static uint32 getLpuartClkFreq(uint32 id);
515
520 static uint32 getLptmrClkFreq(void);
521
526 static uint32 getOstimerClkFreq(void);
527
532 static uint32 getAdcClkFreq(void);
533
538 static uint32 getCmpFClkFreq(uint32 id);
539
544 static uint32 getCmpRRClkFreq(uint32 id);
545
550 static uint32 getTraceClkFreq(void);
551
556 static uint32 getClkoutClkFreq(void);
557
562 static uint32 getSystickClkFreq(void);
563
568 static uint32 getWwdtClkFreq(void);
569
586
603
619
631 static bool enableUsbfsClock(void);
632};
633
634/* ***************************************************************************************
635 * End of file
636 */
637
638#endif /* MCXA153_008A1453_A242_4775_9606_2ED0FF5092CA */
MCXA153 微控制器時鐘管理系統
Definition mcxa153/src/mcxa153/chip/clock/Clock.h:68
static void disableClock(GateName clk)
停用指定 IP 的時鐘
Definition mcxa153/src/mcxa153/chip/clock/Clock.h:223
static mcxa153::chip::Status frohfTrimConfig(FircTrimConfig config)
設定 FROHF 微調參數
static bool enableUsbfsClock(void)
啟用 USB 全速時鐘
static mcxa153::chip::Status setupExtClocking(uint32 iFreq)
初始化外部振盪器時鐘到指定頻率
static uint32 getTraceClkFreq(void)
Return Frequency of Trace Clock.
static uint32 getCmpRRClkFreq(uint32 id)
Return Frequency of CMP Round Robin Clock.
static uint32 getLptmrClkFreq(void)
Return Frequency of LPTMR functional Clock.
static void enableClock(GateName clk)
啟用指定 IP 的時鐘
Definition mcxa153/src/mcxa153/chip/clock/Clock.h:182
static uint32 getAdcClkFreq(void)
Return Frequency of Adc Clock.
static uint32 getLpi2cClkFreq(void)
Return Frequency of LPI2C0 functional Clock.
static mcxa153::chip::Status setupFRO16KClocking(uint8 clk_16k_enable_mask)
初始化 FRO16K 時鐘
static uint32 getOstimerClkFreq(void)
Return Frequency of OSTIMER.
virtual ~Clock(void) override=default
虛擬解構函式
static uint32 getCoreSysClkFreq(void)
取得核心系統時鐘頻率
static uint32 getClkoutClkFreq(void)
Return Frequency of CLKOUT Clock.
static mcxa153::chip::Status setupFROHFClocking(unsigned int iFreq)
初始化高速內部參考時鐘 (FROHF) 到指定頻率
static void setSysOscMonitorMode(MonitorMode mode)
設定系統振盪器監控模式
static AttachID getClockAttachId(AttachID connection)
取得實際時鐘連接 ID
static uint32 getWwdtClkFreq(void)
Return Frequency of Systick Clock.
static mcxa153::chip::Status setupExtRefClocking(uint32 iFreq)
初始化外部參考時鐘到指定頻率
static uint32 getLpspiClkFreq(uint32 id)
Return Frequency of LPSPI functional Clock.
static uint32 getCTimerClkFreq(uint32 id)
取得 CTimer 功能時鐘頻率
static mcxa153::chip::Status setupFRO12MClocking(void)
初始化 FRO12M 時鐘
static uint32 getSystickClkFreq(void)
Return Frequency of Systick Clock.
static void haltClockDiv(Div div_name)
停止時鐘分頻器
static constexpr uint32 ATTACH_REG_OFFSET(AttachID attachID)
計算時鐘附加暫存器偏移量
Definition mcxa153/src/mcxa153/chip/clock/Clock.h:132
static void setClockSelect(SelectName sel_name, uint32 value)
設定時鐘選擇器值
static uint32 getClockDiv(Div div_name)
取得時鐘分頻器值
static mcxa153::chip::Status fro12MTrimConfig(SircTrimConfig config)
設定 FRO 12M 微調參數
static void setClockDiv(Div div_name, uint32 value)
設定外設時鐘分頻器
static bool getClockStatus(GateName clk)
取得指定時鐘閘的狀態
Definition mcxa153/src/mcxa153/chip/clock/Clock.h:151
static void attachClock(AttachID connection)
配置時鐘選擇多工器
static uint32 getFreq(Name clockName)
取得指定時鐘的頻率
static uint32 getLpuartClkFreq(uint32 id)
Return Frequency of LPUART functional Clock.
static uint32 getClockSelect(SelectName sel_name)
取得時鐘選擇器值
static uint32 getCmpFClkFreq(uint32 id)
Return Frequency of CMP Function Clock.
static uint32 getI3CFClkFreq(void)
取得 I3C FCLK 頻率
Definition NonInstantiable.h:29
時鐘源附加識別碼枚舉
Definition AttachID.h:33
AttachID
Definition AttachID.h:81
uint32 getGateNameOffset(const GateName _this)
獲取閘門名稱的偏移量
Definition GateName.h:32
SelectName
MCXA153 晶片的時鐘選擇枚舉 此枚舉定義了所有可用於各個外設的時鐘選擇
Definition SelectName.h:46
Name
MCXA153晶片時鐘來源列舉
Definition Name.h:46
GateName
時鐘門控命名列舉
Definition GateName.h:58
MonitorMode
系統振盪器監視器模式設定
Definition MonitorMode.h:44
uint32 getGateNameShift(const GateName _this)
獲取閘門名稱的位移值
Definition GateName.h:41
Div
MCXA153 時鐘分頻器位址枚舉
Definition Div.h:58
@ GLB_CC0_FLEXPWM0
MRCC_GLB_CC0 - FLEXPWM0.
Clock
Frequency Measurement Reset Control.
@ CLKUNLOCK_UNLOCK
CLKUNLOCK - UNLOCK.
Status
Definition Status.h:221
Definition FircTrimConfig.h:41
Definition SircTrimConfig.h:39
__O uint32 mrcc_glb_cc0_set
AHB 時脈控制設定暫存器 0 (偏移: 0x44,唯寫)
Definition mrcc/Register.h:102
__O uint32 mrcc_glb_cc0_clr
AHB 時脈控制清除暫存器 0 (偏移: 0x48,唯寫)
Definition mrcc/Register.h:109
__IO uint32 pwm0subctl
PWM0 Submodule Control Register (PWM0子模組控制寄存器)
Definition syscon/Register.h:524
__IO uint32 clkunlock
CLKUNLOCK[0x3FC] <RW>
Definition syscon/Register.h:285