1 /*
2 ** ###################################################################
3 **     Processors:          MK22FN128CAH12
4 **                          MK22FN256CAH12
5 **                          MK22FN256VDC12
6 **                          MK22FN256VLH12
7 **                          MK22FN256VLL12
8 **                          MK22FN256VMP12
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:    K22P121M120SF8RM, Rev. 1, March 24, 2014
17 **     Version:             rev. 1.8, 2015-02-19
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-09-17)
36 **         Initial version.
37 **     - rev. 1.1 (2013-10-29)
38 **         Definition of BITBAND macros updated to support peripherals with 32-bit acces disabled.
39 **     - rev. 1.2 (2013-12-20)
40 **         Update according to reference manual rev. 0.6,
41 **     - rev. 1.3 (2014-02-06)
42 **         Update according to reference manual rev. 0.61,
43 **     - rev. 1.4 (2014-02-10)
44 **         The declaration of clock configurations has been moved to separate header file system_MK22F25612.h
45 **     - rev. 1.5 (2014-04-30)
46 **         Update of MCM and USB modules according to the RM rev. 1.
47 **         Update of system and startup files.
48 **         Module access macro module_BASES replaced by module_BASE_PTRS.
49 **     - rev. 1.6 (2014-08-28)
50 **         Update of system files - default clock configuration changed.
51 **         Update of startup files - possibility to override DefaultISR added.
52 **     - rev. 1.7 (2014-10-14)
53 **         Interrupt INT_LPTimer renamed to INT_LPTMR0, interrupt INT_Watchdog renamed to INT_WDOG_EWM.
54 **     - rev. 1.8 (2015-02-19)
55 **         Renamed interrupt vector LLW to LLWU.
56 **
57 ** ###################################################################
58 */
59 
60 /*!
61  * @file MK22F25612
62  * @version 1.8
63  * @date 2015-02-19
64  * @brief Device specific configuration file for MK22F25612 (header file)
65  *
66  * Provides a system configuration function and a global variable that contains
67  * the system frequency. It configures the device and initializes the oscillator
68  * (PLL) that is part of the microcontroller device.
69  */
70 
71 #ifndef _SYSTEM_MK22F25612_H_
72 #define _SYSTEM_MK22F25612_H_                    /**< Symbol preventing repeated inclusion */
73 
74 #ifdef __cplusplus
75 extern "C" {
76 #endif
77 
78 #include <stdint.h>
79 
80 
81 #ifndef DISABLE_WDOG
82   #define DISABLE_WDOG                 1
83 #endif
84 
85 /* Define clock source values */
86 
87 #define CPU_XTAL_CLK_HZ                8000000u            /* Value of the external crystal or oscillator clock frequency in Hz */
88 #define CPU_XTAL32k_CLK_HZ             32768u              /* Value of the external 32k crystal or oscillator clock frequency in Hz */
89 #define CPU_INT_SLOW_CLK_HZ            32768u              /* Value of the slow internal oscillator clock frequency in Hz  */
90 #define CPU_INT_FAST_CLK_HZ            4000000u            /* Value of the fast internal oscillator clock frequency in Hz  */
91 #define CPU_INT_IRC_CLK_HZ             48000000u           /* Value of the 48M internal oscillator clock frequency in Hz  */
92 
93 /* RTC oscillator setting */
94 /* RTC_CR: SC2P=0,SC4P=0,SC8P=0,SC16P=0,CLKO=1,OSCE=1,WPS=0,UM=0,SUP=0,WPE=0,SWR=0 */
95 #define SYSTEM_RTC_CR_VALUE            0x0300U             /* RTC_CR */
96 
97 /* Low power mode enable */
98 /* SMC_PMPROT: AHSRUN=1,AVLP=1,ALLS=1,AVLLS=1 */
99 #define SYSTEM_SMC_PMPROT_VALUE        0xAAU               /* SMC_PMPROT */
100 
101 #define DEFAULT_SYSTEM_CLOCK           20971520u           /* Default System clock value */
102 
103 
104 /**
105  * @brief System clock frequency (core clock)
106  *
107  * The system clock frequency supplied to the SysTick timer and the processor
108  * core clock. This variable can be used by the user application to setup the
109  * SysTick timer or configure other parameters. It may also be used by debugger to
110  * query the frequency of the debug timer or configure the trace clock speed
111  * SystemCoreClock is initialized with a correct predefined value.
112  */
113 extern uint32_t SystemCoreClock;
114 
115 /**
116  * @brief Setup the microcontroller system.
117  *
118  * Typically this function configures the oscillator (PLL) that is part of the
119  * microcontroller device. For systems with variable clock speed it also updates
120  * the variable SystemCoreClock. SystemInit is called from startup_device file.
121  */
122 void SystemInit (void);
123 
124 /**
125  * @brief Updates the SystemCoreClock variable.
126  *
127  * It must be called whenever the core clock is changed during program
128  * execution. SystemCoreClockUpdate() evaluates the clock register settings and calculates
129  * the current core clock.
130  */
131 void SystemCoreClockUpdate (void);
132 
133 /**
134  * @brief SystemInit function hook.
135  *
136  * This weak function allows to call specific initialization code during the
137  * SystemInit() execution.This can be used when an application specific code needs
138  * to be called as close to the reset entry as possible (for example the Multicore
139  * Manager MCMGR_EarlyInit() function call).
140  * NOTE: No global r/w variables can be used in this hook function because the
141  * initialization of these variables happens after this function.
142  */
143 void SystemInitHook (void);
144 
145 #ifdef __cplusplus
146 }
147 #endif
148 
149 #endif  /* _SYSTEM_MK22F25612_H_ */
150