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
20 product: Clocks v4.1
21 processor: LPC804
22 package_id: LPC804M101JDH24
23 mcu_data: ksdk2_0
24 processor_version: 4.0.1
25 board: LPCXpresso804
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. */
40 extern uint32_t SystemCoreClock;
41
42 /*******************************************************************************
43 ************************ BOARD_InitBootClocks function ************************
44 ******************************************************************************/
BOARD_InitBootClocks(void)45 void 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
55 name: BOARD_BootClockFRO18M
56 called_from_default_init: true
57 outputs:
58 - {id: CAPT_clock.outFreq, value: 4.5 MHz}
59 - {id: FROHF_clock.outFreq, value: 18 MHz}
60 - {id: System_clock.outFreq, value: 9 MHz}
61 sources:
62 - {id: SYSCON.fro_osc.outFreq, value: 18 MHz}
63 * BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR TOOLS **********/
64
65 /*******************************************************************************
66 * Variables for BOARD_BootClockFRO18M configuration
67 ******************************************************************************/
68 /*******************************************************************************
69 * Code for BOARD_BootClockFRO18M configuration
70 ******************************************************************************/
BOARD_BootClockFRO18M(void)71 void BOARD_BootClockFRO18M(void)
72 {
73 /*!< Set up the clock sources */
74 /*!< Set up FRO */
75 POWER_DisablePD(kPDRUNCFG_PD_FRO_OUT); /*!< Ensure FRO is on */
76 POWER_DisablePD(kPDRUNCFG_PD_FRO); /*!< Ensure FRO is on */
77 CLOCK_SetFroOscFreq(kCLOCK_FroOscOut18M); /*!< Set up FRO freq */
78 CLOCK_SetMainClkSrc(kCLOCK_MainClkSrcFro); /*!< select fro for main clock */
79 CLOCK_Select(kFRG0_Clk_From_Fro); /*!< select fro for frg0 */
80 CLOCK_SetFRG0ClkFreq(9000000U); /*!< select frg0 freq */
81 CLOCK_Select(kCLKOUT_From_Fro); /*!< select FRO for CLKOUT */
82 CLOCK_Select(kCAPT_Clk_From_Fro_Div); /*!< select FRO_DIV for CAPT */
83 CLOCK_Select(kADC_Clk_From_Fro); /*!< select FRO for ADC */
84 CLOCK_SetCoreSysClkDiv(1U);
85 /*!< Set SystemCoreClock variable. */
86 SystemCoreClock = BOARD_BOOTCLOCKFRO18M_CORE_CLOCK;
87 }
88
89 /*******************************************************************************
90 ******************** Configuration BOARD_BootClockFRO24M **********************
91 ******************************************************************************/
92 /* TEXT BELOW IS USED AS SETTING FOR TOOLS *************************************
93 !!Configuration
94 name: BOARD_BootClockFRO24M
95 outputs:
96 - {id: CAPT_clock.outFreq, value: 6 MHz}
97 - {id: FROHF_clock.outFreq, value: 24 MHz}
98 - {id: System_clock.outFreq, value: 12 MHz}
99 sources:
100 - {id: SYSCON.fro_osc.outFreq, value: 24 MHz}
101 * BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR TOOLS **********/
102
103 /*******************************************************************************
104 * Variables for BOARD_BootClockFRO24M configuration
105 ******************************************************************************/
106 /*******************************************************************************
107 * Code for BOARD_BootClockFRO24M configuration
108 ******************************************************************************/
BOARD_BootClockFRO24M(void)109 void BOARD_BootClockFRO24M(void)
110 {
111 /*!< Set up the clock sources */
112 /*!< Set up FRO */
113 POWER_DisablePD(kPDRUNCFG_PD_FRO_OUT); /*!< Ensure FRO is on */
114 POWER_DisablePD(kPDRUNCFG_PD_FRO); /*!< Ensure FRO is on */
115 CLOCK_SetFroOscFreq(kCLOCK_FroOscOut24M); /*!< Set up FRO freq */
116 CLOCK_SetMainClkSrc(kCLOCK_MainClkSrcFro); /*!< select fro for main clock */
117 CLOCK_Select(kFRG0_Clk_From_Fro); /*!< select fro for frg0 */
118 CLOCK_SetFRG0ClkFreq(12000000U); /*!< select frg0 freq */
119 CLOCK_Select(kCLKOUT_From_Fro); /*!< select FRO for CLKOUT */
120 CLOCK_Select(kCAPT_Clk_From_Fro_Div); /*!< select FRO_DIV for CAPT */
121 CLOCK_Select(kADC_Clk_From_Fro); /*!< select FRO for ADC */
122 CLOCK_SetCoreSysClkDiv(1U);
123 /*!< Set SystemCoreClock variable. */
124 SystemCoreClock = BOARD_BOOTCLOCKFRO24M_CORE_CLOCK;
125 }
126
127 /*******************************************************************************
128 ******************** Configuration BOARD_BootClockFRO30M **********************
129 ******************************************************************************/
130 /* TEXT BELOW IS USED AS SETTING FOR TOOLS *************************************
131 !!Configuration
132 name: BOARD_BootClockFRO30M
133 outputs:
134 - {id: CAPT_clock.outFreq, value: 7.5 MHz}
135 - {id: FROHF_clock.outFreq, value: 30 MHz}
136 - {id: System_clock.outFreq, value: 15 MHz}
137 * BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR TOOLS **********/
138
139 /*******************************************************************************
140 * Variables for BOARD_BootClockFRO30M configuration
141 ******************************************************************************/
142 /*******************************************************************************
143 * Code for BOARD_BootClockFRO30M configuration
144 ******************************************************************************/
BOARD_BootClockFRO30M(void)145 void BOARD_BootClockFRO30M(void)
146 {
147 /*!< Set up the clock sources */
148 /*!< Set up FRO */
149 POWER_DisablePD(kPDRUNCFG_PD_FRO_OUT); /*!< Ensure FRO is on */
150 POWER_DisablePD(kPDRUNCFG_PD_FRO); /*!< Ensure FRO is on */
151 CLOCK_SetFroOscFreq(kCLOCK_FroOscOut30M); /*!< Set up FRO freq */
152 CLOCK_SetMainClkSrc(kCLOCK_MainClkSrcFro); /*!< select fro for main clock */
153 CLOCK_Select(kFRG0_Clk_From_Fro); /*!< select fro for frg0 */
154 CLOCK_SetFRG0ClkFreq(15000000U); /*!< select frg0 freq */
155 CLOCK_Select(kCLKOUT_From_Fro); /*!< select FRO for CLKOUT */
156 CLOCK_Select(kCAPT_Clk_From_Fro_Div); /*!< select FRO_DIV for CAPT */
157 CLOCK_Select(kADC_Clk_From_Fro); /*!< select FRO for ADC */
158 CLOCK_SetCoreSysClkDiv(1U);
159 /*!< Set SystemCoreClock variable. */
160 SystemCoreClock = BOARD_BOOTCLOCKFRO30M_CORE_CLOCK;
161 }
162