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