1 /*
2 ** ###################################################################
3 **     Processors:          MK22FN1M0VLH12
4 **                          MK22FN1M0VLK12
5 **                          MK22FN1M0VLL12
6 **                          MK22FN1M0VLQ12
7 **                          MK22FN1M0VMC12
8 **                          MK22FN1M0VMD12
9 **                          MK22FX512VLH12
10 **                          MK22FX512VLK12
11 **                          MK22FX512VLL12
12 **                          MK22FX512VLQ12
13 **                          MK22FX512VMC12
14 **                          MK22FX512VMD12
15 **
16 **     Compilers:           Freescale C/C++ for Embedded ARM
17 **                          GNU C Compiler
18 **                          IAR ANSI C/C++ Compiler for ARM
19 **                          Keil ARM C/C++ Compiler
20 **                          MCUXpresso Compiler
21 **
22 **     Reference manuals:   K22P100M120SF5V2RM, Rev.5, March 2015
23 **                          K22P121M120SF5V2RM, Rev.5, March 2015
24 **                          K22P144M120SF5V2RM, Rev.5, March 2015
25 **                          K22P64M120SF5V2RM, Rev.5, March 2015
26 **                          K22P80M120SF5V2RM, Rev.5, March 2015
27 **
28 **     Version:             rev. 1.8, 2015-02-19
29 **     Build:               b181105
30 **
31 **     Abstract:
32 **         Provides a system configuration function and a global variable that
33 **         contains the system frequency. It configures the device and initializes
34 **         the oscillator (PLL) that is part of the microcontroller device.
35 **
36 **     Copyright 2016 Freescale Semiconductor, Inc.
37 **     Copyright 2016-2018 NXP
38 **     All rights reserved.
39 **
40 **     SPDX-License-Identifier: BSD-3-Clause
41 **
42 **     http:                 www.nxp.com
43 **     mail:                 support@nxp.com
44 **
45 **     Revisions:
46 **     - rev. 1.0 (2012-06-06)
47 **         Initial version.
48 **     - rev. 1.1 (2012-11-12)
49 **         Update according to reference manual rev.1, draft B
50 **     - rev. 1.2 (2012-12-04)
51 **         Update according to reference manual rev.1
52 **     - rev. 1.3 (2013-03-11)
53 **         System initialization updated to add 120MHz clock option.
54 **     - rev. 1.4 (2013-04-05)
55 **         Changed start of doxygen comment.
56 **     - rev. 1.5 (2013-05-16)
57 **         Update according to reference manual rev.2
58 **     - rev. 1.6 (2013-10-29)
59 **         Definition of BITBAND macros updated to support peripherals with 32-bit acces disabled.
60 **         Access restriction of some registers fixed.
61 **     - rev. 1.7 (2014-02-18)
62 **         UART0 module - LON registers removed.
63 **     - rev. 1.8 (2015-02-19)
64 **         update of SystemInit() imlementation
65 **         Module access macro module_BASES replaced by module_BASE_PTRS.
66 **         Register accessor macros added to the memory map.
67 **         Renamed interrupt vector Watchdog to WDOG_EWM, LPTimer to LPTMR0 and LLW to LLWU
68 **
69 ** ###################################################################
70 */
71 
72 /*!
73  * @file MK22F12
74  * @version 1.8
75  * @date 2015-02-19
76  * @brief Device specific configuration file for MK22F12 (header file)
77  *
78  * Provides a system configuration function and a global variable that contains
79  * the system frequency. It configures the device and initializes the oscillator
80  * (PLL) that is part of the microcontroller device.
81  */
82 
83 #ifndef _SYSTEM_MK22F12_H_
84 #define _SYSTEM_MK22F12_H_                       /**< Symbol preventing repeated inclusion */
85 
86 #ifdef __cplusplus
87 extern "C" {
88 #endif
89 
90 #include <stdint.h>
91 
92 
93 #ifndef DISABLE_WDOG
94   #define DISABLE_WDOG                 1
95 #endif
96 
97 
98 /* Define clock source values */
99 
100 #define CPU_XTAL_CLK_HZ                8000000U            /* Value of the external crystal or oscillator clock frequency of the system oscillator (OSC) in Hz */
101 #define CPU_XTAL32k_CLK_HZ             32768U              /* Value of the external 32k crystal or oscillator clock frequency of the RTC in Hz */
102 #define CPU_INT_SLOW_CLK_HZ            32768U              /* Value of the slow internal oscillator clock frequency in Hz */
103 #define CPU_INT_FAST_CLK_HZ            4000000U            /* Value of the fast internal oscillator clock frequency in Hz */
104 
105 /* RTC oscillator setting */
106 /* #undef SYSTEM_RTC_CR_VALUE */                           /* RTC oscillator not enabled. Commented out for MISRA compliance. */
107 
108 /* Low power mode enable */
109 /* SMC_PMPROT: AVLP=1,ALLS=1,AVLLS=1 */
110 #define SYSTEM_SMC_PMPROT_VALUE        0x2AU               /* SMC_PMPROT */
111 
112 #define DEFAULT_SYSTEM_CLOCK           20971520u           /* Default System clock value */
113 
114 
115 /**
116  * @brief System clock frequency (core clock)
117  *
118  * The system clock frequency supplied to the SysTick timer and the processor
119  * core clock. This variable can be used by the user application to setup the
120  * SysTick timer or configure other parameters. It may also be used by debugger to
121  * query the frequency of the debug timer or configure the trace clock speed
122  * SystemCoreClock is initialized with a correct predefined value.
123  */
124 extern uint32_t SystemCoreClock;
125 
126 /**
127  * @brief Setup the microcontroller system.
128  *
129  * Typically this function configures the oscillator (PLL) that is part of the
130  * microcontroller device. For systems with variable clock speed it also updates
131  * the variable SystemCoreClock. SystemInit is called from startup_device file.
132  */
133 void SystemInit (void);
134 
135 /**
136  * @brief Updates the SystemCoreClock variable.
137  *
138  * It must be called whenever the core clock is changed during program
139  * execution. SystemCoreClockUpdate() evaluates the clock register settings and calculates
140  * the current core clock.
141  */
142 void SystemCoreClockUpdate (void);
143 
144 /**
145  * @brief SystemInit function hook.
146  *
147  * This weak function allows to call specific initialization code during the
148  * SystemInit() execution.This can be used when an application specific code needs
149  * to be called as close to the reset entry as possible (for example the Multicore
150  * Manager MCMGR_EarlyInit() function call).
151  * NOTE: No global r/w variables can be used in this hook function because the
152  * initialization of these variables happens after this function.
153  */
154 void SystemInitHook (void);
155 
156 #ifdef __cplusplus
157 }
158 #endif
159 
160 #endif  /* _SYSTEM_MK22F12_H_ */
161