aboutsummaryrefslogtreecommitdiff
path: root/lib/chibios-contrib/ext/mcux-sdk/boards/frdmke02z40m/clock_config.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/chibios-contrib/ext/mcux-sdk/boards/frdmke02z40m/clock_config.c')
-rw-r--r--lib/chibios-contrib/ext/mcux-sdk/boards/frdmke02z40m/clock_config.c128
1 files changed, 128 insertions, 0 deletions
diff --git a/lib/chibios-contrib/ext/mcux-sdk/boards/frdmke02z40m/clock_config.c b/lib/chibios-contrib/ext/mcux-sdk/boards/frdmke02z40m/clock_config.c
new file mode 100644
index 000000000..0707c59cf
--- /dev/null
+++ b/lib/chibios-contrib/ext/mcux-sdk/boards/frdmke02z40m/clock_config.c
@@ -0,0 +1,128 @@
1/*
2 * Copyright 2017,2019 NXP
3 * All rights reserved.
4 *
5 * SPDX-License-Identifier: BSD-3-Clause
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 setup clock using clock driver functions:
13 *
14 * 1. call CLOCK_SetSimSafeDivs() to set the system clock dividers in SIM to safe value.
15 *
16 * 2. If external oscillator is used Call CLOCK_SetXtal0Freq() to set XTAL0 frequency based on board settings and
17 * call CLOCK_InitOsc0() to init the OSC.
18 *
19 * 3. Call CLOCK_BootToXxxMode()/CLOCK_SetXxxMode() to set ICS run at the target mode.
20 *
21 * 4. If ICSIRCLK is needed, call CLOCK_SetInternalRefClkConfig() to enable the clock.
22 *
23 * 5. call CLOCK_SetSimConfig() to configure the divider in sim.
24 */
25
26/* clang-format off */
27/* TEXT BELOW IS USED AS SETTING FOR TOOLS *************************************
28!!GlobalInfo
29product: Clocks v7.0
30processor: MKE02Z64xxx4
31package_id: MKE02Z64VQH4
32mcu_data: ksdk2_0
33processor_version: 0.7.1
34 * BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR TOOLS **********/
35/* clang-format on */
36
37#include "clock_config.h"
38
39/*******************************************************************************
40 * Definitions
41 ******************************************************************************/
42
43/*******************************************************************************
44 * Variables
45 ******************************************************************************/
46/* System clock frequency. */
47extern uint32_t SystemCoreClock;
48
49/*******************************************************************************
50 ************************ BOARD_InitBootClocks function ************************
51 ******************************************************************************/
52void BOARD_InitBootClocks(void)
53{
54 BOARD_BootClockRUN();
55}
56
57/*******************************************************************************
58 ********************** Configuration BOARD_BootClockRUN ***********************
59 ******************************************************************************/
60/* clang-format off */
61/* TEXT BELOW IS USED AS SETTING FOR TOOLS *************************************
62!!Configuration
63name: BOARD_BootClockRUN
64called_from_default_init: true
65outputs:
66- {id: Bus_clock.outFreq, value: 20 MHz}
67- {id: Core_clock.outFreq, value: 40 MHz}
68- {id: Flash_clock.outFreq, value: 20 MHz}
69- {id: ICSFF_clock.outFreq, value: 39.0625/2 kHz}
70- {id: ICSIR_clock.outFreq, value: 31.25 kHz}
71- {id: LPO_clock.outFreq, value: 1 kHz}
72- {id: OSCER_clock.outFreq, value: 10 MHz}
73- {id: Plat_clock.outFreq, value: 40 MHz}
74- {id: System_clock.outFreq, value: 40 MHz}
75settings:
76- {id: ICSMode, value: FEE}
77- {id: ICS.BDIV.scale, value: '1', locked: true}
78- {id: ICS.IREFS.sel, value: ICS.RDIV}
79- {id: ICS.RDIV.scale, value: '256', locked: true}
80- {id: ICS_C1_IRCLKEN_CFG, value: Enabled}
81- {id: OSC_CR_OSCEN_CFG, value: Enabled}
82- {id: OSC_CR_OSC_MODE_CFG, value: ModeOscLowPower}
83- {id: OSC_CR_RANGE_CFG, value: High}
84- {id: OSC_CR_RANGE_RDIV_CFG, value: High}
85- {id: SIM.BUSDIV.scale, value: '2'}
86sources:
87- {id: OSC.OSC.outFreq, value: 10 MHz, enabled: true}
88 * BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR TOOLS **********/
89/* clang-format on */
90
91/*******************************************************************************
92 * Variables for BOARD_BootClockRUN configuration
93 ******************************************************************************/
94const ics_config_t icsConfig_BOARD_BootClockRUN = {
95 .icsMode = kICS_ModeFEE, /* FEE - FLL Engaged External */
96 .irClkEnableMode = kICS_IrclkEnable, /* ICSIRCLK enabled, ICSIRCLK disabled in STOP mode */
97 .bDiv = 0x0U, /* Bus clock divider: divided by 1 */
98 .rDiv = 0x3U, /* FLL external reference clock divider: divided by 256 */
99};
100const sim_clock_config_t simConfig_BOARD_BootClockRUN = {
101 .busDiv = 0x1U, /* BUSDIV clock divider: divided by 2 */
102 .busClkPrescaler = 0x0U, /* bus clock optional prescaler */
103};
104const osc_config_t oscConfig_BOARD_BootClockRUN = {
105 .freq = 10000000U, /* Oscillator frequency: 10000000Hz */
106 .workMode = kOSC_ModeOscLowPower, /* Oscillator low power */
107 .enableMode = kOSC_Enable, /* Enable external reference clock, disable external reference clock in STOP mode */
108};
109
110/*******************************************************************************
111 * Code for BOARD_BootClockRUN configuration
112 ******************************************************************************/
113void BOARD_BootClockRUN(void)
114{
115 /* Set the system clock dividers in SIM to safe value. */
116 CLOCK_SetSimSafeDivs();
117 /* Initializes OSC0 according to board configuration. */
118 CLOCK_InitOsc0(&oscConfig_BOARD_BootClockRUN);
119 CLOCK_SetXtal0Freq(oscConfig_BOARD_BootClockRUN.freq);
120 /* Set ICS to FEE mode. */
121 CLOCK_BootToFeeMode(icsConfig_BOARD_BootClockRUN.bDiv, icsConfig_BOARD_BootClockRUN.rDiv);
122 /* Configure the Internal Reference clock (ICSIRCLK). */
123 CLOCK_SetInternalRefClkConfig(icsConfig_BOARD_BootClockRUN.irClkEnableMode);
124 /* Set the clock configuration in SIM module. */
125 CLOCK_SetSimConfig(&simConfig_BOARD_BootClockRUN);
126 /* Set SystemCoreClock variable. */
127 SystemCoreClock = BOARD_BOOTCLOCKRUN_CORE_CLOCK;
128}