diff options
Diffstat (limited to 'lib/chibios-contrib/ext/mcux-sdk/devices/LPC804/system_LPC804.c')
-rw-r--r-- | lib/chibios-contrib/ext/mcux-sdk/devices/LPC804/system_LPC804.c | 116 |
1 files changed, 116 insertions, 0 deletions
diff --git a/lib/chibios-contrib/ext/mcux-sdk/devices/LPC804/system_LPC804.c b/lib/chibios-contrib/ext/mcux-sdk/devices/LPC804/system_LPC804.c new file mode 100644 index 000000000..ed52c5061 --- /dev/null +++ b/lib/chibios-contrib/ext/mcux-sdk/devices/LPC804/system_LPC804.c | |||
@@ -0,0 +1,116 @@ | |||
1 | /* | ||
2 | ** ################################################################### | ||
3 | ** Processors: LPC804M101JDH20 | ||
4 | ** LPC804M101JDH24 | ||
5 | ** LPC804M101JHI33 | ||
6 | ** LPC804M111JDH24 | ||
7 | ** LPC804UK | ||
8 | ** | ||
9 | ** Compilers: GNU C Compiler | ||
10 | ** IAR ANSI C/C++ Compiler for ARM | ||
11 | ** Keil ARM C/C++ Compiler | ||
12 | ** MCUXpresso Compiler | ||
13 | ** | ||
14 | ** Reference manual: LPC804 User manual Rev.1.0 24 Jan 2018 | ||
15 | ** Version: rev. 1.0, 2018-01-09 | ||
16 | ** Build: b201015 | ||
17 | ** | ||
18 | ** Abstract: | ||
19 | ** Provides a system configuration function and a global variable that | ||
20 | ** contains the system frequency. It configures the device and initializes | ||
21 | ** the oscillator (PLL) that is part of the microcontroller device. | ||
22 | ** | ||
23 | ** Copyright 2016 Freescale Semiconductor, Inc. | ||
24 | ** Copyright 2016-2020 NXP | ||
25 | ** All rights reserved. | ||
26 | ** | ||
27 | ** SPDX-License-Identifier: BSD-3-Clause | ||
28 | ** | ||
29 | ** http: www.nxp.com | ||
30 | ** mail: [email protected] | ||
31 | ** | ||
32 | ** Revisions: | ||
33 | ** - rev. 1.0 (2018-01-09) | ||
34 | ** Initial version. | ||
35 | ** | ||
36 | ** ################################################################### | ||
37 | */ | ||
38 | |||
39 | /*! | ||
40 | * @file LPC804 | ||
41 | * @version 1.0 | ||
42 | * @date 2018-01-09 | ||
43 | * @brief Device specific configuration file for LPC804 (implementation file) | ||
44 | * | ||
45 | * Provides a system configuration function and a global variable that contains | ||
46 | * the system frequency. It configures the device and initializes the oscillator | ||
47 | * (PLL) that is part of the microcontroller device. | ||
48 | */ | ||
49 | |||
50 | #include <stdint.h> | ||
51 | #include "fsl_device_registers.h" | ||
52 | |||
53 | extern uint32_t g_Fro_Osc_Freq; | ||
54 | extern uint32_t g_LP_Osc_Freq; | ||
55 | |||
56 | |||
57 | |||
58 | /* ---------------------------------------------------------------------------- | ||
59 | -- Core clock | ||
60 | ---------------------------------------------------------------------------- */ | ||
61 | |||
62 | uint32_t SystemCoreClock = DEFAULT_SYSTEM_CLOCK; | ||
63 | |||
64 | /* ---------------------------------------------------------------------------- | ||
65 | -- SystemInit() | ||
66 | ---------------------------------------------------------------------------- */ | ||
67 | |||
68 | void SystemInit (void) { | ||
69 | |||
70 | #if defined(__MCUXPRESSO) | ||
71 | extern void(*const g_pfnVectors[]) (void); | ||
72 | SCB->VTOR = (uint32_t) &g_pfnVectors; | ||
73 | #else | ||
74 | extern void *__Vectors; | ||
75 | SCB->VTOR = (uint32_t) &__Vectors; | ||
76 | #endif | ||
77 | SystemCoreClock = DEFAULT_SYSTEM_CLOCK; | ||
78 | SystemInitHook(); | ||
79 | } | ||
80 | |||
81 | /* ---------------------------------------------------------------------------- | ||
82 | -- SystemCoreClockUpdate() | ||
83 | ---------------------------------------------------------------------------- */ | ||
84 | |||
85 | void SystemCoreClockUpdate (void) { | ||
86 | |||
87 | |||
88 | switch (SYSCON->MAINCLKSEL & SYSCON_MAINCLKSEL_SEL_MASK) | ||
89 | { | ||
90 | case 0U: /* Free running oscillator (FRO / 2) */ | ||
91 | SystemCoreClock = (g_Fro_Osc_Freq >> 1U); | ||
92 | break; | ||
93 | case 1U: /* System oscillator */ | ||
94 | SystemCoreClock = CLK_OSC_IN; | ||
95 | break; | ||
96 | case 2U: /* lower power oscillator */ | ||
97 | SystemCoreClock = g_LP_Osc_Freq; | ||
98 | break; | ||
99 | case 3U: /* Free running oscillator ((FRO / 2) / 2) */ | ||
100 | SystemCoreClock = (g_Fro_Osc_Freq >> 2U); | ||
101 | break; | ||
102 | default: | ||
103 | SystemCoreClock = 0U; | ||
104 | break; | ||
105 | } | ||
106 | |||
107 | SystemCoreClock /= SYSCON->SYSAHBCLKDIV; | ||
108 | } | ||
109 | |||
110 | /* ---------------------------------------------------------------------------- | ||
111 | -- SystemInitHook() | ||
112 | ---------------------------------------------------------------------------- */ | ||
113 | |||
114 | __attribute__ ((weak)) void SystemInitHook (void) { | ||
115 | /* Void implementation of the weak function. */ | ||
116 | } | ||