1 /*
2  * Copyright 2023 NXP
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 /***********************************************************************************************************************
8  * This file was generated by the MCUXpresso Config Tools. Any manual edits made to this file
9  * will be overwritten if the respective MCUXpresso Config Tools is used to update this file.
10  **********************************************************************************************************************/
11 /*
12  * How to set up clock using clock driver functions:
13  *
14  * 1. Setup clock sources.
15  *
16  * 2. Set up all selectors to provide selected clocks.
17  *
18  * 3. Set up all dividers.
19  */
20 
21 #include "fsl_clock.h"
22 #include "clock_config.h"
23 #include "fsl_power.h"
24 
25 /*******************************************************************************
26  * Definitions
27  ******************************************************************************/
28 
29 /*******************************************************************************
30  * Variables
31  ******************************************************************************/
32 /*******************************************************************************
33  ************************ BOARD_InitBootClocks function ************************
34  ******************************************************************************/
BOARD_InitBootClocks(void)35 void BOARD_InitBootClocks(void)
36 {
37     BOARD_BootClockRUN();
38 }
39 
40 /*******************************************************************************
41  ********************** Configuration BOARD_BootClockRUN ***********************
42  ******************************************************************************/
43 
44 /*******************************************************************************
45  * Variables for BOARD_BootClockRUN configuration
46  ******************************************************************************/
47 
48 /*******************************************************************************
49  * Code for BOARD_BootClockRUN configuration
50  ******************************************************************************/
BOARD_BootClockRUN(void)51 void BOARD_BootClockRUN(void)
52 {
53     /* Power up OSC in case it's not enabled. */
54     POWER_DisablePD(kPDRUNCFG_PD_SYSXTAL);
55     CLOCK_EnableSysOscClk(true, true, BOARD_SYSOSC_SETTLING_US); /* Enable system OSC */
56     CLOCK_SetXtalFreq(BOARD_XTAL_SYS_CLK_HZ);                    /* Sets external XTAL OSC freq */
57 
58     CLOCK_AttachClk(kFRO1_DIV3_to_SENSE_BASE);
59     CLOCK_SetClkDiv(kCLOCK_DivSenseMainClk, 1);
60     CLOCK_AttachClk(kSENSE_BASE_to_SENSE_MAIN);
61 
62     POWER_DisablePD(kPDRUNCFG_GATE_FRO2);
63     CLOCK_EnableFroClkFreq(FRO2, 300000000U, kCLOCK_FroAllOutEn);
64 
65     CLOCK_EnableFro2ClkForDomain(kCLOCK_AllDomainEnable);
66 
67     CLOCK_AttachClk(kFRO2_DIV3_to_SENSE_BASE);
68     CLOCK_SetClkDiv(kCLOCK_DivSenseMainClk, 1);
69     CLOCK_AttachClk(kSENSE_BASE_to_SENSE_MAIN);
70 
71     SystemCoreClock = BOARD_BOOTCLOCKRUN_CORE_CLOCK;
72 }
73