diff options
Diffstat (limited to 'lib/chibios-contrib/ext/mcux-sdk/devices/LPC54S018/project_template/clock_config.c')
-rw-r--r-- | lib/chibios-contrib/ext/mcux-sdk/devices/LPC54S018/project_template/clock_config.c | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/lib/chibios-contrib/ext/mcux-sdk/devices/LPC54S018/project_template/clock_config.c b/lib/chibios-contrib/ext/mcux-sdk/devices/LPC54S018/project_template/clock_config.c new file mode 100644 index 000000000..a6aaa3f58 --- /dev/null +++ b/lib/chibios-contrib/ext/mcux-sdk/devices/LPC54S018/project_template/clock_config.c | |||
@@ -0,0 +1,89 @@ | |||
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. Setup voltage for the fastest of the clock outputs | ||
14 | * | ||
15 | * 3. Set up wait states of the flash. | ||
16 | * | ||
17 | * 4. Set up all dividers. | ||
18 | * | ||
19 | * 5. Set up all selectors to provide selected clocks. | ||
20 | */ | ||
21 | |||
22 | /* TEXT BELOW IS USED AS SETTING FOR TOOLS ************************************* | ||
23 | !!GlobalInfo | ||
24 | product: Clocks v5.0 | ||
25 | processor: LPC54S018 | ||
26 | mcu_data: ksdk2_0 | ||
27 | processor_version: 0.0.5 | ||
28 | * BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR TOOLS **********/ | ||
29 | |||
30 | #include "fsl_power.h" | ||
31 | #include "fsl_clock.h" | ||
32 | #include "clock_config.h" | ||
33 | |||
34 | /******************************************************************************* | ||
35 | * Definitions | ||
36 | ******************************************************************************/ | ||
37 | |||
38 | /******************************************************************************* | ||
39 | * Variables | ||
40 | ******************************************************************************/ | ||
41 | /* System clock frequency. */ | ||
42 | extern uint32_t SystemCoreClock; | ||
43 | |||
44 | /******************************************************************************* | ||
45 | ************************ BOARD_InitBootClocks function ************************ | ||
46 | ******************************************************************************/ | ||
47 | void BOARD_InitBootClocks(void) | ||
48 | { | ||
49 | BOARD_BootClockRUN(); | ||
50 | } | ||
51 | |||
52 | /******************************************************************************* | ||
53 | ********************** Configuration BOARD_BootClockRUN *********************** | ||
54 | ******************************************************************************/ | ||
55 | /* TEXT BELOW IS USED AS SETTING FOR TOOLS ************************************* | ||
56 | !!Configuration | ||
57 | name: BOARD_BootClockRUN | ||
58 | called_from_default_init: true | ||
59 | outputs: | ||
60 | - {id: FRO12M_clock.outFreq, value: 12 MHz} | ||
61 | - {id: FROHF_clock.outFreq, value: 48 MHz} | ||
62 | - {id: MAIN_clock.outFreq, value: 12 MHz} | ||
63 | - {id: System_clock.outFreq, value: 12 MHz} | ||
64 | * BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR TOOLS **********/ | ||
65 | |||
66 | /******************************************************************************* | ||
67 | * Variables for BOARD_BootClockRUN configuration | ||
68 | ******************************************************************************/ | ||
69 | /******************************************************************************* | ||
70 | * Code for BOARD_BootClockRUN configuration | ||
71 | ******************************************************************************/ | ||
72 | void BOARD_BootClockRUN(void) | ||
73 | { | ||
74 | /*!< Set up the clock sources */ | ||
75 | /*!< Set up FRO */ | ||
76 | POWER_DisablePD(kPDRUNCFG_PD_FRO_EN); /*!< Ensure FRO is on */ | ||
77 | CLOCK_AttachClk(kFRO12M_to_MAIN_CLK); /*!< Switch to FRO 12MHz first to ensure we can change voltage without accidentally | ||
78 | being below the voltage for current speed */ | ||
79 | POWER_SetVoltageForFreq(12000000U); /*!< Set voltage for the one of the fastest clock outputs: System clock output */ | ||
80 | |||
81 | /*!< Set up dividers */ | ||
82 | CLOCK_SetClkDiv(kCLOCK_DivAhbClk, 1U, false); /*!< Reset divider counter and set divider to value 1 */ | ||
83 | |||
84 | /*!< Set up clock selectors - Attach clocks to the peripheries */ | ||
85 | CLOCK_AttachClk(kFRO12M_to_MAIN_CLK); /*!< Switch MAIN_CLK to FRO12M */ | ||
86 | /* Set SystemCoreClock variable. */ | ||
87 | SystemCoreClock = BOARD_BOOTCLOCKRUN_CORE_CLOCK; | ||
88 | } | ||
89 | |||