1 /*
2 ** ###################################################################
3 **     Processors:          MK22FN512CAP12
4 **                          MK22FN512VDC12
5 **                          MK22FN512VFX12
6 **                          MK22FN512VLH12
7 **                          MK22FN512VLL12
8 **                          MK22FN512VMP12
9 **
10 **     Compilers:           Freescale C/C++ for Embedded ARM
11 **                          GNU C Compiler
12 **                          IAR ANSI C/C++ Compiler for ARM
13 **                          Keil ARM C/C++ Compiler
14 **                          MCUXpresso Compiler
15 **
16 **     Reference manual:    K22P121M120SF7RM, Rev. 1, March 24, 2014
17 **     Version:             rev. 2.9, 2016-03-21
18 **     Build:               b181105
19 **
20 **     Abstract:
21 **         Provides a system configuration function and a global variable that
22 **         contains the system frequency. It configures the device and initializes
23 **         the oscillator (PLL) that is part of the microcontroller device.
24 **
25 **     Copyright 2016 Freescale Semiconductor, Inc.
26 **     Copyright 2016-2018 NXP
27 **     All rights reserved.
28 **
29 **     SPDX-License-Identifier: BSD-3-Clause
30 **
31 **     http:                 www.nxp.com
32 **     mail:                 support@nxp.com
33 **
34 **     Revisions:
35 **     - rev. 1.0 (2013-07-23)
36 **         Initial version.
37 **     - rev. 1.1 (2013-09-17)
38 **         RM rev. 0.4 update.
39 **     - rev. 2.0 (2013-10-29)
40 **         Register accessor macros added to the memory map.
41 **         Symbols for Processor Expert memory map compatibility added to the memory map.
42 **         Startup file for gcc has been updated according to CMSIS 3.2.
43 **         System initialization updated.
44 **     - rev. 2.1 (2013-10-30)
45 **         Definition of BITBAND macros updated to support peripherals with 32-bit acces disabled.
46 **     - rev. 2.2 (2013-12-20)
47 **         Update according to reference manual rev. 0.6,
48 **     - rev. 2.3 (2014-01-13)
49 **         Update according to reference manual rev. 0.61,
50 **     - rev. 2.4 (2014-02-10)
51 **         The declaration of clock configurations has been moved to separate header file system_MK22F51212.h
52 **     - rev. 2.5 (2014-05-06)
53 **         Update according to reference manual rev. 1.0,
54 **         Update of system and startup files.
55 **         Module access macro module_BASES replaced by module_BASE_PTRS.
56 **     - rev. 2.6 (2014-08-28)
57 **         Update of system files - default clock configuration changed.
58 **         Update of startup files - possibility to override DefaultISR added.
59 **     - rev. 2.7 (2014-10-14)
60 **         Interrupt INT_LPTimer renamed to INT_LPTMR0, interrupt INT_Watchdog renamed to INT_WDOG_EWM.
61 **     - rev. 2.8 (2015-02-19)
62 **         Renamed interrupt vector LLW to LLWU.
63 **     - rev. 2.9 (2016-03-21)
64 **         Added MK22FN512VFX12 part.
65 **         GPIO - renamed port instances: PTx -> GPIOx.
66 **
67 ** ###################################################################
68 */
69 
70 /*!
71  * @file MK22F51212
72  * @version 2.9
73  * @date 2016-03-21
74  * @brief Device specific configuration file for MK22F51212 (header file)
75  *
76  * Provides a system configuration function and a global variable that contains
77  * the system frequency. It configures the device and initializes the oscillator
78  * (PLL) that is part of the microcontroller device.
79  */
80 
81 #ifndef _SYSTEM_MK22F51212_H_
82 #define _SYSTEM_MK22F51212_H_                    /**< Symbol preventing repeated inclusion */
83 
84 #ifdef __cplusplus
85 extern "C" {
86 #endif
87 
88 #include <stdint.h>
89 
90 
91 #ifndef DISABLE_WDOG
92   #define DISABLE_WDOG                 1
93 #endif
94 
95 /* Define clock source values */
96 
97 #define CPU_XTAL_CLK_HZ                8000000u            /* Value of the external crystal or oscillator clock frequency in Hz */
98 #define CPU_XTAL32k_CLK_HZ             32768u              /* Value of the external 32k crystal or oscillator clock frequency in Hz */
99 #define CPU_INT_SLOW_CLK_HZ            32768u              /* Value of the slow internal oscillator clock frequency in Hz  */
100 #define CPU_INT_FAST_CLK_HZ            4000000u            /* Value of the fast internal oscillator clock frequency in Hz  */
101 #define CPU_INT_IRC_CLK_HZ             48000000u           /* Value of the 48M internal oscillator clock frequency in Hz  */
102 
103 /* RTC oscillator setting */
104 /* RTC_CR: SC2P=0,SC4P=0,SC8P=0,SC16P=0,CLKO=1,OSCE=1,WPS=0,UM=0,SUP=0,WPE=0,SWR=0 */
105 #define SYSTEM_RTC_CR_VALUE            0x0300U             /* RTC_CR */
106 
107 /* Low power mode enable */
108 /* SMC_PMPROT: AHSRUN=1,AVLP=1,ALLS=1,AVLLS=1 */
109 #define SYSTEM_SMC_PMPROT_VALUE        0xAAU               /* SMC_PMPROT */
110 
111 #define DEFAULT_SYSTEM_CLOCK           20971520u           /* Default System clock value */
112 
113 
114 /**
115  * @brief System clock frequency (core clock)
116  *
117  * The system clock frequency supplied to the SysTick timer and the processor
118  * core clock. This variable can be used by the user application to setup the
119  * SysTick timer or configure other parameters. It may also be used by debugger to
120  * query the frequency of the debug timer or configure the trace clock speed
121  * SystemCoreClock is initialized with a correct predefined value.
122  */
123 extern uint32_t SystemCoreClock;
124 
125 /**
126  * @brief Setup the microcontroller system.
127  *
128  * Typically this function configures the oscillator (PLL) that is part of the
129  * microcontroller device. For systems with variable clock speed it also updates
130  * the variable SystemCoreClock. SystemInit is called from startup_device file.
131  */
132 void SystemInit (void);
133 
134 /**
135  * @brief Updates the SystemCoreClock variable.
136  *
137  * It must be called whenever the core clock is changed during program
138  * execution. SystemCoreClockUpdate() evaluates the clock register settings and calculates
139  * the current core clock.
140  */
141 void SystemCoreClockUpdate (void);
142 
143 /**
144  * @brief SystemInit function hook.
145  *
146  * This weak function allows to call specific initialization code during the
147  * SystemInit() execution.This can be used when an application specific code needs
148  * to be called as close to the reset entry as possible (for example the Multicore
149  * Manager MCMGR_EarlyInit() function call).
150  * NOTE: No global r/w variables can be used in this hook function because the
151  * initialization of these variables happens after this function.
152  */
153 void SystemInitHook (void);
154 
155 #ifdef __cplusplus
156 }
157 #endif
158 
159 #endif  /* _SYSTEM_MK22F51212_H_ */
160