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