1 /*
2 * Copyright 2017-2020 ,2021 NXP
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7 /*
8 * How to set up clock using clock driver functions:
9 *
10 * 1. Setup clock sources.
11 *
12 * 2. Set up all dividers.
13 *
14 * 3. Set up all selectors to provide selected clocks.
15 */
16
17 /* TEXT BELOW IS USED AS SETTING FOR TOOLS *************************************
18 !!GlobalInfo
19 product: Clocks v7.0
20 processor: LPC802
21 package_id: LPC802M001JDH20
22 mcu_data: ksdk2_0
23 processor_version: 9.0.0
24 * BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR TOOLS **********/
25
26 #include "fsl_power.h"
27 #include "fsl_clock.h"
28 #include "clock_config.h"
29
30 /*******************************************************************************
31 * Definitions
32 ******************************************************************************/
33
34 /*******************************************************************************
35 * Variables
36 ******************************************************************************/
37 /* System clock frequency. */
38 extern uint32_t SystemCoreClock;
39
40 /*******************************************************************************
41 ************************ BOARD_InitBootClocks function ************************
42 ******************************************************************************/
BOARD_InitBootClocks(void)43 void BOARD_InitBootClocks(void)
44 {
45 BOARD_BootClockFRO30M();
46 }
47
48 /*******************************************************************************
49 ******************** Configuration BOARD_BootClockFRO18M **********************
50 ******************************************************************************/
51 /* TEXT BELOW IS USED AS SETTING FOR TOOLS *************************************
52 !!Configuration
53 name: BOARD_BootClockFRO18M
54 outputs:
55 - {id: FROHF_clock.outFreq, value: 18 MHz}
56 - {id: LowPower_clock.outFreq, value: 1 MHz}
57 - {id: System_clock.outFreq, value: 9 MHz}
58 - {id: WWDT_clock.outFreq, value: 1 MHz}
59 - {id: divto750k_clock.outFreq, value: 750 kHz}
60 settings:
61 - {id: SYSCON.CLKOUTSEL.sel, value: NO_CLOCK}
62 - {id: SYSCON.FRG0CLKSEL.sel, value: NO_CLOCK}
63 sources:
64 - {id: SYSCON.fro_osc.outFreq, value: 18 MHz}
65 * BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR TOOLS **********/
66
67 /*******************************************************************************
68 * Variables for BOARD_BootClockFRO18M configuration
69 ******************************************************************************/
70 /*******************************************************************************
71 * Code for BOARD_BootClockFRO18M configuration
72 ******************************************************************************/
BOARD_BootClockFRO18M(void)73 void BOARD_BootClockFRO18M(void)
74 {
75 /*!< Set up the clock sources */
76 /*!< Set up FRO */
77 POWER_DisablePD(kPDRUNCFG_PD_FRO_OUT); /*!< Ensure FRO is on */
78 POWER_DisablePD(kPDRUNCFG_PD_FRO); /*!< Ensure FRO is on */
79 CLOCK_SetFroOscFreq(kCLOCK_FroOscOut18M); /*!< Set up FRO freq */
80 POWER_DisablePD(kPDRUNCFG_PD_LPOSC); /*!< Ensure Main osc is on */
81 CLOCK_SetMainClkSrc(kCLOCK_MainClkSrcFro); /*!< select fro for main clock */
82 CLOCK_Select(kADC_Clk_From_Fro); /*!< select FRO for ADC */
83 CLOCK_SetCoreSysClkDiv(1U);
84 /*!< Set SystemCoreClock variable. */
85 SystemCoreClock = BOARD_BOOTCLOCKFRO18M_CORE_CLOCK;
86 }
87
88 /*******************************************************************************
89 ******************** Configuration BOARD_BootClockFRO24M **********************
90 ******************************************************************************/
91 /* TEXT BELOW IS USED AS SETTING FOR TOOLS *************************************
92 !!Configuration
93 name: BOARD_BootClockFRO24M
94 outputs:
95 - {id: FROHF_clock.outFreq, value: 24 MHz}
96 - {id: LowPower_clock.outFreq, value: 1 MHz}
97 - {id: System_clock.outFreq, value: 12 MHz}
98 - {id: WWDT_clock.outFreq, value: 1 MHz}
99 - {id: divto750k_clock.outFreq, value: 750 kHz}
100 settings:
101 - {id: SYSCON.CLKOUTSEL.sel, value: NO_CLOCK}
102 - {id: SYSCON.FRG0CLKSEL.sel, value: NO_CLOCK}
103 sources:
104 - {id: SYSCON.fro_osc.outFreq, value: 24 MHz}
105 * BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR TOOLS **********/
106
107 /*******************************************************************************
108 * Variables for BOARD_BootClockFRO24M configuration
109 ******************************************************************************/
110 /*******************************************************************************
111 * Code for BOARD_BootClockFRO24M configuration
112 ******************************************************************************/
BOARD_BootClockFRO24M(void)113 void BOARD_BootClockFRO24M(void)
114 {
115 /*!< Set up the clock sources */
116 /*!< Set up FRO */
117 POWER_DisablePD(kPDRUNCFG_PD_FRO_OUT); /*!< Ensure FRO is on */
118 POWER_DisablePD(kPDRUNCFG_PD_FRO); /*!< Ensure FRO is on */
119 CLOCK_SetFroOscFreq(kCLOCK_FroOscOut24M); /*!< Set up FRO freq */
120 POWER_DisablePD(kPDRUNCFG_PD_LPOSC); /*!< Ensure Main osc is on */
121 CLOCK_SetMainClkSrc(kCLOCK_MainClkSrcFro); /*!< select fro for main clock */
122 CLOCK_Select(kADC_Clk_From_Fro); /*!< select FRO for ADC */
123 CLOCK_SetCoreSysClkDiv(1U);
124 /*!< Set SystemCoreClock variable. */
125 SystemCoreClock = BOARD_BOOTCLOCKFRO24M_CORE_CLOCK;
126 }
127
128 /*******************************************************************************
129 ******************** Configuration BOARD_BootClockFRO30M **********************
130 ******************************************************************************/
131 /* TEXT BELOW IS USED AS SETTING FOR TOOLS *************************************
132 !!Configuration
133 name: BOARD_BootClockFRO30M
134 called_from_default_init: true
135 outputs:
136 - {id: FROHF_clock.outFreq, value: 30 MHz}
137 - {id: LowPower_clock.outFreq, value: 1 MHz}
138 - {id: System_clock.outFreq, value: 15 MHz}
139 - {id: WWDT_clock.outFreq, value: 1 MHz}
140 - {id: divto750k_clock.outFreq, value: 750 kHz}
141 settings:
142 - {id: SYSCON.CLKOUTSEL.sel, value: NO_CLOCK}
143 - {id: SYSCON.FRG0CLKSEL.sel, value: NO_CLOCK}
144 * BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR TOOLS **********/
145
146 /*******************************************************************************
147 * Variables for BOARD_BootClockFRO30M configuration
148 ******************************************************************************/
149 /*******************************************************************************
150 * Code for BOARD_BootClockFRO30M configuration
151 ******************************************************************************/
BOARD_BootClockFRO30M(void)152 void BOARD_BootClockFRO30M(void)
153 {
154 /*!< Set up the clock sources */
155 /*!< Set up FRO */
156 POWER_DisablePD(kPDRUNCFG_PD_FRO_OUT); /*!< Ensure FRO is on */
157 POWER_DisablePD(kPDRUNCFG_PD_FRO); /*!< Ensure FRO is on */
158 CLOCK_SetFroOscFreq(kCLOCK_FroOscOut30M); /*!< Set up FRO freq */
159 POWER_DisablePD(kPDRUNCFG_PD_LPOSC); /*!< Ensure Main osc is on */
160 CLOCK_SetMainClkSrc(kCLOCK_MainClkSrcFro); /*!< select fro for main clock */
161 CLOCK_Select(kADC_Clk_From_Fro); /*!< select FRO for ADC */
162 CLOCK_SetCoreSysClkDiv(1U);
163 /*!< Set SystemCoreClock variable. */
164 SystemCoreClock = BOARD_BOOTCLOCKFRO30M_CORE_CLOCK;
165 }
166
167