diff options
Diffstat (limited to 'lib/chibios-contrib/ext/mcux-sdk/boards/frdmk32l3a6/clock_config.c')
-rw-r--r-- | lib/chibios-contrib/ext/mcux-sdk/boards/frdmk32l3a6/clock_config.c | 419 |
1 files changed, 419 insertions, 0 deletions
diff --git a/lib/chibios-contrib/ext/mcux-sdk/boards/frdmk32l3a6/clock_config.c b/lib/chibios-contrib/ext/mcux-sdk/boards/frdmk32l3a6/clock_config.c new file mode 100644 index 000000000..261f9b31c --- /dev/null +++ b/lib/chibios-contrib/ext/mcux-sdk/boards/frdmk32l3a6/clock_config.c | |||
@@ -0,0 +1,419 @@ | |||
1 | /* | ||
2 | * Copyright 2020 NXP | ||
3 | * All rights reserved. | ||
4 | * | ||
5 | * SPDX-License-Identifier: BSD-3-Clause | ||
6 | */ | ||
7 | /*********************************************************************************************************************** | ||
8 | * This file was generated by the MCUXpresso Config Tools. Any manual edits made to this file | ||
9 | * will be overwritten if the respective MCUXpresso Config Tools is used to update this file. | ||
10 | **********************************************************************************************************************/ | ||
11 | /* | ||
12 | * How to setup clock using clock driver functions: | ||
13 | * | ||
14 | * 1. Call CLOCK_InitXXX() to configure corresponding SCG clock source. | ||
15 | * Note: The clock could not be set when it is being used as system clock. | ||
16 | * In default out of reset, the CPU is clocked from FIRC(IRC48M), | ||
17 | * so before setting FIRC, change to use another avaliable clock source. | ||
18 | * | ||
19 | * 2. Call CLOCK_SetXtal0Freq() to set XTAL0 frequency based on board settings. | ||
20 | * | ||
21 | * 3. Call CLOCK_SetXxxModeSysClkConfig() to set SCG mode for Xxx run mode. | ||
22 | * Wait until the system clock source is changed to target source. | ||
23 | * | ||
24 | * 4. If power mode change is needed, call SMC_SetPowerModeProtection() to allow | ||
25 | * corresponding power mode and SMC_SetPowerModeXxx() to change to Xxx mode. | ||
26 | * Supported run mode and clock restrictions could be found in Reference Manual. | ||
27 | */ | ||
28 | |||
29 | /* clang-format off */ | ||
30 | /* TEXT BELOW IS USED AS SETTING FOR TOOLS ************************************* | ||
31 | !!GlobalInfo | ||
32 | product: Clocks v7.0 | ||
33 | processor: K32L3A60xxx | ||
34 | package_id: K32L3A60VPJ1A | ||
35 | mcu_data: ksdk2_0 | ||
36 | processor_version: 0.8.5 | ||
37 | board: FRDM-K32L3A6 | ||
38 | * BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR TOOLS **********/ | ||
39 | /* clang-format on */ | ||
40 | |||
41 | #include "fsl_msmc.h" | ||
42 | #include "clock_config.h" | ||
43 | |||
44 | /******************************************************************************* | ||
45 | * Definitions | ||
46 | ******************************************************************************/ | ||
47 | #define SCG_LPFLL_DISABLE 0U /*!< LPFLL clock disabled */ | ||
48 | |||
49 | /******************************************************************************* | ||
50 | * Variables | ||
51 | ******************************************************************************/ | ||
52 | /* System clock frequency. */ | ||
53 | extern uint32_t SystemCoreClock; | ||
54 | |||
55 | /******************************************************************************* | ||
56 | * Code | ||
57 | ******************************************************************************/ | ||
58 | #ifndef SDK_SECONDARY_CORE | ||
59 | /*FUNCTION********************************************************************** | ||
60 | * | ||
61 | * Function Name : CLOCK_CONFIG_FircSafeConfig | ||
62 | * Description : This function is used to safely configure FIRC clock. | ||
63 | * In default out of reset, the CPU is clocked from FIRC(IRC48M). | ||
64 | * Before setting FIRC, change to use SIRC as system clock, | ||
65 | * then configure FIRC. | ||
66 | * Param fircConfig : FIRC configuration. | ||
67 | * | ||
68 | *END**************************************************************************/ | ||
69 | static void CLOCK_CONFIG_FircSafeConfig(const scg_firc_config_t *fircConfig) | ||
70 | { | ||
71 | scg_sys_clk_config_t curConfig; | ||
72 | const scg_sirc_config_t scgSircConfig = {.enableMode = kSCG_SircEnable, | ||
73 | .div1 = kSCG_AsyncClkDisable, | ||
74 | .div2 = kSCG_AsyncClkDivBy2, | ||
75 | .range = kSCG_SircRangeHigh}; | ||
76 | scg_sys_clk_config_t sysClkSafeConfigSource = { | ||
77 | .divSlow = kSCG_SysClkDivBy4, /* Slow clock divider. */ | ||
78 | .divCore = kSCG_SysClkDivBy1, /* Core clock divider. */ | ||
79 | .src = kSCG_SysClkSrcSirc /* System clock source. */ | ||
80 | }; | ||
81 | /* Init Sirc */ | ||
82 | CLOCK_InitSirc(&scgSircConfig); | ||
83 | /* Change to use SIRC as system clock source to prepare to change FIRCCFG register */ | ||
84 | CLOCK_SetRunModeSysClkConfig(&sysClkSafeConfigSource); | ||
85 | /* Wait for clock source switch finished */ | ||
86 | do | ||
87 | { | ||
88 | CLOCK_GetCurSysClkConfig(&curConfig); | ||
89 | } while (curConfig.src != sysClkSafeConfigSource.src); | ||
90 | |||
91 | /* Init Firc */ | ||
92 | CLOCK_InitFirc(fircConfig); | ||
93 | } | ||
94 | #endif | ||
95 | |||
96 | /******************************************************************************* | ||
97 | ************************ BOARD_InitBootClocks function ************************ | ||
98 | ******************************************************************************/ | ||
99 | void BOARD_InitBootClocks(void) | ||
100 | { | ||
101 | BOARD_BootClockRUN(); | ||
102 | } | ||
103 | |||
104 | /******************************************************************************* | ||
105 | ********************** Configuration BOARD_BootClockRUN *********************** | ||
106 | ******************************************************************************/ | ||
107 | /* clang-format off */ | ||
108 | /* TEXT BELOW IS USED AS SETTING FOR TOOLS ************************************* | ||
109 | !!Configuration | ||
110 | name: BOARD_BootClockRUN | ||
111 | called_from_default_init: true | ||
112 | outputs: | ||
113 | - {id: Bus_clock.outFreq, value: 48 MHz} | ||
114 | - {id: Core_clock.outFreq, value: 48 MHz} | ||
115 | - {id: FIRCDIV1_CLK.outFreq, value: 48 MHz} | ||
116 | - {id: FIRCDIV2_CLK.outFreq, value: 48 MHz} | ||
117 | - {id: FIRCDIV3_CLK.outFreq, value: 48 MHz} | ||
118 | - {id: LPO_CLK.outFreq, value: 1 kHz} | ||
119 | - {id: Platform_clock.outFreq, value: 48 MHz} | ||
120 | - {id: SIRCDIV3_CLK.outFreq, value: 8 MHz} | ||
121 | - {id: Slow_clock.outFreq, value: 24 MHz} | ||
122 | - {id: System_clock.outFreq, value: 48 MHz} | ||
123 | settings: | ||
124 | - {id: SCG.FIRCDIV1.scale, value: '1', locked: true} | ||
125 | - {id: SCG.FIRCDIV2.scale, value: '1', locked: true} | ||
126 | - {id: SCG.FIRCDIV3.scale, value: '1', locked: true} | ||
127 | - {id: SCG.LPFLLDIV1.scale, value: '1', locked: true} | ||
128 | - {id: SCG.LPFLLDIV3.scale, value: '0', locked: true} | ||
129 | - {id: SCG.SIRCDIV1.scale, value: '0', locked: true} | ||
130 | - {id: SCG.SIRCDIV3.scale, value: '1', locked: true} | ||
131 | * BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR TOOLS **********/ | ||
132 | /* clang-format on */ | ||
133 | |||
134 | /******************************************************************************* | ||
135 | * Variables for BOARD_BootClockRUN configuration | ||
136 | ******************************************************************************/ | ||
137 | const scg_sys_clk_config_t g_sysClkConfig_BOARD_BootClockRUN = | ||
138 | { | ||
139 | .divSlow = kSCG_SysClkDivBy2, /* Slow Clock Divider: divided by 2 */ | ||
140 | .divBus = kSCG_SysClkDivBy1, /* Bus Clock Divider: divided by 1 */ | ||
141 | .divExt = kSCG_SysClkDivBy1, /* External Clock Divider: divided by 1 */ | ||
142 | .divCore = kSCG_SysClkDivBy1, /* Core Clock Divider: divided by 1 */ | ||
143 | .src = kSCG_SysClkSrcFirc, /* Fast IRC is selected as System Clock Source */ | ||
144 | }; | ||
145 | const scg_sirc_config_t g_scgSircConfig_BOARD_BootClockRUN = | ||
146 | { | ||
147 | .enableMode = kSCG_SircEnable | kSCG_SircEnableInLowPower,/* Enable SIRC clock, Enable SIRC in low power mode */ | ||
148 | .div1 = kSCG_AsyncClkDisable, /* Slow IRC Clock Divider 1: Clock output is disabled */ | ||
149 | .div2 = kSCG_AsyncClkDisable, /* Slow IRC Clock Divider 2: Clock output is disabled */ | ||
150 | .div3 = kSCG_AsyncClkDivBy1, /* Slow IRC Clock Divider 3: divided by 1 */ | ||
151 | .range = kSCG_SircRangeHigh, /* Slow IRC high range clock (8 MHz) */ | ||
152 | }; | ||
153 | const scg_firc_config_t g_scgFircConfig_BOARD_BootClockRUN = | ||
154 | { | ||
155 | .enableMode = kSCG_FircEnable, /* Enable FIRC clock */ | ||
156 | .div1 = kSCG_AsyncClkDivBy1, /* Fast IRC Clock Divider 1: divided by 1 */ | ||
157 | .div2 = kSCG_AsyncClkDivBy1, /* Fast IRC Clock Divider 2: divided by 1 */ | ||
158 | .div3 = kSCG_AsyncClkDivBy1, /* Fast IRC Clock Divider 3: divided by 1 */ | ||
159 | .range = kSCG_FircRange48M, /* Fast IRC is trimmed to 48MHz */ | ||
160 | .trimConfig = NULL, | ||
161 | }; | ||
162 | const scg_lpfll_config_t g_scgLpFllConfig_BOARD_BootClockRUN = | ||
163 | { | ||
164 | .enableMode = SCG_LPFLL_DISABLE, /* LPFLL clock disabled */ | ||
165 | .div1 = kSCG_AsyncClkDivBy1, /* Low Power FLL Clock Divider 1: divided by 1 */ | ||
166 | .div2 = kSCG_AsyncClkDisable, /* Low Power FLL Clock Divider 2: Clock output is disabled */ | ||
167 | .div3 = kSCG_AsyncClkDisable, /* Low Power FLL Clock Divider 3: Clock output is disabled */ | ||
168 | .range = kSCG_LpFllRange48M, /* LPFLL is trimmed to 48MHz */ | ||
169 | .trimConfig = NULL, | ||
170 | }; | ||
171 | /******************************************************************************* | ||
172 | * Code for BOARD_BootClockRUN configuration | ||
173 | ******************************************************************************/ | ||
174 | void BOARD_BootClockRUN(void) | ||
175 | { | ||
176 | #ifndef SDK_SECONDARY_CORE | ||
177 | scg_sys_clk_config_t curConfig; | ||
178 | |||
179 | /* Init FIRC */ | ||
180 | CLOCK_CONFIG_FircSafeConfig(&g_scgFircConfig_BOARD_BootClockRUN); | ||
181 | /* Set SCG to FIRC mode. */ | ||
182 | CLOCK_SetRunModeSysClkConfig(&g_sysClkConfig_BOARD_BootClockRUN); | ||
183 | /* Wait for clock source switch finished */ | ||
184 | do | ||
185 | { | ||
186 | CLOCK_GetCurSysClkConfig(&curConfig); | ||
187 | } while (curConfig.src != g_sysClkConfig_BOARD_BootClockRUN.src); | ||
188 | /* Init SIRC */ | ||
189 | CLOCK_InitSirc(&g_scgSircConfig_BOARD_BootClockRUN); | ||
190 | /* Init LPFLL */ | ||
191 | CLOCK_InitLpFll(&g_scgLpFllConfig_BOARD_BootClockRUN); | ||
192 | /* Set SystemCoreClock variable. */ | ||
193 | SystemCoreClock = BOARD_BOOTCLOCKRUN_CORE_CLOCK; | ||
194 | #endif | ||
195 | } | ||
196 | |||
197 | /******************************************************************************* | ||
198 | ********************* Configuration BOARD_BootClockHSRUN ********************** | ||
199 | ******************************************************************************/ | ||
200 | /* clang-format off */ | ||
201 | /* TEXT BELOW IS USED AS SETTING FOR TOOLS ************************************* | ||
202 | !!Configuration | ||
203 | name: BOARD_BootClockHSRUN | ||
204 | outputs: | ||
205 | - {id: Bus_clock.outFreq, value: 72 MHz} | ||
206 | - {id: Core_clock.outFreq, value: 72 MHz} | ||
207 | - {id: FIRCDIV1_CLK.outFreq, value: 48 MHz} | ||
208 | - {id: FIRCDIV2_CLK.outFreq, value: 48 MHz} | ||
209 | - {id: FIRCDIV3_CLK.outFreq, value: 48 MHz} | ||
210 | - {id: LPFLLDIV1_CLK.outFreq, value: 72 MHz} | ||
211 | - {id: LPO_CLK.outFreq, value: 1 kHz} | ||
212 | - {id: Platform_clock.outFreq, value: 72 MHz} | ||
213 | - {id: SIRCDIV3_CLK.outFreq, value: 8 MHz} | ||
214 | - {id: Slow_clock.outFreq, value: 8 MHz} | ||
215 | - {id: System_clock.outFreq, value: 72 MHz} | ||
216 | settings: | ||
217 | - {id: SCGMode, value: LPFLL} | ||
218 | - {id: powerMode, value: HSRUN} | ||
219 | - {id: SCG.DIVCORE.scale, value: '1', locked: true} | ||
220 | - {id: SCG.DIVSLOW.scale, value: '9'} | ||
221 | - {id: SCG.FIRCDIV1.scale, value: '1', locked: true} | ||
222 | - {id: SCG.FIRCDIV2.scale, value: '1', locked: true} | ||
223 | - {id: SCG.FIRCDIV3.scale, value: '1', locked: true} | ||
224 | - {id: SCG.LPFLLDIV1.scale, value: '1'} | ||
225 | - {id: SCG.LPFLL_mul.scale, value: '36', locked: true} | ||
226 | - {id: SCG.SCSSEL.sel, value: SCG.LPFLL} | ||
227 | - {id: SCG.SIRCDIV3.scale, value: '1', locked: true} | ||
228 | - {id: SCG.TRIMDIV.scale, value: '24'} | ||
229 | - {id: SCG.TRIMSRCSEL.sel, value: SCG.FIRC} | ||
230 | - {id: SCG_LPFLLCSR_LPFLLEN_CFG, value: Enabled} | ||
231 | * BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR TOOLS **********/ | ||
232 | /* clang-format on */ | ||
233 | |||
234 | /******************************************************************************* | ||
235 | * Variables for BOARD_BootClockHSRUN configuration | ||
236 | ******************************************************************************/ | ||
237 | const scg_sys_clk_config_t g_sysClkConfig_BOARD_BootClockHSRUN = | ||
238 | { | ||
239 | .divSlow = kSCG_SysClkDivBy9, /* Slow Clock Divider: divided by 9 */ | ||
240 | .divBus = kSCG_SysClkDivBy1, /* Bus Clock Divider: divided by 1 */ | ||
241 | .divExt = kSCG_SysClkDivBy1, /* External Clock Divider: divided by 1 */ | ||
242 | .divCore = kSCG_SysClkDivBy1, /* Core Clock Divider: divided by 1 */ | ||
243 | .src = kSCG_SysClkSrcLpFll, /* Low power FLL is selected as System Clock Source */ | ||
244 | }; | ||
245 | const scg_sirc_config_t g_scgSircConfig_BOARD_BootClockHSRUN = | ||
246 | { | ||
247 | .enableMode = kSCG_SircEnable | kSCG_SircEnableInLowPower,/* Enable SIRC clock, Enable SIRC in low power mode */ | ||
248 | .div1 = kSCG_AsyncClkDisable, /* Slow IRC Clock Divider 1: Clock output is disabled */ | ||
249 | .div2 = kSCG_AsyncClkDisable, /* Slow IRC Clock Divider 2: Clock output is disabled */ | ||
250 | .div3 = kSCG_AsyncClkDivBy1, /* Slow IRC Clock Divider 3: divided by 1 */ | ||
251 | .range = kSCG_SircRangeHigh, /* Slow IRC high range clock (8 MHz) */ | ||
252 | }; | ||
253 | const scg_firc_config_t g_scgFircConfig_BOARD_BootClockHSRUN = | ||
254 | { | ||
255 | .enableMode = kSCG_FircEnable, /* Enable FIRC clock */ | ||
256 | .div1 = kSCG_AsyncClkDivBy1, /* Fast IRC Clock Divider 1: divided by 1 */ | ||
257 | .div2 = kSCG_AsyncClkDivBy1, /* Fast IRC Clock Divider 2: divided by 1 */ | ||
258 | .div3 = kSCG_AsyncClkDivBy1, /* Fast IRC Clock Divider 3: divided by 1 */ | ||
259 | .range = kSCG_FircRange48M, /* Fast IRC is trimmed to 48MHz */ | ||
260 | .trimConfig = NULL, | ||
261 | }; | ||
262 | const scg_lpfll_config_t g_scgLpFllConfig_BOARD_BootClockHSRUN = | ||
263 | { | ||
264 | .enableMode = kSCG_LpFllEnable, /* Enable LPFLL clock */ | ||
265 | .div1 = kSCG_AsyncClkDivBy1, /* Low Power FLL Clock Divider 1: divided by 1 */ | ||
266 | .div2 = kSCG_AsyncClkDisable, /* Low Power FLL Clock Divider 2: Clock output is disabled */ | ||
267 | .div3 = kSCG_AsyncClkDisable, /* Low Power FLL Clock Divider 3: Clock output is disabled */ | ||
268 | .range = kSCG_LpFllRange72M, /* LPFLL is trimmed to 72MHz */ | ||
269 | .trimConfig = NULL, | ||
270 | }; | ||
271 | /******************************************************************************* | ||
272 | * Code for BOARD_BootClockHSRUN configuration | ||
273 | ******************************************************************************/ | ||
274 | void BOARD_BootClockHSRUN(void) | ||
275 | { | ||
276 | #ifndef SDK_SECONDARY_CORE | ||
277 | scg_sys_clk_config_t curConfig; | ||
278 | |||
279 | /* Init FIRC */ | ||
280 | CLOCK_CONFIG_FircSafeConfig(&g_scgFircConfig_BOARD_BootClockHSRUN); | ||
281 | /* Init LPFLL */ | ||
282 | CLOCK_InitLpFll(&g_scgLpFllConfig_BOARD_BootClockHSRUN); | ||
283 | #if defined(SDK_CORE_ID_CM4) | ||
284 | /* Set HSRUN power mode */ | ||
285 | SMC_SetPowerModeProtection(SMC0, kSMC_AllowPowerModeAll); | ||
286 | SMC_SetPowerModeHsrun(SMC0); | ||
287 | while (SMC_GetPowerModeState(SMC0) != kSMC_PowerStateHsrun) | ||
288 | { | ||
289 | } | ||
290 | #elif defined(SDK_CORE_ID_CM0PLUS) | ||
291 | SMC_SetPowerModeProtection(SMC1, kSMC_AllowPowerModeAll); | ||
292 | SMC_SetPowerModeHsrun(SMC1); | ||
293 | while (SMC_GetPowerModeState(SMC1) != kSMC_PowerStateHsrun) | ||
294 | { | ||
295 | } | ||
296 | #endif | ||
297 | /* Set SCG to LPFLL mode. */ | ||
298 | CLOCK_SetHsrunModeSysClkConfig(&g_sysClkConfig_BOARD_BootClockHSRUN); | ||
299 | /* Wait for clock source switch finished */ | ||
300 | do | ||
301 | { | ||
302 | CLOCK_GetCurSysClkConfig(&curConfig); | ||
303 | } while (curConfig.src != g_sysClkConfig_BOARD_BootClockHSRUN.src); | ||
304 | /* Init SIRC */ | ||
305 | CLOCK_InitSirc(&g_scgSircConfig_BOARD_BootClockHSRUN); | ||
306 | /* Set SystemCoreClock variable. */ | ||
307 | SystemCoreClock = BOARD_BOOTCLOCKHSRUN_CORE_CLOCK; | ||
308 | #endif | ||
309 | } | ||
310 | |||
311 | /******************************************************************************* | ||
312 | ********************* Configuration BOARD_BootClockVLPR *********************** | ||
313 | ******************************************************************************/ | ||
314 | /* clang-format off */ | ||
315 | /* TEXT BELOW IS USED AS SETTING FOR TOOLS ************************************* | ||
316 | !!Configuration | ||
317 | name: BOARD_BootClockVLPR | ||
318 | outputs: | ||
319 | - {id: Bus_clock.outFreq, value: 2 MHz} | ||
320 | - {id: Core_clock.outFreq, value: 4 MHz} | ||
321 | - {id: LPO_CLK.outFreq, value: 1 kHz} | ||
322 | - {id: Platform_clock.outFreq, value: 4 MHz} | ||
323 | - {id: SIRCDIV1_CLK.outFreq, value: 8 MHz} | ||
324 | - {id: SIRCDIV2_CLK.outFreq, value: 8 MHz} | ||
325 | - {id: SIRCDIV3_CLK.outFreq, value: 8 MHz} | ||
326 | - {id: Slow_clock.outFreq, value: 4000/9 kHz} | ||
327 | - {id: System_clock.outFreq, value: 4 MHz} | ||
328 | settings: | ||
329 | - {id: SCGMode, value: SIRC} | ||
330 | - {id: powerMode, value: VLPR} | ||
331 | - {id: SCG.DIVBUS.scale, value: '2', locked: true} | ||
332 | - {id: SCG.DIVCORE.scale, value: '2', locked: true} | ||
333 | - {id: SCG.DIVSLOW.scale, value: '9'} | ||
334 | - {id: SCG.FIRCDIV1.scale, value: '1'} | ||
335 | - {id: SCG.SCSSEL.sel, value: SCG.SIRC} | ||
336 | - {id: SCG.SIRCDIV1.scale, value: '1', locked: true} | ||
337 | - {id: SCG.SIRCDIV2.scale, value: '1', locked: true} | ||
338 | - {id: SCG.SIRCDIV3.scale, value: '1', locked: true} | ||
339 | * BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR TOOLS **********/ | ||
340 | /* clang-format on */ | ||
341 | |||
342 | /******************************************************************************* | ||
343 | * Variables for BOARD_BootClockVLPR configuration | ||
344 | ******************************************************************************/ | ||
345 | const scg_sys_clk_config_t g_sysClkConfig_BOARD_BootClockVLPR = | ||
346 | { | ||
347 | .divSlow = kSCG_SysClkDivBy9, /* Slow Clock Divider: divided by 9 */ | ||
348 | .divBus = kSCG_SysClkDivBy2, /* Bus Clock Divider: divided by 2 */ | ||
349 | .divExt = kSCG_SysClkDivBy1, /* External Clock Divider: divided by 1 */ | ||
350 | .divCore = kSCG_SysClkDivBy2, /* Core Clock Divider: divided by 2 */ | ||
351 | .src = kSCG_SysClkSrcSirc, /* Slow IRC is selected as System Clock Source */ | ||
352 | }; | ||
353 | const scg_sirc_config_t g_scgSircConfig_BOARD_BootClockVLPR = | ||
354 | { | ||
355 | .enableMode = kSCG_SircEnable | kSCG_SircEnableInLowPower,/* Enable SIRC clock, Enable SIRC in low power mode */ | ||
356 | .div1 = kSCG_AsyncClkDivBy1, /* Slow IRC Clock Divider 1: divided by 1 */ | ||
357 | .div2 = kSCG_AsyncClkDivBy1, /* Slow IRC Clock Divider 2: divided by 1 */ | ||
358 | .div3 = kSCG_AsyncClkDivBy1, /* Slow IRC Clock Divider 3: divided by 1 */ | ||
359 | .range = kSCG_SircRangeHigh, /* Slow IRC high range clock (8 MHz) */ | ||
360 | }; | ||
361 | const scg_firc_config_t g_scgFircConfig_BOARD_BootClockVLPR = | ||
362 | { | ||
363 | .enableMode = kSCG_FircEnable, /* Enable FIRC clock */ | ||
364 | .div1 = kSCG_AsyncClkDivBy1, /* Fast IRC Clock Divider 1: divided by 1 */ | ||
365 | .div2 = kSCG_AsyncClkDisable, /* Fast IRC Clock Divider 2: Clock output is disabled */ | ||
366 | .div3 = kSCG_AsyncClkDisable, /* Fast IRC Clock Divider 3: Clock output is disabled */ | ||
367 | .range = kSCG_FircRange48M, /* Fast IRC is trimmed to 48MHz */ | ||
368 | .trimConfig = NULL, | ||
369 | }; | ||
370 | const scg_lpfll_config_t g_scgLpFllConfig_BOARD_BootClockVLPR = | ||
371 | { | ||
372 | .enableMode = SCG_LPFLL_DISABLE, /* LPFLL clock disabled */ | ||
373 | .div1 = kSCG_AsyncClkDisable, /* Low Power FLL Clock Divider 1: Clock output is disabled */ | ||
374 | .div2 = kSCG_AsyncClkDisable, /* Low Power FLL Clock Divider 2: Clock output is disabled */ | ||
375 | .div3 = kSCG_AsyncClkDisable, /* Low Power FLL Clock Divider 3: Clock output is disabled */ | ||
376 | .range = kSCG_LpFllRange48M, /* LPFLL is trimmed to 48MHz */ | ||
377 | .trimConfig = NULL, | ||
378 | }; | ||
379 | /******************************************************************************* | ||
380 | * Code for BOARD_BootClockVLPR configuration | ||
381 | ******************************************************************************/ | ||
382 | void BOARD_BootClockVLPR(void) | ||
383 | { | ||
384 | #ifndef SDK_SECONDARY_CORE | ||
385 | scg_sys_clk_config_t curConfig; | ||
386 | |||
387 | /* Init SIRC */ | ||
388 | CLOCK_InitSirc(&g_scgSircConfig_BOARD_BootClockVLPR); | ||
389 | /* Set SCG to SIRC mode. */ | ||
390 | CLOCK_SetVlprModeSysClkConfig(&g_sysClkConfig_BOARD_BootClockVLPR); | ||
391 | /* Init FIRC */ | ||
392 | CLOCK_InitFirc(&g_scgFircConfig_BOARD_BootClockVLPR); | ||
393 | /* Init LPFLL */ | ||
394 | CLOCK_InitLpFll(&g_scgLpFllConfig_BOARD_BootClockVLPR); | ||
395 | #if defined(SDK_CORE_ID_CM4) | ||
396 | /* Set VLPR power mode. */ | ||
397 | SMC_SetPowerModeProtection(SMC0, kSMC_AllowPowerModeAll); | ||
398 | SMC_SetPowerModeVlpr(SMC0); | ||
399 | while (SMC_GetPowerModeState(SMC0) != kSMC_PowerStateVlpr) | ||
400 | { | ||
401 | } | ||
402 | #elif defined(SDK_CORE_ID_CM0PLUS) | ||
403 | /* Set VLPR power mode. */ | ||
404 | SMC_SetPowerModeProtection(SMC1, kSMC_AllowPowerModeAll); | ||
405 | SMC_SetPowerModeVlpr(SMC1); | ||
406 | while (SMC_GetPowerModeState(SMC1) != kSMC_PowerStateVlpr) | ||
407 | { | ||
408 | } | ||
409 | #endif | ||
410 | /* Wait for clock source switch finished */ | ||
411 | do | ||
412 | { | ||
413 | CLOCK_GetCurSysClkConfig(&curConfig); | ||
414 | } while (curConfig.src != g_sysClkConfig_BOARD_BootClockVLPR.src); | ||
415 | /* Set SystemCoreClock variable. */ | ||
416 | SystemCoreClock = BOARD_BOOTCLOCKVLPR_CORE_CLOCK; | ||
417 | #endif | ||
418 | } | ||
419 | |||