aboutsummaryrefslogtreecommitdiff
path: root/lib/chibios-contrib/ext/mcux-sdk/devices/LPC824/project_template/clock_config.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/chibios-contrib/ext/mcux-sdk/devices/LPC824/project_template/clock_config.c')
-rw-r--r--lib/chibios-contrib/ext/mcux-sdk/devices/LPC824/project_template/clock_config.c93
1 files changed, 93 insertions, 0 deletions
diff --git a/lib/chibios-contrib/ext/mcux-sdk/devices/LPC824/project_template/clock_config.c b/lib/chibios-contrib/ext/mcux-sdk/devices/LPC824/project_template/clock_config.c
new file mode 100644
index 000000000..b94440f59
--- /dev/null
+++ b/lib/chibios-contrib/ext/mcux-sdk/devices/LPC824/project_template/clock_config.c
@@ -0,0 +1,93 @@
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
20product: Clocks v5.0
21processor: LPC824
22mcu_data: ksdk2_0
23processor_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. */
38extern uint32_t SystemCoreClock;
39
40/*******************************************************************************
41 ************************ BOARD_InitBootClocks function ************************
42 ******************************************************************************/
43void 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
53name: BOARD_BootClockRUN
54called_from_default_init: true
55outputs:
56- {id: ADC_clock.outFreq, value: 12 MHz}
57- {id: I2C0_clock.outFreq, value: 12 MHz}
58- {id: I2C1_clock.outFreq, value: 12 MHz}
59- {id: I2C2_clock.outFreq, value: 12 MHz}
60- {id: I2C3_clock.outFreq, value: 12 MHz}
61- {id: LowPower_clock.outFreq, value: 10 kHz}
62- {id: SPI0_clock.outFreq, value: 12 MHz}
63- {id: SPI1_clock.outFreq, value: 12 MHz}
64- {id: SYSPLL_clock.outFreq, value: 12 MHz}
65- {id: System_clock.outFreq, value: 12 MHz}
66- {id: divto750k_clock.outFreq, value: 750 kHz}
67 * BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR TOOLS **********/
68
69/*******************************************************************************
70 * Variables for BOARD_BootClockRUN configuration
71 ******************************************************************************/
72/*******************************************************************************
73 * Code for BOARD_BootClockRUN configuration
74 ******************************************************************************/
75void BOARD_BootClockRUN(void)
76{
77 /*!< Set up the clock sources */
78 /*!< Set up IRC */
79 POWER_DisablePD(kPDRUNCFG_PD_IRC_OUT); /*!< Ensure IRC OUT is on */
80 POWER_DisablePD(kPDRUNCFG_PD_IRC); /*!< Ensure IRC is on */
81 POWER_DisablePD(kPDRUNCFG_PD_SYSOSC); /*!< Ensure SYSOSC is on */
82 CLOCK_Select(kSYSPLL_From_Irc); /*!< set IRC to pll select */
83 clock_sys_pll_t config;
84 config.src = kCLOCK_SysPllSrcIrc; /*!< set pll src */
85 config.targetFreq = 12000000U; /*!< set pll target freq */
86 CLOCK_InitSystemPll(&config); /*!< set parameters */
87 CLOCK_SetMainClkSrc(kCLOCK_MainClkSrcIrc); /*!< select irc for main clock */
88 CLOCK_Select(kCLKOUT_From_Irc); /*!< select IRC for CLKOUT */
89 CLOCK_SetCoreSysClkDiv(1U);
90 /*!< Set SystemCoreClock variable. */
91 SystemCoreClock = BOARD_BOOTCLOCKRUN_CORE_CLOCK;
92}
93