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 v5.0
21 processor: LPC811
22 mcu_data: ksdk2_0
23 processor_version: 0.0.10
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_BootClockRUN();
46 }
47
48 /*******************************************************************************
49 ********************** Configuration BOARD_BootClockRUN ***********************
50 ******************************************************************************/
51 /* TEXT BELOW IS USED AS SETTING FOR TOOLS *************************************
52 !!Configuration
53 name: BOARD_BootClockRUN
54 called_from_default_init: true
55 outputs:
56 - {id: I2C0_clock.outFreq, value: 12 MHz}
57 - {id: LowPower_clock.outFreq, value: 10 kHz}
58 - {id: SPI0_clock.outFreq, value: 12 MHz}
59 - {id: SYSPLL_clock.outFreq, value: 12 MHz}
60 - {id: System_clock.outFreq, value: 12 MHz}
61 - {id: divto750k_clock.outFreq, value: 750 kHz}
62 * BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR TOOLS **********/
63
64 /*******************************************************************************
65 * Variables for BOARD_BootClockRUN configuration
66 ******************************************************************************/
67 /*******************************************************************************
68 * Code for BOARD_BootClockRUN configuration
69 ******************************************************************************/
BOARD_BootClockRUN(void)70 void BOARD_BootClockRUN(void)
71 {
72 /*!< Set up the clock sources */
73 /*!< Set up IRC */
74 POWER_DisablePD(kPDRUNCFG_PD_IRC_OUT); /*!< Ensure IRC_OUT is on */
75 POWER_DisablePD(kPDRUNCFG_PD_IRC); /*!< Ensure IRC is on */
76 POWER_DisablePD(kPDRUNCFG_PD_SYSOSC); /*!< Ensure Main osc is on */
77 CLOCK_Select(kSYSPLL_From_Irc); /*!< set IRC to pll select */
78 clock_sys_pll_t config;
79 config.src = kCLOCK_SysPllSrcIrc; /*!< set pll src */
80 config.targetFreq = 12000000U; /*!< set pll target freq */
81 CLOCK_InitSystemPll(&config); /*!< set parameters */
82 CLOCK_SetMainClkSrc(kCLOCK_MainClkSrcIrc); /*!< select IRC for main clock */
83 CLOCK_Select(kCLKOUT_From_Irc); /*!< select IRC for CLKOUT */
84 CLOCK_UpdateClkOUTsrc(); /*!< update CLKOUT src */
85 CLOCK_SetCoreSysClkDiv(1U);
86 /*!< Set SystemCoreClock variable. */
87 SystemCoreClock = BOARD_BOOTCLOCKRUN_CORE_CLOCK;
88 }
89
90