diff options
Diffstat (limited to 'lib/chibios-contrib/ext/mcux-sdk/devices/LPC844/project_template/clock_config.c')
-rw-r--r-- | lib/chibios-contrib/ext/mcux-sdk/devices/LPC844/project_template/clock_config.c | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/lib/chibios-contrib/ext/mcux-sdk/devices/LPC844/project_template/clock_config.c b/lib/chibios-contrib/ext/mcux-sdk/devices/LPC844/project_template/clock_config.c new file mode 100644 index 000000000..19d6887be --- /dev/null +++ b/lib/chibios-contrib/ext/mcux-sdk/devices/LPC844/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 | ||
20 | product: Clocks v5.0 | ||
21 | processor: LPC844 | ||
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 | ******************************************************************************/ | ||
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: FROHF_clock.outFreq, value: 30 MHz} | ||
57 | - {id: SYSPLL_clock.outFreq, value: 15 MHz} | ||
58 | - {id: System_clock.outFreq, value: 15 MHz} | ||
59 | * BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR TOOLS **********/ | ||
60 | |||
61 | /******************************************************************************* | ||
62 | * Variables for BOARD_BootClockRUN configuration | ||
63 | ******************************************************************************/ | ||
64 | /******************************************************************************* | ||
65 | * Code for BOARD_BootClockRUN configuration | ||
66 | ******************************************************************************/ | ||
67 | void BOARD_BootClockRUN(void) | ||
68 | { | ||
69 | /*!< Set up the clock sources */ | ||
70 | /*!< Set up FRO */ | ||
71 | POWER_DisablePD(kPDRUNCFG_PD_FRO_OUT); /*!< Ensure FRO is on */ | ||
72 | POWER_DisablePD(kPDRUNCFG_PD_FRO); /*!< Ensure FRO is on */ | ||
73 | CLOCK_SetFroOscFreq(kCLOCK_FroOscOut30M); /*!< Set up FRO freq */ | ||
74 | CLOCK_SetFroOutClkSrc(kCLOCK_FroSrcLpwrBootValue); /*!< Set FRO clock source */ | ||
75 | POWER_DisablePD(kPDRUNCFG_PD_SYSOSC); /*!< Ensure Main osc is on */ | ||
76 | CLOCK_Select(kEXT_Clk_From_SysOsc); /*!<select external clock source to sys_osc */ | ||
77 | clock_sys_pll_t config; | ||
78 | config.src = kCLOCK_SysPllSrcFRO; /*!< select FRO for SYSPLL */ | ||
79 | config.targetFreq = 15000000U; /*!< set pll target freq */ | ||
80 | CLOCK_InitSystemPll(&config); /*!< set parameters */ | ||
81 | CLOCK_Select(kFRG0_Clk_From_Fro); /*!< select fro for frg0 */ | ||
82 | CLOCK_SetFRG0ClkFreq(15000000U); /*!< select frg0 freq */ | ||
83 | CLOCK_Select(kFRG1_Clk_From_Fro); /*!< select fro for frg1 */ | ||
84 | CLOCK_SetFRG1ClkFreq(15000000U); /*!< select frg1 freq */ | ||
85 | CLOCK_SetMainClkSrc(kCLOCK_MainClkSrcFro); /*!< select fro for main clock */ | ||
86 | CLOCK_Select(kCLKOUT_From_Fro); /*!< select FRO for CLKOUT */ | ||
87 | CLOCK_Select(kSCT_Clk_From_Fro); /*!< select FRO for SCT */ | ||
88 | CLOCK_Select(kADC_Clk_From_Fro); /*!< select FRO for ADC */ | ||
89 | CLOCK_SetCoreSysClkDiv(1U); | ||
90 | /*!< Set SystemCoreClock variable. */ | ||
91 | SystemCoreClock = BOARD_BOOTCLOCKRUN_CORE_CLOCK; | ||
92 | } | ||
93 | |||