1 /*
2 ** ###################################################################
3 **     Processors:          MKL25Z128VFM4
4 **                          MKL25Z128VFT4
5 **                          MKL25Z128VLH4
6 **                          MKL25Z128VLK4
7 **                          MKL25Z32VFM4
8 **                          MKL25Z32VFT4
9 **                          MKL25Z32VLH4
10 **                          MKL25Z32VLK4
11 **                          MKL25Z64VFM4
12 **                          MKL25Z64VFT4
13 **                          MKL25Z64VLH4
14 **                          MKL25Z64VLK4
15 **
16 **     Compilers:           Keil ARM C/C++ Compiler
17 **                          Freescale C/C++ for Embedded ARM
18 **                          GNU C Compiler
19 **                          IAR ANSI C/C++ Compiler for ARM
20 **                          MCUXpresso Compiler
21 **
22 **     Reference manual:    KL25P80M48SF0RM, Rev.3, Sep 2012
23 **     Version:             rev. 2.5, 2015-02-19
24 **     Build:               b170112
25 **
26 **     Abstract:
27 **         Provides a system configuration function and a global variable that
28 **         contains the system frequency. It configures the device and initializes
29 **         the oscillator (PLL) that is part of the microcontroller device.
30 **
31 **     Copyright (c) 2016 Freescale Semiconductor, Inc.
32 **     Copyright 2016 - 2017 NXP
33 **     Redistribution and use in source and binary forms, with or without modification,
34 **     are permitted provided that the following conditions are met:
35 **
36 **     o Redistributions of source code must retain the above copyright notice, this list
37 **       of conditions and the following disclaimer.
38 **
39 **     o Redistributions in binary form must reproduce the above copyright notice, this
40 **       list of conditions and the following disclaimer in the documentation and/or
41 **       other materials provided with the distribution.
42 **
43 **     o Neither the name of the copyright holder nor the names of its
44 **       contributors may be used to endorse or promote products derived from this
45 **       software without specific prior written permission.
46 **
47 **     THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
48 **     ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
49 **     WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
50 **     DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
51 **     ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
52 **     (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
53 **     LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
54 **     ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
55 **     (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
56 **     SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
57 **
58 **     http:                 www.nxp.com
59 **     mail:                 support@nxp.com
60 **
61 **     Revisions:
62 **     - rev. 1.0 (2012-06-13)
63 **         Initial version.
64 **     - rev. 1.1 (2012-06-21)
65 **         Update according to reference manual rev. 1.
66 **     - rev. 1.2 (2012-08-01)
67 **         Device type UARTLP changed to UART0.
68 **     - rev. 1.3 (2012-10-04)
69 **         Update according to reference manual rev. 3.
70 **     - rev. 1.4 (2012-11-22)
71 **         MCG module - bit LOLS in MCG_S register renamed to LOLS0.
72 **         NV registers - bit EZPORT_DIS in NV_FOPT register removed.
73 **     - rev. 1.5 (2013-04-05)
74 **         Changed start of doxygen comment.
75 **     - rev. 2.0 (2013-10-29)
76 **         Register accessor macros added to the memory map.
77 **         Symbols for Processor Expert memory map compatibility added to the memory map.
78 **         Startup file for gcc has been updated according to CMSIS 3.2.
79 **         System initialization updated.
80 **     - rev. 2.1 (2014-07-16)
81 **         Module access macro module_BASES replaced by module_BASE_PTRS.
82 **         System initialization and startup updated.
83 **     - rev. 2.2 (2014-08-22)
84 **         System initialization updated - default clock config changed.
85 **     - rev. 2.3 (2014-08-28)
86 **         Update of startup files - possibility to override DefaultISR added.
87 **     - rev. 2.4 (2014-10-14)
88 **         Interrupt INT_LPTimer renamed to INT_LPTMR0.
89 **     - rev. 2.5 (2015-02-19)
90 **         Renamed interrupt vector LLW to LLWU.
91 **
92 ** ###################################################################
93 */
94 
95 /*!
96  * @file MKL25Z4
97  * @version 2.5
98  * @date 2015-02-19
99  * @brief Device specific configuration file for MKL25Z4 (header file)
100  *
101  * Provides a system configuration function and a global variable that contains
102  * the system frequency. It configures the device and initializes the oscillator
103  * (PLL) that is part of the microcontroller device.
104  */
105 
106 #ifndef _SYSTEM_MKL25Z4_H_
107 #define _SYSTEM_MKL25Z4_H_                       /**< Symbol preventing repeated inclusion */
108 
109 #ifdef __cplusplus
110 extern "C" {
111 #endif
112 
113 #include <stdint.h>
114 
115 
116 #ifndef DISABLE_WDOG
117   #define DISABLE_WDOG                 1
118 #endif
119 
120 
121 
122 /* Define clock source values */
123 
124 #define CPU_XTAL_CLK_HZ                8000000u            /* Value of the external crystal or oscillator clock frequency in Hz */
125 #define CPU_INT_SLOW_CLK_HZ            32768u              /* Value of the slow internal oscillator clock frequency in Hz */
126 #define CPU_INT_FAST_CLK_HZ            4000000u            /* Value of the fast internal oscillator clock frequency in Hz */
127 
128 /* RTC oscillator setting */
129 
130 /* Low power mode enable */
131 /* SMC_PMPROT: AVLP=1,ALLS=1,AVLLS=1 */
132 #define SYSTEM_SMC_PMPROT_VALUE        0x2AU               /* SMC_PMPROT */
133 
134 #define DEFAULT_SYSTEM_CLOCK           20971520u           /* Default System clock value */
135 
136 
137 /**
138  * @brief System clock frequency (core clock)
139  *
140  * The system clock frequency supplied to the SysTick timer and the processor
141  * core clock. This variable can be used by the user application to setup the
142  * SysTick timer or configure other parameters. It may also be used by debugger to
143  * query the frequency of the debug timer or configure the trace clock speed
144  * SystemCoreClock is initialized with a correct predefined value.
145  */
146 extern uint32_t SystemCoreClock;
147 
148 /**
149  * @brief Setup the microcontroller system.
150  *
151  * Typically this function configures the oscillator (PLL) that is part of the
152  * microcontroller device. For systems with variable clock speed it also updates
153  * the variable SystemCoreClock. SystemInit is called from startup_device file.
154  */
155 void SystemInit (void);
156 
157 /**
158  * @brief Updates the SystemCoreClock variable.
159  *
160  * It must be called whenever the core clock is changed during program
161  * execution. SystemCoreClockUpdate() evaluates the clock register settings and calculates
162  * the current core clock.
163  */
164 void SystemCoreClockUpdate (void);
165 
166 #ifdef __cplusplus
167 }
168 #endif
169 
170 #endif  /* _SYSTEM_MKL25Z4_H_ */
171