aboutsummaryrefslogtreecommitdiff
path: root/lib/chibios-contrib/ext/mcux-sdk/boards/lpcxpresso802/project_template/clock_config.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/chibios-contrib/ext/mcux-sdk/boards/lpcxpresso802/project_template/clock_config.c')
-rw-r--r--lib/chibios-contrib/ext/mcux-sdk/boards/lpcxpresso802/project_template/clock_config.c170
1 files changed, 170 insertions, 0 deletions
diff --git a/lib/chibios-contrib/ext/mcux-sdk/boards/lpcxpresso802/project_template/clock_config.c b/lib/chibios-contrib/ext/mcux-sdk/boards/lpcxpresso802/project_template/clock_config.c
new file mode 100644
index 000000000..aa1af38b3
--- /dev/null
+++ b/lib/chibios-contrib/ext/mcux-sdk/boards/lpcxpresso802/project_template/clock_config.c
@@ -0,0 +1,170 @@
1/*
2 * Copyright 2018 NXP.
3 * All rights reserved.
4 *
5 * SPDX-License-Identifier: BSD-3-Clause
6 */
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
20product: Clocks v4.1
21processor: LPC802
22package_id: LPC802M001JDH20
23mcu_data: ksdk2_0
24processor_version: 4.0.1
25board: LPCXpresso802
26 * BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR TOOLS **********/
27
28#include "fsl_power.h"
29#include "fsl_clock.h"
30#include "clock_config.h"
31
32/*******************************************************************************
33 * Definitions
34 ******************************************************************************/
35
36/*******************************************************************************
37 * Variables
38 ******************************************************************************/
39/* System clock frequency. */
40extern uint32_t SystemCoreClock;
41
42/*******************************************************************************
43 ************************ BOARD_InitBootClocks function ************************
44 ******************************************************************************/
45void BOARD_InitBootClocks(void)
46{
47 BOARD_BootClockFRO18M();
48}
49
50/*******************************************************************************
51 ******************** Configuration BOARD_BootClockFRO18M **********************
52 ******************************************************************************/
53/* TEXT BELOW IS USED AS SETTING FOR TOOLS *************************************
54!!Configuration
55name: BOARD_BootClockFRO18M
56called_from_default_init: true
57outputs:
58- {id: FROHF_clock.outFreq, value: 18 MHz}
59- {id: System_clock.outFreq, value: 9 MHz}
60settings:
61- {id: SYSCON.CLKOUTSEL.sel, value: NO_CLOCK}
62- {id: SYSCON.FRG0CLKSEL.sel, value: NO_CLOCK}
63- {id: SYSCON.I2C0CLKSEL.sel, value: NO_CLOCK}
64- {id: SYSCON.SPI0CLKSEL.sel, value: NO_CLOCK}
65- {id: SYSCON.UART0CLKSEL.sel, value: NO_CLOCK}
66- {id: SYSCON.UART1CLKSEL.sel, value: NO_CLOCK}
67sources:
68- {id: SYSCON.fro_osc.outFreq, value: 18 MHz}
69 * BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR TOOLS **********/
70
71/*******************************************************************************
72 * Variables for BOARD_BootClockFRO18M configuration
73 ******************************************************************************/
74/*******************************************************************************
75 * Code for BOARD_BootClockFRO18M configuration
76 ******************************************************************************/
77void BOARD_BootClockFRO18M(void)
78{
79 /*!< Set up the clock sources */
80 /*!< Set up FRO */
81 POWER_DisablePD(kPDRUNCFG_PD_FRO_OUT); /*!< Ensure FRO is on */
82 POWER_DisablePD(kPDRUNCFG_PD_FRO); /*!< Ensure FRO is on */
83 CLOCK_SetFroOscFreq(kCLOCK_FroOscOut18M); /*!< Set up FRO freq */
84 POWER_DisablePD(kPDRUNCFG_PD_LPOSC); /*!< Ensure Main osc is on */
85 CLOCK_SetMainClkSrc(kCLOCK_MainClkSrcFro); /*!< select fro for main clock */
86 CLOCK_Select(kADC_Clk_From_Fro); /*!< select FRO for ADC */
87 CLOCK_SetCoreSysClkDiv(1U);
88 /*!< Set SystemCoreClock variable. */
89 SystemCoreClock = BOARD_BOOTCLOCKFRO18M_CORE_CLOCK;
90}
91
92/*******************************************************************************
93 ******************** Configuration BOARD_BootClockFRO24M **********************
94 ******************************************************************************/
95/* TEXT BELOW IS USED AS SETTING FOR TOOLS *************************************
96!!Configuration
97name: BOARD_BootClockFRO24M
98outputs:
99- {id: FROHF_clock.outFreq, value: 24 MHz}
100- {id: System_clock.outFreq, value: 12 MHz}
101settings:
102- {id: SYSCON.CLKOUTSEL.sel, value: NO_CLOCK}
103- {id: SYSCON.FRG0CLKSEL.sel, value: NO_CLOCK}
104- {id: SYSCON.I2C0CLKSEL.sel, value: NO_CLOCK}
105- {id: SYSCON.SPI0CLKSEL.sel, value: NO_CLOCK}
106- {id: SYSCON.UART0CLKSEL.sel, value: NO_CLOCK}
107- {id: SYSCON.UART1CLKSEL.sel, value: NO_CLOCK}
108sources:
109- {id: SYSCON.fro_osc.outFreq, value: 24 MHz}
110 * BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR TOOLS **********/
111
112/*******************************************************************************
113 * Variables for BOARD_BootClockFRO24M configuration
114 ******************************************************************************/
115/*******************************************************************************
116 * Code for BOARD_BootClockFRO24M configuration
117 ******************************************************************************/
118void BOARD_BootClockFRO24M(void)
119{
120 /*!< Set up the clock sources */
121 /*!< Set up FRO */
122 POWER_DisablePD(kPDRUNCFG_PD_FRO_OUT); /*!< Ensure FRO is on */
123 POWER_DisablePD(kPDRUNCFG_PD_FRO); /*!< Ensure FRO is on */
124 CLOCK_SetFroOscFreq(kCLOCK_FroOscOut24M); /*!< Set up FRO freq */
125 POWER_DisablePD(kPDRUNCFG_PD_LPOSC); /*!< Ensure Main osc is on */
126 CLOCK_SetMainClkSrc(kCLOCK_MainClkSrcFro); /*!< select fro for main clock */
127 CLOCK_Select(kADC_Clk_From_Fro); /*!< select FRO for ADC */
128 CLOCK_SetCoreSysClkDiv(1U);
129 /*!< Set SystemCoreClock variable. */
130 SystemCoreClock = BOARD_BOOTCLOCKFRO24M_CORE_CLOCK;
131}
132
133/*******************************************************************************
134 ******************** Configuration BOARD_BootClockFRO30M **********************
135 ******************************************************************************/
136/* TEXT BELOW IS USED AS SETTING FOR TOOLS *************************************
137!!Configuration
138name: BOARD_BootClockFRO30M
139outputs:
140- {id: FROHF_clock.outFreq, value: 30 MHz}
141- {id: System_clock.outFreq, value: 15 MHz}
142settings:
143- {id: SYSCON.CLKOUTSEL.sel, value: NO_CLOCK}
144- {id: SYSCON.FRG0CLKSEL.sel, value: NO_CLOCK}
145- {id: SYSCON.I2C0CLKSEL.sel, value: NO_CLOCK}
146- {id: SYSCON.SPI0CLKSEL.sel, value: NO_CLOCK}
147- {id: SYSCON.UART0CLKSEL.sel, value: NO_CLOCK}
148- {id: SYSCON.UART1CLKSEL.sel, value: NO_CLOCK}
149 * BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR TOOLS **********/
150
151/*******************************************************************************
152 * Variables for BOARD_BootClockFRO30M configuration
153 ******************************************************************************/
154/*******************************************************************************
155 * Code for BOARD_BootClockFRO30M configuration
156 ******************************************************************************/
157void BOARD_BootClockFRO30M(void)
158{
159 /*!< Set up the clock sources */
160 /*!< Set up FRO */
161 POWER_DisablePD(kPDRUNCFG_PD_FRO_OUT); /*!< Ensure FRO is on */
162 POWER_DisablePD(kPDRUNCFG_PD_FRO); /*!< Ensure FRO is on */
163 CLOCK_SetFroOscFreq(kCLOCK_FroOscOut30M); /*!< Set up FRO freq */
164 POWER_DisablePD(kPDRUNCFG_PD_LPOSC); /*!< Ensure Main osc is on */
165 CLOCK_SetMainClkSrc(kCLOCK_MainClkSrcFro); /*!< select fro for main clock */
166 CLOCK_Select(kADC_Clk_From_Fro); /*!< select FRO for ADC */
167 CLOCK_SetCoreSysClkDiv(1U);
168 /*!< Set SystemCoreClock variable. */
169 SystemCoreClock = BOARD_BOOTCLOCKFRO30M_CORE_CLOCK;
170}