diff options
Diffstat (limited to 'lib/chibios-contrib/ext/mcux-sdk/boards/lpcxpresso845max/clock_config.c')
-rw-r--r-- | lib/chibios-contrib/ext/mcux-sdk/boards/lpcxpresso845max/clock_config.c | 231 |
1 files changed, 231 insertions, 0 deletions
diff --git a/lib/chibios-contrib/ext/mcux-sdk/boards/lpcxpresso845max/clock_config.c b/lib/chibios-contrib/ext/mcux-sdk/boards/lpcxpresso845max/clock_config.c new file mode 100644 index 000000000..83d6e6d42 --- /dev/null +++ b/lib/chibios-contrib/ext/mcux-sdk/boards/lpcxpresso845max/clock_config.c | |||
@@ -0,0 +1,231 @@ | |||
1 | /* | ||
2 | * Copyright 2018,2019 NXP | ||
3 | * All rights reserved. | ||
4 | * | ||
5 | * | ||
6 | * SPDX-License-Identifier: BSD-3-Clause | ||
7 | */ | ||
8 | /* | ||
9 | * How to set up clock using clock driver functions: | ||
10 | * | ||
11 | * 1. Setup clock sources. | ||
12 | * | ||
13 | * 2. Set up all dividers. | ||
14 | * | ||
15 | * 3. Set up all selectors to provide selected clocks. | ||
16 | */ | ||
17 | |||
18 | /* TEXT BELOW IS USED AS SETTING FOR TOOLS ************************************* | ||
19 | !!GlobalInfo | ||
20 | product: Clocks v7.0 | ||
21 | processor: LPC845 | ||
22 | package_id: LPC845M301JBD64 | ||
23 | mcu_data: ksdk2_0 | ||
24 | processor_version: 0.7.1 | ||
25 | * BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR TOOLS **********/ | ||
26 | |||
27 | #include "fsl_power.h" | ||
28 | #include "fsl_clock.h" | ||
29 | #include "clock_config.h" | ||
30 | |||
31 | /******************************************************************************* | ||
32 | * Definitions | ||
33 | ******************************************************************************/ | ||
34 | |||
35 | /******************************************************************************* | ||
36 | * Variables | ||
37 | ******************************************************************************/ | ||
38 | /* System clock frequency. */ | ||
39 | extern uint32_t SystemCoreClock; | ||
40 | |||
41 | /******************************************************************************* | ||
42 | ************************ BOARD_InitBootClocks function ************************ | ||
43 | ******************************************************************************/ | ||
44 | void BOARD_InitBootClocks(void) | ||
45 | { | ||
46 | BOARD_BootClockFRO18M(); | ||
47 | } | ||
48 | |||
49 | /******************************************************************************* | ||
50 | ******************** Configuration BOARD_BootClockFRO18M ********************** | ||
51 | ******************************************************************************/ | ||
52 | /* TEXT BELOW IS USED AS SETTING FOR TOOLS ************************************* | ||
53 | !!Configuration | ||
54 | name: BOARD_BootClockFRO18M | ||
55 | called_from_default_init: true | ||
56 | outputs: | ||
57 | - {id: FROHF_clock.outFreq, value: 18 MHz} | ||
58 | - {id: LowPower_clock.outFreq, value: 10 kHz} | ||
59 | - {id: System_clock.outFreq, value: 18 MHz} | ||
60 | - {id: divto750k_clock.outFreq, value: 750 kHz} | ||
61 | settings: | ||
62 | - {id: SYSCON.ADCCLKSEL.sel, value: NO_CLOCK} | ||
63 | - {id: SYSCON.CLKOUTSEL.sel, value: NO_CLOCK} | ||
64 | - {id: SYSCON.FRG0CLKSEL.sel, value: NO_CLOCK} | ||
65 | - {id: SYSCON.FRG1CLKSEL.sel, value: NO_CLOCK} | ||
66 | - {id: SYSCON.FRO_DIRECT.sel, value: SYSCON.fro_osc} | ||
67 | - {id: SYSCON.SCTCLKSEL.sel, value: NO_CLOCK} | ||
68 | - {id: SYSCON_PDRUNCFG0_PDEN_PLL_CFG, value: Power_down} | ||
69 | sources: | ||
70 | - {id: SYSCON.fro_osc.outFreq, value: 18 MHz} | ||
71 | * BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR TOOLS **********/ | ||
72 | |||
73 | /******************************************************************************* | ||
74 | * Variables for BOARD_BootClockFRO18M configuration | ||
75 | ******************************************************************************/ | ||
76 | /******************************************************************************* | ||
77 | * Code for BOARD_BootClockFRO18M configuration | ||
78 | ******************************************************************************/ | ||
79 | void BOARD_BootClockFRO18M(void) | ||
80 | { | ||
81 | /*!< Set up the clock sources */ | ||
82 | /*!< Set up FRO */ | ||
83 | POWER_DisablePD(kPDRUNCFG_PD_FRO_OUT); /*!< Ensure FRO is on */ | ||
84 | POWER_DisablePD(kPDRUNCFG_PD_FRO); /*!< Ensure FRO is on */ | ||
85 | CLOCK_SetFroOscFreq(kCLOCK_FroOscOut18M); /*!< Set up FRO freq */ | ||
86 | CLOCK_SetFroOutClkSrc(kCLOCK_FroSrcFroOsc); /*!< Set FRO clock source */ | ||
87 | POWER_DisablePD(kPDRUNCFG_PD_SYSOSC); /*!< Ensure Main osc is on */ | ||
88 | CLOCK_Select(kEXT_Clk_From_SysOsc); /*!<select external clock source to sys_osc */ | ||
89 | CLOCK_SetMainClkSrc(kCLOCK_MainClkSrcFro); /*!< select fro for main clock */ | ||
90 | CLOCK_SetCoreSysClkDiv(1U); | ||
91 | /*!< Set SystemCoreClock variable. */ | ||
92 | SystemCoreClock = BOARD_BOOTCLOCKFRO18M_CORE_CLOCK; | ||
93 | } | ||
94 | |||
95 | /******************************************************************************* | ||
96 | ******************** Configuration BOARD_BootClockFRO24M ********************** | ||
97 | ******************************************************************************/ | ||
98 | /* TEXT BELOW IS USED AS SETTING FOR TOOLS ************************************* | ||
99 | !!Configuration | ||
100 | name: BOARD_BootClockFRO24M | ||
101 | outputs: | ||
102 | - {id: FROHF_clock.outFreq, value: 24 MHz} | ||
103 | - {id: LowPower_clock.outFreq, value: 10 kHz} | ||
104 | - {id: System_clock.outFreq, value: 24 MHz} | ||
105 | - {id: divto750k_clock.outFreq, value: 750 kHz} | ||
106 | settings: | ||
107 | - {id: SYSCON.ADCCLKSEL.sel, value: NO_CLOCK} | ||
108 | - {id: SYSCON.CLKOUTSEL.sel, value: NO_CLOCK} | ||
109 | - {id: SYSCON.FRG0CLKSEL.sel, value: NO_CLOCK} | ||
110 | - {id: SYSCON.FRG1CLKSEL.sel, value: NO_CLOCK} | ||
111 | - {id: SYSCON.FRO_DIRECT.sel, value: SYSCON.fro_osc} | ||
112 | - {id: SYSCON.SCTCLKSEL.sel, value: NO_CLOCK} | ||
113 | - {id: SYSCON_PDRUNCFG0_PDEN_PLL_CFG, value: Power_down} | ||
114 | sources: | ||
115 | - {id: SYSCON.fro_osc.outFreq, value: 24 MHz} | ||
116 | * BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR TOOLS **********/ | ||
117 | |||
118 | /******************************************************************************* | ||
119 | * Variables for BOARD_BootClockFRO24M configuration | ||
120 | ******************************************************************************/ | ||
121 | /******************************************************************************* | ||
122 | * Code for BOARD_BootClockFRO24M configuration | ||
123 | ******************************************************************************/ | ||
124 | void BOARD_BootClockFRO24M(void) | ||
125 | { | ||
126 | /*!< Set up the clock sources */ | ||
127 | /*!< Set up FRO */ | ||
128 | POWER_DisablePD(kPDRUNCFG_PD_FRO_OUT); /*!< Ensure FRO is on */ | ||
129 | POWER_DisablePD(kPDRUNCFG_PD_FRO); /*!< Ensure FRO is on */ | ||
130 | CLOCK_SetFroOscFreq(kCLOCK_FroOscOut24M); /*!< Set up FRO freq */ | ||
131 | CLOCK_SetFroOutClkSrc(kCLOCK_FroSrcFroOsc); /*!< Set FRO clock source */ | ||
132 | POWER_DisablePD(kPDRUNCFG_PD_SYSOSC); /*!< Ensure Main osc is on */ | ||
133 | CLOCK_Select(kEXT_Clk_From_SysOsc); /*!<select external clock source to sys_osc */ | ||
134 | CLOCK_SetMainClkSrc(kCLOCK_MainClkSrcFro); /*!< select fro for main clock */ | ||
135 | CLOCK_SetCoreSysClkDiv(1U); | ||
136 | /*!< Set SystemCoreClock variable. */ | ||
137 | SystemCoreClock = BOARD_BOOTCLOCKFRO24M_CORE_CLOCK; | ||
138 | } | ||
139 | |||
140 | /******************************************************************************* | ||
141 | ******************** Configuration BOARD_BootClockFRO30M ********************** | ||
142 | ******************************************************************************/ | ||
143 | /* TEXT BELOW IS USED AS SETTING FOR TOOLS ************************************* | ||
144 | !!Configuration | ||
145 | name: BOARD_BootClockFRO30M | ||
146 | outputs: | ||
147 | - {id: FROHF_clock.outFreq, value: 30 MHz} | ||
148 | - {id: LowPower_clock.outFreq, value: 10 kHz} | ||
149 | - {id: System_clock.outFreq, value: 30 MHz} | ||
150 | - {id: divto750k_clock.outFreq, value: 750 kHz} | ||
151 | settings: | ||
152 | - {id: SYSCON.ADCCLKSEL.sel, value: NO_CLOCK} | ||
153 | - {id: SYSCON.CLKOUTSEL.sel, value: NO_CLOCK} | ||
154 | - {id: SYSCON.FRG0CLKSEL.sel, value: NO_CLOCK} | ||
155 | - {id: SYSCON.FRG1CLKSEL.sel, value: NO_CLOCK} | ||
156 | - {id: SYSCON.FRO_DIRECT.sel, value: SYSCON.fro_osc} | ||
157 | - {id: SYSCON.SCTCLKSEL.sel, value: NO_CLOCK} | ||
158 | - {id: SYSCON_PDRUNCFG0_PDEN_PLL_CFG, value: Power_down} | ||
159 | * BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR TOOLS **********/ | ||
160 | |||
161 | /******************************************************************************* | ||
162 | * Variables for BOARD_BootClockFRO30M configuration | ||
163 | ******************************************************************************/ | ||
164 | /******************************************************************************* | ||
165 | * Code for BOARD_BootClockFRO30M configuration | ||
166 | ******************************************************************************/ | ||
167 | void BOARD_BootClockFRO30M(void) | ||
168 | { | ||
169 | /*!< Set up the clock sources */ | ||
170 | /*!< Set up FRO */ | ||
171 | POWER_DisablePD(kPDRUNCFG_PD_FRO_OUT); /*!< Ensure FRO is on */ | ||
172 | POWER_DisablePD(kPDRUNCFG_PD_FRO); /*!< Ensure FRO is on */ | ||
173 | CLOCK_SetFroOscFreq(kCLOCK_FroOscOut30M); /*!< Set up FRO freq */ | ||
174 | CLOCK_SetFroOutClkSrc(kCLOCK_FroSrcFroOsc); /*!< Set FRO clock source */ | ||
175 | POWER_DisablePD(kPDRUNCFG_PD_SYSOSC); /*!< Ensure Main osc is on */ | ||
176 | CLOCK_Select(kEXT_Clk_From_SysOsc); /*!<select external clock source to sys_osc */ | ||
177 | CLOCK_SetMainClkSrc(kCLOCK_MainClkSrcFro); /*!< select fro for main clock */ | ||
178 | CLOCK_SetCoreSysClkDiv(1U); | ||
179 | /*!< Set SystemCoreClock variable. */ | ||
180 | SystemCoreClock = BOARD_BOOTCLOCKFRO30M_CORE_CLOCK; | ||
181 | } | ||
182 | |||
183 | /******************************************************************************* | ||
184 | ******************** Configuration BOARD_BootClockPll24M ********************** | ||
185 | ******************************************************************************/ | ||
186 | /* TEXT BELOW IS USED AS SETTING FOR TOOLS ************************************* | ||
187 | !!Configuration | ||
188 | name: BOARD_BootClockPll24M | ||
189 | outputs: | ||
190 | - {id: FROHF_clock.outFreq, value: 24 MHz} | ||
191 | - {id: LowPower_clock.outFreq, value: 10 kHz} | ||
192 | - {id: SYSPLL_clock.outFreq, value: 24 MHz} | ||
193 | - {id: System_clock.outFreq, value: 24 MHz} | ||
194 | - {id: divto750k_clock.outFreq, value: 750 kHz} | ||
195 | settings: | ||
196 | - {id: SYSCON.ADCCLKSEL.sel, value: NO_CLOCK} | ||
197 | - {id: SYSCON.CLKOUTSEL.sel, value: NO_CLOCK} | ||
198 | - {id: SYSCON.FRG0CLKSEL.sel, value: NO_CLOCK} | ||
199 | - {id: SYSCON.FRG1CLKSEL.sel, value: NO_CLOCK} | ||
200 | - {id: SYSCON.FRO_DIRECT.sel, value: SYSCON.fro_osc} | ||
201 | - {id: SYSCON.MAINCLKPLLSEL.sel, value: SYSCON.PLL} | ||
202 | - {id: SYSCON.SCTCLKSEL.sel, value: NO_CLOCK} | ||
203 | sources: | ||
204 | - {id: SYSCON.fro_osc.outFreq, value: 24 MHz} | ||
205 | * BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR TOOLS **********/ | ||
206 | |||
207 | /******************************************************************************* | ||
208 | * Variables for BOARD_BootClockPll24M configuration | ||
209 | ******************************************************************************/ | ||
210 | /******************************************************************************* | ||
211 | * Code for BOARD_BootClockPll24M configuration | ||
212 | ******************************************************************************/ | ||
213 | void BOARD_BootClockPll24M(void) | ||
214 | { | ||
215 | /*!< Set up the clock sources */ | ||
216 | /*!< Set up FRO */ | ||
217 | POWER_DisablePD(kPDRUNCFG_PD_FRO_OUT); /*!< Ensure FRO is on */ | ||
218 | POWER_DisablePD(kPDRUNCFG_PD_FRO); /*!< Ensure FRO is on */ | ||
219 | CLOCK_SetFroOscFreq(kCLOCK_FroOscOut24M); /*!< Set up FRO freq */ | ||
220 | CLOCK_SetFroOutClkSrc(kCLOCK_FroSrcFroOsc); /*!< Set FRO clock source */ | ||
221 | POWER_DisablePD(kPDRUNCFG_PD_SYSOSC); /*!< Ensure Main osc is on */ | ||
222 | CLOCK_Select(kEXT_Clk_From_SysOsc); /*!<select external clock source to sys_osc */ | ||
223 | clock_sys_pll_t config; | ||
224 | config.src = kCLOCK_SysPllSrcFRO; /*!< select FRO for SYSPLL */ | ||
225 | config.targetFreq = 24000000U; /*!< set pll target freq */ | ||
226 | CLOCK_InitSystemPll(&config); /*!< set parameters */ | ||
227 | CLOCK_SetMainClkSrc(kCLOCK_MainClkSrcSysPll); /*!< select syspll for main clock */ | ||
228 | CLOCK_SetCoreSysClkDiv(1U); | ||
229 | /*!< Set SystemCoreClock variable. */ | ||
230 | SystemCoreClock = BOARD_BOOTCLOCKPLL24M_CORE_CLOCK; | ||
231 | } | ||