aboutsummaryrefslogtreecommitdiff
path: root/lib/chibios-contrib/ext/mcux-sdk/boards/lpcxpresso54114/project_template/clock_config.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/chibios-contrib/ext/mcux-sdk/boards/lpcxpresso54114/project_template/clock_config.c')
-rw-r--r--lib/chibios-contrib/ext/mcux-sdk/boards/lpcxpresso54114/project_template/clock_config.c192
1 files changed, 192 insertions, 0 deletions
diff --git a/lib/chibios-contrib/ext/mcux-sdk/boards/lpcxpresso54114/project_template/clock_config.c b/lib/chibios-contrib/ext/mcux-sdk/boards/lpcxpresso54114/project_template/clock_config.c
new file mode 100644
index 000000000..d8bccd22b
--- /dev/null
+++ b/lib/chibios-contrib/ext/mcux-sdk/boards/lpcxpresso54114/project_template/clock_config.c
@@ -0,0 +1,192 @@
1/*
2 * Copyright 2018 NXP.
3 * All rights reserved.
4 *
5 * SPDX-License-Identifier: BSD-3-Clause
6 */
7
8/***********************************************************************************************************************
9 * This file was generated by the MCUXpresso Config Tools. Any manual edits made to this file
10 * will be overwritten if the respective MCUXpresso Config Tools is used to update this file.
11 **********************************************************************************************************************/
12/*
13 * How to set up clock using clock driver functions:
14 *
15 * 1. Setup clock sources.
16 *
17 * 2. Setup voltage for the fastest of the clock outputs
18 *
19 * 3. Set up wait states of the flash.
20 *
21 * 4. Set up all dividers.
22 *
23 * 5. Set up all selectors to provide selected clocks.
24 */
25
26/* clang-format off */
27/* TEXT BELOW IS USED AS SETTING FOR TOOLS *************************************
28!!GlobalInfo
29product: Clocks v4.1
30processor: LPC54114J256
31package_id: LPC54114J256BD64
32mcu_data: ksdk2_0
33processor_version: 4.0.0
34board: LPCXpresso54114
35 * BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR TOOLS **********/
36/* clang-format on */
37
38#include "fsl_power.h"
39#include "fsl_clock.h"
40#include "clock_config.h"
41
42/*******************************************************************************
43 * Definitions
44 ******************************************************************************/
45
46/*******************************************************************************
47 * Variables
48 ******************************************************************************/
49/* System clock frequency. */
50extern uint32_t SystemCoreClock;
51
52/*******************************************************************************
53 ************************ BOARD_InitBootClocks function ************************
54 ******************************************************************************/
55void BOARD_InitBootClocks(void)
56{
57 BOARD_BootClockHSRUN();
58}
59
60/*******************************************************************************
61 ********************* Configuration BOARD_BootClockVLPR ***********************
62 ******************************************************************************/
63/* clang-format off */
64/* TEXT BELOW IS USED AS SETTING FOR TOOLS *************************************
65!!Configuration
66name: BOARD_BootClockVLPR
67outputs:
68- {id: System_clock.outFreq, value: 12 MHz}
69 * BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR TOOLS **********/
70/* clang-format on */
71
72/*******************************************************************************
73 * Variables for BOARD_BootClockVLPR configuration
74 ******************************************************************************/
75/*******************************************************************************
76 * Code for BOARD_BootClockVLPR configuration
77 ******************************************************************************/
78void BOARD_BootClockVLPR(void)
79{
80#ifndef SDK_SECONDARY_CORE
81 /*!< Set up the clock sources */
82 /*!< Set up FRO */
83 POWER_DisablePD(kPDRUNCFG_PD_FRO_EN); /*!< Ensure FRO is on */
84 CLOCK_SetupFROClocking(12000000U); /*!< Set up FRO to the 12 MHz, just for sure */
85 CLOCK_AttachClk(kFRO12M_to_MAIN_CLK); /*!< Switch to FRO 12MHz first to ensure we can change voltage without
86 accidentally being below the voltage for current speed */
87 POWER_SetVoltageForFreq(
88 12000000U); /*!< Set voltage for the one of the fastest clock outputs: System clock output */
89 CLOCK_SetFLASHAccessCyclesForFreq(12000000U); /*!< Set FLASH wait states for core */
90
91 /*!< Set up dividers */
92 CLOCK_SetClkDiv(kCLOCK_DivAhbClk, 1U, false); /*!< Set AHBCLKDIV divider to value 1 */
93
94 /*!< Set up clock selectors - Attach clocks to the peripheries */
95 CLOCK_AttachClk(kFRO12M_to_MAIN_CLK); /*!< Switch MAIN_CLK to FRO12M */
96 /*< Set SystemCoreClock variable. */
97 SystemCoreClock = BOARD_BOOTCLOCKVLPR_CORE_CLOCK;
98#endif
99}
100
101/*******************************************************************************
102 ********************** Configuration BOARD_BootClockRUN ***********************
103 ******************************************************************************/
104/* clang-format off */
105/* TEXT BELOW IS USED AS SETTING FOR TOOLS *************************************
106!!Configuration
107name: BOARD_BootClockRUN
108outputs:
109- {id: System_clock.outFreq, value: 48 MHz}
110settings:
111- {id: SYSCON.MAINCLKSELA.sel, value: SYSCON.fro_hf}
112 * BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR TOOLS **********/
113/* clang-format on */
114
115/*******************************************************************************
116 * Variables for BOARD_BootClockRUN configuration
117 ******************************************************************************/
118/*******************************************************************************
119 * Code for BOARD_BootClockRUN configuration
120 ******************************************************************************/
121void BOARD_BootClockRUN(void)
122{
123#ifndef SDK_SECONDARY_CORE
124 /*!< Set up the clock sources */
125 /*!< Set up FRO */
126 POWER_DisablePD(kPDRUNCFG_PD_FRO_EN); /*!< Ensure FRO is on */
127 CLOCK_SetupFROClocking(12000000U); /*!< Set up FRO to the 12 MHz, just for sure */
128 CLOCK_AttachClk(kFRO12M_to_MAIN_CLK); /*!< Switch to FRO 12MHz first to ensure we can change voltage without
129 accidentally being below the voltage for current speed */
130 POWER_SetVoltageForFreq(
131 48000000U); /*!< Set voltage for the one of the fastest clock outputs: System clock output */
132 CLOCK_SetFLASHAccessCyclesForFreq(48000000U); /*!< Set FLASH wait states for core */
133
134 CLOCK_SetupFROClocking(48000000U); /*!< Set up high frequency FRO output to selected frequency */
135
136 /*!< Set up dividers */
137 CLOCK_SetClkDiv(kCLOCK_DivAhbClk, 1U, false); /*!< Set AHBCLKDIV divider to value 1 */
138
139 /*!< Set up clock selectors - Attach clocks to the peripheries */
140 CLOCK_AttachClk(kFRO_HF_to_MAIN_CLK); /*!< Switch MAIN_CLK to FRO_HF */
141 /*< Set SystemCoreClock variable. */
142 SystemCoreClock = BOARD_BOOTCLOCKRUN_CORE_CLOCK;
143#endif
144}
145
146/*******************************************************************************
147 ********************* Configuration BOARD_BootClockHSRUN **********************
148 ******************************************************************************/
149/* clang-format off */
150/* TEXT BELOW IS USED AS SETTING FOR TOOLS *************************************
151!!Configuration
152name: BOARD_BootClockHSRUN
153called_from_default_init: true
154outputs:
155- {id: System_clock.outFreq, value: 96 MHz}
156settings:
157- {id: SYSCON.MAINCLKSELA.sel, value: SYSCON.fro_hf}
158sources:
159- {id: SYSCON.fro_hf.outFreq, value: 96 MHz}
160 * BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR TOOLS **********/
161/* clang-format on */
162
163/*******************************************************************************
164 * Variables for BOARD_BootClockHSRUN configuration
165 ******************************************************************************/
166/*******************************************************************************
167 * Code for BOARD_BootClockHSRUN configuration
168 ******************************************************************************/
169void BOARD_BootClockHSRUN(void)
170{
171#ifndef SDK_SECONDARY_CORE
172 /*!< Set up the clock sources */
173 /*!< Set up FRO */
174 POWER_DisablePD(kPDRUNCFG_PD_FRO_EN); /*!< Ensure FRO is on */
175 CLOCK_SetupFROClocking(12000000U); /*!< Set up FRO to the 12 MHz, just for sure */
176 CLOCK_AttachClk(kFRO12M_to_MAIN_CLK); /*!< Switch to FRO 12MHz first to ensure we can change voltage without
177 accidentally being below the voltage for current speed */
178 POWER_SetVoltageForFreq(
179 96000000U); /*!< Set voltage for the one of the fastest clock outputs: System clock output */
180 CLOCK_SetFLASHAccessCyclesForFreq(96000000U); /*!< Set FLASH wait states for core */
181
182 CLOCK_SetupFROClocking(96000000U); /*!< Set up high frequency FRO output to selected frequency */
183
184 /*!< Set up dividers */
185 CLOCK_SetClkDiv(kCLOCK_DivAhbClk, 1U, false); /*!< Set AHBCLKDIV divider to value 1 */
186
187 /*!< Set up clock selectors - Attach clocks to the peripheries */
188 CLOCK_AttachClk(kFRO_HF_to_MAIN_CLK); /*!< Switch MAIN_CLK to FRO_HF */
189 /*< Set SystemCoreClock variable. */
190 SystemCoreClock = BOARD_BOOTCLOCKHSRUN_CORE_CLOCK;
191#endif
192}