1 /*
2  * Copyright 2018 NXP.
3  * All rights reserved.
4  *
5  * SPDX-License-Identifier: BSD-3-Clause
6  */
7 
8 /***********************************************************************************************************************
9  * This file was generated by the MCUXpresso Config Tools. Any manual edits made to this file
10  * will be overwritten if the respective MCUXpresso Config Tools is used to update this file.
11  **********************************************************************************************************************/
12 /*
13  * How to setup clock using clock driver functions:
14  *
15  * 1. CLOCK_SetSimSafeDivs, to make sure core clock, bus clock, flexbus clock
16  *    and flash clock are in allowed range during clock mode switch.
17  *
18  * 2. Call CLOCK_Osc0Init to setup OSC clock, if it is used in target mode.
19  *
20  * 3. Call CLOCK_SetMcgliteConfig to set MCG_Lite configuration.
21  *
22  * 4. Call CLOCK_SetSimConfig to set the clock configuration in SIM.
23  */
24 
25 /* clang-format off */
26 /* TEXT BELOW IS USED AS SETTING FOR TOOLS *************************************
27 !!GlobalInfo
28 product: Clocks v5.0
29 processor: MKL17Z64xxx4
30 mcu_data: ksdk2_0
31 processor_version: 0.0.16
32  * BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR TOOLS **********/
33 /* clang-format on */
34 
35 #include "clock_config.h"
36 
37 /*******************************************************************************
38  * Definitions
39  ******************************************************************************/
40 #define OSC_CAP0P                                         0U  /*!< Oscillator 0pF capacitor load */
41 #define OSC_ER_CLK_DISABLE                                0U  /*!< Disable external reference clock */
42 #define SIM_OSC32KSEL_OSC32KCLK_CLK                       0U  /*!< OSC32KSEL select: OSC32KCLK clock */
43 
44 /*******************************************************************************
45  * Variables
46  ******************************************************************************/
47 /* System clock frequency. */
48 extern uint32_t SystemCoreClock;
49 
50 /*******************************************************************************
51  ************************ BOARD_InitBootClocks function ************************
52  ******************************************************************************/
BOARD_InitBootClocks(void)53 void BOARD_InitBootClocks(void)
54 {
55     BOARD_BootClockRUN();
56 }
57 
58 /*******************************************************************************
59  ********************** Configuration BOARD_BootClockRUN ***********************
60  ******************************************************************************/
61 /* clang-format off */
62 /* TEXT BELOW IS USED AS SETTING FOR TOOLS *************************************
63 !!Configuration
64 name: BOARD_BootClockRUN
65 called_from_default_init: true
66 outputs:
67 - {id: Bus_clock.outFreq, value: 4 MHz}
68 - {id: Core_clock.outFreq, value: 8 MHz}
69 - {id: Flash_clock.outFreq, value: 4 MHz}
70 - {id: LPO_clock.outFreq, value: 1 kHz}
71 - {id: MCGIRCLK.outFreq, value: 8 MHz}
72 - {id: System_clock.outFreq, value: 8 MHz}
73  * BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR TOOLS **********/
74 /* clang-format on */
75 
76 /*******************************************************************************
77  * Variables for BOARD_BootClockRUN configuration
78  ******************************************************************************/
79 const mcglite_config_t mcgliteConfig_BOARD_BootClockRUN =
80     {
81         .outSrc = kMCGLITE_ClkSrcLirc,            /* MCGOUTCLK source is LIRC */
82         .irclkEnableMode = kMCGLITE_IrclkEnable,  /* MCGIRCLK enabled, MCGIRCLK disabled in STOP mode */
83         .ircs = kMCGLITE_Lirc8M,                  /* Slow internal reference (LIRC) 8 MHz clock selected */
84         .fcrdiv = kMCGLITE_LircDivBy1,            /* Low-frequency Internal Reference Clock Divider: divided by 1 */
85         .lircDiv2 = kMCGLITE_LircDivBy1,          /* Second Low-frequency Internal Reference Clock Divider: divided by 1 */
86         .hircEnableInNotHircMode = false,         /* HIRC source is not enabled */
87     };
88 const sim_clock_config_t simConfig_BOARD_BootClockRUN =
89     {
90         .er32kSrc = SIM_OSC32KSEL_OSC32KCLK_CLK,  /* OSC32KSEL select: OSC32KCLK clock */
91         .clkdiv1 = 0x10000U,                      /* SIM_CLKDIV1 - OUTDIV1: /1, OUTDIV4: /2 */
92     };
93 const osc_config_t oscConfig_BOARD_BootClockRUN =
94     {
95         .freq = 0U,                               /* Oscillator frequency: 0Hz */
96         .capLoad = (OSC_CAP0P),                   /* Oscillator capacity load: 0pF */
97         .workMode = kOSC_ModeExt,                 /* Use external clock */
98         .oscerConfig =
99             {
100                 .enableMode = OSC_ER_CLK_DISABLE, /* Disable external reference clock */
101             }
102     };
103 
104 /*******************************************************************************
105  * Code for BOARD_BootClockRUN configuration
106  ******************************************************************************/
BOARD_BootClockRUN(void)107 void BOARD_BootClockRUN(void)
108 {
109     /* Set the system clock dividers in SIM to safe value. */
110     CLOCK_SetSimSafeDivs();
111     /* Set MCG to LIRC8M mode. */
112     CLOCK_SetMcgliteConfig(&mcgliteConfig_BOARD_BootClockRUN);
113     /* Set the clock configuration in SIM module. */
114     CLOCK_SetSimConfig(&simConfig_BOARD_BootClockRUN);
115     /* Set SystemCoreClock variable. */
116     SystemCoreClock = BOARD_BOOTCLOCKRUN_CORE_CLOCK;
117 }
118 
119