mbed library sources

Dependents:   Encrypted my_mbed lklk CyaSSL_DTLS_Cellular ... more

Superseded

This library was superseded by mbed-dev - https://os.mbed.com/users/mbed_official/code/mbed-dev/.

Development branch of the mbed library sources. This library is kept in synch with the latest changes from the mbed SDK and it is not guaranteed to work.

If you are looking for a stable and tested release, please import one of the official mbed library releases:

Import librarymbed

The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Committer:
mbed_official
Date:
Wed Jul 08 14:45:08 2015 +0100
Revision:
585:a1ed5b41f74f
Synchronized with git revision 7a2b57896e0263b82f31ddc5a0ad2443615db184

Full URL: https://github.com/mbedmicro/mbed/commit/7a2b57896e0263b82f31ddc5a0ad2443615db184/

Add rtc_api.c

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 585:a1ed5b41f74f 1 /*
mbed_official 585:a1ed5b41f74f 2 ** ###################################################################
mbed_official 585:a1ed5b41f74f 3 ** Processors: MKL26Z128CAL4
mbed_official 585:a1ed5b41f74f 4 ** MKL26Z128VFM4
mbed_official 585:a1ed5b41f74f 5 ** MKL26Z64VFM4
mbed_official 585:a1ed5b41f74f 6 ** MKL26Z32VM4
mbed_official 585:a1ed5b41f74f 7 ** MKL26Z128VFT4
mbed_official 585:a1ed5b41f74f 8 ** MKL26Z64VFT4
mbed_official 585:a1ed5b41f74f 9 ** MKL26Z32VFT4
mbed_official 585:a1ed5b41f74f 10 ** MKL26Z128VLH4
mbed_official 585:a1ed5b41f74f 11 ** MKL26Z64VLH4
mbed_official 585:a1ed5b41f74f 12 ** MKL26Z32VLH4
mbed_official 585:a1ed5b41f74f 13 ** MKL26Z256VLH4
mbed_official 585:a1ed5b41f74f 14 ** MKL26Z256VLL4
mbed_official 585:a1ed5b41f74f 15 ** MKL26Z128VLL4
mbed_official 585:a1ed5b41f74f 16 ** MKL26Z256VMC4
mbed_official 585:a1ed5b41f74f 17 ** MKL26Z128VMC4
mbed_official 585:a1ed5b41f74f 18 ** MKL26Z256VMP4
mbed_official 585:a1ed5b41f74f 19 **
mbed_official 585:a1ed5b41f74f 20 ** Compilers: Keil ARM C/C++ Compiler
mbed_official 585:a1ed5b41f74f 21 ** Freescale C/C++ for Embedded ARM
mbed_official 585:a1ed5b41f74f 22 ** GNU C Compiler
mbed_official 585:a1ed5b41f74f 23 ** GNU C Compiler - CodeSourcery Sourcery G++
mbed_official 585:a1ed5b41f74f 24 ** IAR ANSI C/C++ Compiler for ARM
mbed_official 585:a1ed5b41f74f 25 **
mbed_official 585:a1ed5b41f74f 26 ** Reference manuals: KL26P121M48SF4RM Rev. 3.2, October 2013
mbed_official 585:a1ed5b41f74f 27 ** KL26P121M48SF4RM, Rev.2, Dec 2012
mbed_official 585:a1ed5b41f74f 28 **
mbed_official 585:a1ed5b41f74f 29 ** Version: rev. 1.7, 2015-01-13
mbed_official 585:a1ed5b41f74f 30 ** Build: b150129
mbed_official 585:a1ed5b41f74f 31 **
mbed_official 585:a1ed5b41f74f 32 ** Abstract:
mbed_official 585:a1ed5b41f74f 33 ** Provides a system configuration function and a global variable that
mbed_official 585:a1ed5b41f74f 34 ** contains the system frequency. It configures the device and initializes
mbed_official 585:a1ed5b41f74f 35 ** the oscillator (PLL) that is part of the microcontroller device.
mbed_official 585:a1ed5b41f74f 36 **
mbed_official 585:a1ed5b41f74f 37 ** Copyright (c) 2015 Freescale Semiconductor, Inc.
mbed_official 585:a1ed5b41f74f 38 ** All rights reserved.
mbed_official 585:a1ed5b41f74f 39 **
mbed_official 585:a1ed5b41f74f 40 ** Redistribution and use in source and binary forms, with or without modification,
mbed_official 585:a1ed5b41f74f 41 ** are permitted provided that the following conditions are met:
mbed_official 585:a1ed5b41f74f 42 **
mbed_official 585:a1ed5b41f74f 43 ** o Redistributions of source code must retain the above copyright notice, this list
mbed_official 585:a1ed5b41f74f 44 ** of conditions and the following disclaimer.
mbed_official 585:a1ed5b41f74f 45 **
mbed_official 585:a1ed5b41f74f 46 ** o Redistributions in binary form must reproduce the above copyright notice, this
mbed_official 585:a1ed5b41f74f 47 ** list of conditions and the following disclaimer in the documentation and/or
mbed_official 585:a1ed5b41f74f 48 ** other materials provided with the distribution.
mbed_official 585:a1ed5b41f74f 49 **
mbed_official 585:a1ed5b41f74f 50 ** o Neither the name of Freescale Semiconductor, Inc. nor the names of its
mbed_official 585:a1ed5b41f74f 51 ** contributors may be used to endorse or promote products derived from this
mbed_official 585:a1ed5b41f74f 52 ** software without specific prior written permission.
mbed_official 585:a1ed5b41f74f 53 **
mbed_official 585:a1ed5b41f74f 54 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
mbed_official 585:a1ed5b41f74f 55 ** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
mbed_official 585:a1ed5b41f74f 56 ** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
mbed_official 585:a1ed5b41f74f 57 ** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
mbed_official 585:a1ed5b41f74f 58 ** ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
mbed_official 585:a1ed5b41f74f 59 ** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
mbed_official 585:a1ed5b41f74f 60 ** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
mbed_official 585:a1ed5b41f74f 61 ** ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
mbed_official 585:a1ed5b41f74f 62 ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
mbed_official 585:a1ed5b41f74f 63 ** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
mbed_official 585:a1ed5b41f74f 64 **
mbed_official 585:a1ed5b41f74f 65 ** http: www.freescale.com
mbed_official 585:a1ed5b41f74f 66 ** mail: support@freescale.com
mbed_official 585:a1ed5b41f74f 67 **
mbed_official 585:a1ed5b41f74f 68 ** Revisions:
mbed_official 585:a1ed5b41f74f 69 ** - rev. 1.0 (2012-12-12)
mbed_official 585:a1ed5b41f74f 70 ** Initial version.
mbed_official 585:a1ed5b41f74f 71 ** - rev. 1.1 (2013-04-05)
mbed_official 585:a1ed5b41f74f 72 ** Changed start of doxygen comment.
mbed_official 585:a1ed5b41f74f 73 ** - rev. 1.2 (2013-04-12)
mbed_official 585:a1ed5b41f74f 74 ** SystemInit function fixed for clock configuration 1.
mbed_official 585:a1ed5b41f74f 75 ** Name of the interrupt num. 31 updated to reflect proper function.
mbed_official 585:a1ed5b41f74f 76 ** - rev. 1.3 (2014-05-27)
mbed_official 585:a1ed5b41f74f 77 ** Updated to Kinetis SDK support standard.
mbed_official 585:a1ed5b41f74f 78 ** MCG OSC clock select supported (MCG_C7[OSCSEL]).
mbed_official 585:a1ed5b41f74f 79 ** - rev. 1.4 (2014-07-25)
mbed_official 585:a1ed5b41f74f 80 ** System initialization updated:
mbed_official 585:a1ed5b41f74f 81 ** - Prefix added to the system initialization parameterization constants to avoid name conflicts..
mbed_official 585:a1ed5b41f74f 82 ** - VLLSx wake-up recovery added.
mbed_official 585:a1ed5b41f74f 83 ** - Delay of 1 ms added to SystemInit() to ensure stable FLL output in FEI and FEE MCG modes.
mbed_official 585:a1ed5b41f74f 84 ** - rev. 1.5 (2014-08-28)
mbed_official 585:a1ed5b41f74f 85 ** Update of system files - default clock configuration changed, fix of OSC initialization.
mbed_official 585:a1ed5b41f74f 86 ** Update of startup files - possibility to override DefaultISR added.
mbed_official 585:a1ed5b41f74f 87 ** - rev. 1.6 (2014-10-14)
mbed_official 585:a1ed5b41f74f 88 ** Renamed interrupt vector LPTimer to LPTMR0
mbed_official 585:a1ed5b41f74f 89 ** - rev. 1.7 (2015-01-13)
mbed_official 585:a1ed5b41f74f 90 ** Update of the copyright.
mbed_official 585:a1ed5b41f74f 91 **
mbed_official 585:a1ed5b41f74f 92 ** ###################################################################
mbed_official 585:a1ed5b41f74f 93 */
mbed_official 585:a1ed5b41f74f 94
mbed_official 585:a1ed5b41f74f 95 /*!
mbed_official 585:a1ed5b41f74f 96 * @file MKL26Z4
mbed_official 585:a1ed5b41f74f 97 * @version 1.7
mbed_official 585:a1ed5b41f74f 98 * @date 2015-01-13
mbed_official 585:a1ed5b41f74f 99 * @brief Device specific configuration file for MKL26Z4 (header file)
mbed_official 585:a1ed5b41f74f 100 *
mbed_official 585:a1ed5b41f74f 101 * Provides a system configuration function and a global variable that contains
mbed_official 585:a1ed5b41f74f 102 * the system frequency. It configures the device and initializes the oscillator
mbed_official 585:a1ed5b41f74f 103 * (PLL) that is part of the microcontroller device.
mbed_official 585:a1ed5b41f74f 104 */
mbed_official 585:a1ed5b41f74f 105
mbed_official 585:a1ed5b41f74f 106 #ifndef SYSTEM_MKL26Z4_H_
mbed_official 585:a1ed5b41f74f 107 #define SYSTEM_MKL26Z4_H_ /**< Symbol preventing repeated inclusion */
mbed_official 585:a1ed5b41f74f 108
mbed_official 585:a1ed5b41f74f 109 #ifdef __cplusplus
mbed_official 585:a1ed5b41f74f 110 extern "C" {
mbed_official 585:a1ed5b41f74f 111 #endif
mbed_official 585:a1ed5b41f74f 112
mbed_official 585:a1ed5b41f74f 113 #include <stdint.h>
mbed_official 585:a1ed5b41f74f 114
mbed_official 585:a1ed5b41f74f 115
mbed_official 585:a1ed5b41f74f 116 #ifndef DISABLE_WDOG
mbed_official 585:a1ed5b41f74f 117 #define DISABLE_WDOG 1
mbed_official 585:a1ed5b41f74f 118 #endif
mbed_official 585:a1ed5b41f74f 119
mbed_official 585:a1ed5b41f74f 120 #define ACK_ISOLATION 1
mbed_official 585:a1ed5b41f74f 121
mbed_official 585:a1ed5b41f74f 122 #ifndef RTC_CLKIN_USED
mbed_official 585:a1ed5b41f74f 123 #define RTC_CLKIN_USED 1
mbed_official 585:a1ed5b41f74f 124 #endif
mbed_official 585:a1ed5b41f74f 125
mbed_official 585:a1ed5b41f74f 126
mbed_official 585:a1ed5b41f74f 127 /* MCG mode constants */
mbed_official 585:a1ed5b41f74f 128
mbed_official 585:a1ed5b41f74f 129 #define MCG_MODE_FEI 0U
mbed_official 585:a1ed5b41f74f 130 #define MCG_MODE_FBI 1U
mbed_official 585:a1ed5b41f74f 131 #define MCG_MODE_BLPI 2U
mbed_official 585:a1ed5b41f74f 132 #define MCG_MODE_FEE 3U
mbed_official 585:a1ed5b41f74f 133 #define MCG_MODE_FBE 4U
mbed_official 585:a1ed5b41f74f 134 #define MCG_MODE_BLPE 5U
mbed_official 585:a1ed5b41f74f 135 #define MCG_MODE_PBE 6U
mbed_official 585:a1ed5b41f74f 136 #define MCG_MODE_PEE 7U
mbed_official 585:a1ed5b41f74f 137
mbed_official 585:a1ed5b41f74f 138 /* Predefined clock setups
mbed_official 585:a1ed5b41f74f 139 0 ... Default part configuration
mbed_official 585:a1ed5b41f74f 140 Multipurpose Clock Generator (MCG) in FEI mode.
mbed_official 585:a1ed5b41f74f 141 Reference clock source for MCG module: Slow internal reference clock
mbed_official 585:a1ed5b41f74f 142 Core clock = 20.97152MHz
mbed_official 585:a1ed5b41f74f 143 Bus clock = 20.97152MHz
mbed_official 585:a1ed5b41f74f 144 1 ... Maximum achievable clock frequency configuration
mbed_official 585:a1ed5b41f74f 145 Multipurpose Clock Generator (MCG) in PEE mode.
mbed_official 585:a1ed5b41f74f 146 Reference clock source for MCG module: System oscillator reference clock
mbed_official 585:a1ed5b41f74f 147 Core clock = 48MHz
mbed_official 585:a1ed5b41f74f 148 Bus clock = 24MHz
mbed_official 585:a1ed5b41f74f 149 2 ... Chip internally clocked, ready for Very Low Power Run mode
mbed_official 585:a1ed5b41f74f 150 Multipurpose Clock Generator (MCG) in BLPI mode.
mbed_official 585:a1ed5b41f74f 151 Reference clock source for MCG module: Fast internal reference clock
mbed_official 585:a1ed5b41f74f 152 Core clock = 4MHz
mbed_official 585:a1ed5b41f74f 153 Bus clock = 0.8MHz
mbed_official 585:a1ed5b41f74f 154 3 ... Chip externally clocked, ready for Very Low Power Run mode
mbed_official 585:a1ed5b41f74f 155 Multipurpose Clock Generator (MCG) in BLPE mode.
mbed_official 585:a1ed5b41f74f 156 Reference clock source for MCG module: System oscillator reference clock
mbed_official 585:a1ed5b41f74f 157 Core clock = 4MHz
mbed_official 585:a1ed5b41f74f 158 Bus clock = 1MHz
mbed_official 585:a1ed5b41f74f 159 4 ... USB clock setup
mbed_official 585:a1ed5b41f74f 160 Multipurpose Clock Generator (MCG) in PEE mode.
mbed_official 585:a1ed5b41f74f 161 Reference clock source for MCG module: System oscillator reference clock
mbed_official 585:a1ed5b41f74f 162 Core clock = 48MHz
mbed_official 585:a1ed5b41f74f 163 Bus clock = 24MHz
mbed_official 585:a1ed5b41f74f 164 */
mbed_official 585:a1ed5b41f74f 165
mbed_official 585:a1ed5b41f74f 166 /* Define clock source values */
mbed_official 585:a1ed5b41f74f 167
mbed_official 585:a1ed5b41f74f 168 #define CPU_XTAL_CLK_HZ 8000000U /* Value of the external crystal or oscillator clock frequency of the system oscillator (OSC) in Hz */
mbed_official 585:a1ed5b41f74f 169 #define CPU_INT_SLOW_CLK_HZ 32768U /* Value of the slow internal oscillator clock frequency in Hz */
mbed_official 585:a1ed5b41f74f 170 #define CPU_INT_FAST_CLK_HZ 4000000U /* Value of the fast internal oscillator clock frequency in Hz */
mbed_official 585:a1ed5b41f74f 171
mbed_official 585:a1ed5b41f74f 172 /* RTC oscillator setting */
mbed_official 585:a1ed5b41f74f 173
mbed_official 585:a1ed5b41f74f 174 /* Low power mode enable */
mbed_official 585:a1ed5b41f74f 175 /* SMC_PMPROT: AVLP=1,ALLS=1,AVLLS=1 */
mbed_official 585:a1ed5b41f74f 176 #define SYSTEM_SMC_PMPROT_VALUE 0x2AU /* SMC_PMPROT */
mbed_official 585:a1ed5b41f74f 177
mbed_official 585:a1ed5b41f74f 178 /* Internal reference clock trim */
mbed_official 585:a1ed5b41f74f 179 /* #undef SLOW_TRIM_ADDRESS */ /* Slow oscillator not trimmed. Commented out for MISRA compliance. */
mbed_official 585:a1ed5b41f74f 180 /* #undef SLOW_FINE_TRIM_ADDRESS */ /* Slow oscillator not trimmed. Commented out for MISRA compliance. */
mbed_official 585:a1ed5b41f74f 181 /* #undef FAST_TRIM_ADDRESS */ /* Fast oscillator not trimmed. Commented out for MISRA compliance. */
mbed_official 585:a1ed5b41f74f 182 /* #undef FAST_FINE_TRIM_ADDRESS */ /* Fast oscillator not trimmed. Commented out for MISRA compliance. */
mbed_official 585:a1ed5b41f74f 183
mbed_official 585:a1ed5b41f74f 184 #ifdef CLOCK_SETUP
mbed_official 585:a1ed5b41f74f 185 #if (CLOCK_SETUP == 0)
mbed_official 585:a1ed5b41f74f 186 #define DEFAULT_SYSTEM_CLOCK 20971520U /* Default System clock value */
mbed_official 585:a1ed5b41f74f 187 #define MCG_MODE MCG_MODE_FEI /* Clock generator mode */
mbed_official 585:a1ed5b41f74f 188 /* MCG_C1: CLKS=0,FRDIV=0,IREFS=1,IRCLKEN=1,IREFSTEN=0 */
mbed_official 585:a1ed5b41f74f 189 #define SYSTEM_MCG_C1_VALUE 0x06U /* MCG_C1 */
mbed_official 585:a1ed5b41f74f 190 /* MCG_C2: LOCRE0=0,FCFTRIM=0,RANGE0=2,HGO0=0,EREFS0=1,LP=0,IRCS=0 */
mbed_official 585:a1ed5b41f74f 191 #define SYSTEM_MCG_C2_VALUE 0x24U /* MCG_C2 */
mbed_official 585:a1ed5b41f74f 192 /* MCG_C4: DMX32=0,DRST_DRS=0,FCTRIM=0,SCFTRIM=0 */
mbed_official 585:a1ed5b41f74f 193 #define SYSTEM_MCG_C4_VALUE 0x00U /* MCG_C4 */
mbed_official 585:a1ed5b41f74f 194 /* MCG_SC: ATME=0,ATMS=0,ATMF=0,FLTPRSRV=0,FCRDIV=0,LOCS0=0 */
mbed_official 585:a1ed5b41f74f 195 #define SYSTEM_MCG_SC_VALUE 0x00U /* MCG_SC */
mbed_official 585:a1ed5b41f74f 196 /* MCG_C5: PLLCLKEN0=0,PLLSTEN0=0,PRDIV0=0 */
mbed_official 585:a1ed5b41f74f 197 #define SYSTEM_MCG_C5_VALUE 0x00U /* MCG_C5 */
mbed_official 585:a1ed5b41f74f 198 /* MCG_C6: LOLIE0=0,PLLS=0,CME0=0,VDIV0=0 */
mbed_official 585:a1ed5b41f74f 199 #define SYSTEM_MCG_C6_VALUE 0x00U /* MCG_C6 */
mbed_official 585:a1ed5b41f74f 200 /* OSC0_CR: ERCLKEN=1,EREFSTEN=0,SC2P=0,SC4P=0,SC8P=0,SC16P=0 */
mbed_official 585:a1ed5b41f74f 201 #define SYSTEM_OSC0_CR_VALUE 0x80U /* OSC0_CR */
mbed_official 585:a1ed5b41f74f 202 /* SMC_PMCTRL: RUNM=0,STOPA=0,STOPM=0 */
mbed_official 585:a1ed5b41f74f 203 #define SYSTEM_SMC_PMCTRL_VALUE 0x00U /* SMC_PMCTRL */
mbed_official 585:a1ed5b41f74f 204 /* SIM_CLKDIV1: OUTDIV1=0,OUTDIV4=0 */
mbed_official 585:a1ed5b41f74f 205 #define SYSTEM_SIM_CLKDIV1_VALUE 0x00U /* SIM_CLKDIV1 */
mbed_official 585:a1ed5b41f74f 206 /* SIM_SOPT1: USBREGEN=0,USBSSTBY=0,USBVSTBY=0,OSC32KSEL=3 */
mbed_official 585:a1ed5b41f74f 207 #define SYSTEM_SIM_SOPT1_VALUE 0x000C0000U /* SIM_SOPT1 */
mbed_official 585:a1ed5b41f74f 208 /* SIM_SOPT2: UART0SRC=0,TPMSRC=1,USBSRC=0,PLLFLLSEL=0,CLKOUTSEL=0,RTCCLKOUTSEL=0 */
mbed_official 585:a1ed5b41f74f 209 #define SYSTEM_SIM_SOPT2_VALUE 0x01000000U /* SIM_SOPT2 */
mbed_official 585:a1ed5b41f74f 210 #elif (CLOCK_SETUP == 1)
mbed_official 585:a1ed5b41f74f 211 #define DEFAULT_SYSTEM_CLOCK 48000000U /* Default System clock value */
mbed_official 585:a1ed5b41f74f 212 #define MCG_MODE MCG_MODE_PEE /* Clock generator mode */
mbed_official 585:a1ed5b41f74f 213 /* MCG_C1: CLKS=0,FRDIV=3,IREFS=0,IRCLKEN=1,IREFSTEN=0 */
mbed_official 585:a1ed5b41f74f 214 #define SYSTEM_MCG_C1_VALUE 0x1AU /* MCG_C1 */
mbed_official 585:a1ed5b41f74f 215 /* MCG_C2: LOCRE0=0,FCFTRIM=0,RANGE0=2,HGO0=0,EREFS0=1,LP=0,IRCS=0 */
mbed_official 585:a1ed5b41f74f 216 #define SYSTEM_MCG_C2_VALUE 0x24U /* MCG_C2 */
mbed_official 585:a1ed5b41f74f 217 /* MCG_C4: DMX32=0,DRST_DRS=0,FCTRIM=0,SCFTRIM=0 */
mbed_official 585:a1ed5b41f74f 218 #define SYSTEM_MCG_C4_VALUE 0x00U /* MCG_C4 */
mbed_official 585:a1ed5b41f74f 219 /* MCG_SC: ATME=0,ATMS=0,ATMF=0,FLTPRSRV=0,FCRDIV=0,LOCS0=0 */
mbed_official 585:a1ed5b41f74f 220 #define SYSTEM_MCG_SC_VALUE 0x00U /* MCG_SC */
mbed_official 585:a1ed5b41f74f 221 /* MCG_C5: PLLCLKEN0=0,PLLSTEN0=0,PRDIV0=3 */
mbed_official 585:a1ed5b41f74f 222 #define SYSTEM_MCG_C5_VALUE 0x03U /* MCG_C5 */
mbed_official 585:a1ed5b41f74f 223 /* MCG_C6: LOLIE0=0,PLLS=1,CME0=0,VDIV0=0 */
mbed_official 585:a1ed5b41f74f 224 #define SYSTEM_MCG_C6_VALUE 0x40U /* MCG_C6 */
mbed_official 585:a1ed5b41f74f 225 /* OSC0_CR: ERCLKEN=1,EREFSTEN=0,SC2P=0,SC4P=0,SC8P=0,SC16P=0 */
mbed_official 585:a1ed5b41f74f 226 #define SYSTEM_OSC0_CR_VALUE 0x80U /* OSC0_CR */
mbed_official 585:a1ed5b41f74f 227 /* SMC_PMCTRL: RUNM=0,STOPA=0,STOPM=0 */
mbed_official 585:a1ed5b41f74f 228 #define SYSTEM_SMC_PMCTRL_VALUE 0x00U /* SMC_PMCTRL */
mbed_official 585:a1ed5b41f74f 229 /* SIM_CLKDIV1: OUTDIV1=0,OUTDIV4=1 */
mbed_official 585:a1ed5b41f74f 230 #define SYSTEM_SIM_CLKDIV1_VALUE 0x00010000U /* SIM_CLKDIV1 */
mbed_official 585:a1ed5b41f74f 231 /* SIM_SOPT1: USBREGEN=0,USBSSTBY=0,USBVSTBY=0,OSC32KSEL=3 */
mbed_official 585:a1ed5b41f74f 232 #define SYSTEM_SIM_SOPT1_VALUE 0x000C0000U /* SIM_SOPT1 */
mbed_official 585:a1ed5b41f74f 233 /* SIM_SOPT2: UART0SRC=0,TPMSRC=1,USBSRC=0,PLLFLLSEL=1,CLKOUTSEL=0,RTCCLKOUTSEL=0 */
mbed_official 585:a1ed5b41f74f 234 #define SYSTEM_SIM_SOPT2_VALUE 0x01010000U /* SIM_SOPT2 */
mbed_official 585:a1ed5b41f74f 235 #elif (CLOCK_SETUP == 2)
mbed_official 585:a1ed5b41f74f 236 #define DEFAULT_SYSTEM_CLOCK 4000000U /* Default System clock value */
mbed_official 585:a1ed5b41f74f 237 #define MCG_MODE MCG_MODE_BLPI /* Clock generator mode */
mbed_official 585:a1ed5b41f74f 238 /* MCG_C1: CLKS=1,FRDIV=0,IREFS=1,IRCLKEN=1,IREFSTEN=0 */
mbed_official 585:a1ed5b41f74f 239 #define SYSTEM_MCG_C1_VALUE 0x46U /* MCG_C1 */
mbed_official 585:a1ed5b41f74f 240 /* MCG_C2: LOCRE0=0,FCFTRIM=0,RANGE0=2,HGO0=0,EREFS0=1,LP=1,IRCS=1 */
mbed_official 585:a1ed5b41f74f 241 #define SYSTEM_MCG_C2_VALUE 0x27U /* MCG_C2 */
mbed_official 585:a1ed5b41f74f 242 /* MCG_C4: DMX32=0,DRST_DRS=0,FCTRIM=0,SCFTRIM=0 */
mbed_official 585:a1ed5b41f74f 243 #define SYSTEM_MCG_C4_VALUE 0x00U /* MCG_C4 */
mbed_official 585:a1ed5b41f74f 244 /* MCG_SC: ATME=0,ATMS=0,ATMF=0,FLTPRSRV=0,FCRDIV=0,LOCS0=0 */
mbed_official 585:a1ed5b41f74f 245 #define SYSTEM_MCG_SC_VALUE 0x00U /* MCG_SC */
mbed_official 585:a1ed5b41f74f 246 /* MCG_C5: PLLCLKEN0=0,PLLSTEN0=0,PRDIV0=0 */
mbed_official 585:a1ed5b41f74f 247 #define SYSTEM_MCG_C5_VALUE 0x00U /* MCG_C5 */
mbed_official 585:a1ed5b41f74f 248 /* MCG_C6: LOLIE0=0,PLLS=0,CME0=0,VDIV0=0 */
mbed_official 585:a1ed5b41f74f 249 #define SYSTEM_MCG_C6_VALUE 0x00U /* MCG_C6 */
mbed_official 585:a1ed5b41f74f 250 /* OSC0_CR: ERCLKEN=1,EREFSTEN=0,SC2P=0,SC4P=0,SC8P=0,SC16P=0 */
mbed_official 585:a1ed5b41f74f 251 #define SYSTEM_OSC0_CR_VALUE 0x80U /* OSC0_CR */
mbed_official 585:a1ed5b41f74f 252 /* SMC_PMCTRL: RUNM=0,STOPA=0,STOPM=0 */
mbed_official 585:a1ed5b41f74f 253 #define SYSTEM_SMC_PMCTRL_VALUE 0x00U /* SMC_PMCTRL */
mbed_official 585:a1ed5b41f74f 254 /* SIM_CLKDIV1: OUTDIV1=0,OUTDIV4=4 */
mbed_official 585:a1ed5b41f74f 255 #define SYSTEM_SIM_CLKDIV1_VALUE 0x00040000U /* SIM_CLKDIV1 */
mbed_official 585:a1ed5b41f74f 256 /* SIM_SOPT1: USBREGEN=0,USBSSTBY=0,USBVSTBY=0,OSC32KSEL=3 */
mbed_official 585:a1ed5b41f74f 257 #define SYSTEM_SIM_SOPT1_VALUE 0x000C0000U /* SIM_SOPT1 */
mbed_official 585:a1ed5b41f74f 258 /* SIM_SOPT2: UART0SRC=0,TPMSRC=2,USBSRC=0,PLLFLLSEL=0,CLKOUTSEL=0,RTCCLKOUTSEL=0 */
mbed_official 585:a1ed5b41f74f 259 #define SYSTEM_SIM_SOPT2_VALUE 0x02000000U /* SIM_SOPT2 */
mbed_official 585:a1ed5b41f74f 260 #elif (CLOCK_SETUP == 3)
mbed_official 585:a1ed5b41f74f 261 #define DEFAULT_SYSTEM_CLOCK 4000000U /* Default System clock value */
mbed_official 585:a1ed5b41f74f 262 #define MCG_MODE MCG_MODE_BLPE /* Clock generator mode */
mbed_official 585:a1ed5b41f74f 263 /* MCG_C1: CLKS=2,FRDIV=3,IREFS=0,IRCLKEN=1,IREFSTEN=0 */
mbed_official 585:a1ed5b41f74f 264 #define SYSTEM_MCG_C1_VALUE 0x9AU /* MCG_C1 */
mbed_official 585:a1ed5b41f74f 265 /* MCG_C2: LOCRE0=0,FCFTRIM=0,RANGE0=2,HGO0=0,EREFS0=1,LP=1,IRCS=1 */
mbed_official 585:a1ed5b41f74f 266 #define SYSTEM_MCG_C2_VALUE 0x27U /* MCG_C2 */
mbed_official 585:a1ed5b41f74f 267 /* MCG_C4: DMX32=0,DRST_DRS=0,FCTRIM=0,SCFTRIM=0 */
mbed_official 585:a1ed5b41f74f 268 #define SYSTEM_MCG_C4_VALUE 0x00U /* MCG_C4 */
mbed_official 585:a1ed5b41f74f 269 /* MCG_SC: ATME=0,ATMS=0,ATMF=0,FLTPRSRV=0,FCRDIV=0,LOCS0=0 */
mbed_official 585:a1ed5b41f74f 270 #define SYSTEM_MCG_SC_VALUE 0x00U /* MCG_SC */
mbed_official 585:a1ed5b41f74f 271 /* MCG_C5: PLLCLKEN0=0,PLLSTEN0=0,PRDIV0=0 */
mbed_official 585:a1ed5b41f74f 272 #define SYSTEM_MCG_C5_VALUE 0x00U /* MCG_C5 */
mbed_official 585:a1ed5b41f74f 273 /* MCG_C6: LOLIE0=0,PLLS=0,CME0=0,VDIV0=0 */
mbed_official 585:a1ed5b41f74f 274 #define SYSTEM_MCG_C6_VALUE 0x00U /* MCG_C6 */
mbed_official 585:a1ed5b41f74f 275 /* OSC0_CR: ERCLKEN=1,EREFSTEN=0,SC2P=0,SC4P=0,SC8P=0,SC16P=0 */
mbed_official 585:a1ed5b41f74f 276 #define SYSTEM_OSC0_CR_VALUE 0x80U /* OSC0_CR */
mbed_official 585:a1ed5b41f74f 277 /* SMC_PMCTRL: RUNM=0,STOPA=0,STOPM=0 */
mbed_official 585:a1ed5b41f74f 278 #define SYSTEM_SMC_PMCTRL_VALUE 0x00U /* SMC_PMCTRL */
mbed_official 585:a1ed5b41f74f 279 /* SIM_CLKDIV1: OUTDIV1=1,OUTDIV4=3 */
mbed_official 585:a1ed5b41f74f 280 #define SYSTEM_SIM_CLKDIV1_VALUE 0x10030000U /* SIM_CLKDIV1 */
mbed_official 585:a1ed5b41f74f 281 /* SIM_SOPT1: USBREGEN=0,USBSSTBY=0,USBVSTBY=0,OSC32KSEL=3 */
mbed_official 585:a1ed5b41f74f 282 #define SYSTEM_SIM_SOPT1_VALUE 0x000C0000U /* SIM_SOPT1 */
mbed_official 585:a1ed5b41f74f 283 /* SIM_SOPT2: UART0SRC=0,TPMSRC=2,USBSRC=0,PLLFLLSEL=0,CLKOUTSEL=0,RTCCLKOUTSEL=0 */
mbed_official 585:a1ed5b41f74f 284 #define SYSTEM_SIM_SOPT2_VALUE 0x02000000U /* SIM_SOPT2 */
mbed_official 585:a1ed5b41f74f 285 #elif (CLOCK_SETUP == 4)
mbed_official 585:a1ed5b41f74f 286 #define DEFAULT_SYSTEM_CLOCK 48000000U /* Default System clock value */
mbed_official 585:a1ed5b41f74f 287 #define MCG_MODE MCG_MODE_PEE /* Clock generator mode */
mbed_official 585:a1ed5b41f74f 288 /* MCG_C1: CLKS=0,FRDIV=3,IREFS=0,IRCLKEN=1,IREFSTEN=0 */
mbed_official 585:a1ed5b41f74f 289 #define SYSTEM_MCG_C1_VALUE 0x1AU /* MCG_C1 */
mbed_official 585:a1ed5b41f74f 290 /* MCG_C2: LOCRE0=0,FCFTRIM=0,RANGE0=2,HGO0=0,EREFS0=1,LP=0,IRCS=0 */
mbed_official 585:a1ed5b41f74f 291 #define SYSTEM_MCG_C2_VALUE 0x24U /* MCG_C2 */
mbed_official 585:a1ed5b41f74f 292 /* MCG_C4: DMX32=0,DRST_DRS=0,FCTRIM=0,SCFTRIM=0 */
mbed_official 585:a1ed5b41f74f 293 #define SYSTEM_MCG_C4_VALUE 0x00U /* MCG_C4 */
mbed_official 585:a1ed5b41f74f 294 /* MCG_SC: ATME=0,ATMS=0,ATMF=0,FLTPRSRV=0,FCRDIV=0,LOCS0=0 */
mbed_official 585:a1ed5b41f74f 295 #define SYSTEM_MCG_SC_VALUE 0x00U /* MCG_SC */
mbed_official 585:a1ed5b41f74f 296 /* MCG_C5: PLLCLKEN0=0,PLLSTEN0=0,PRDIV0=3 */
mbed_official 585:a1ed5b41f74f 297 #define SYSTEM_MCG_C5_VALUE 0x03U /* MCG_C5 */
mbed_official 585:a1ed5b41f74f 298 /* MCG_C6: LOLIE0=0,PLLS=1,CME0=0,VDIV0=24 */
mbed_official 585:a1ed5b41f74f 299 #define SYSTEM_MCG_C6_VALUE 0x58U /* MCG_C6 */
mbed_official 585:a1ed5b41f74f 300 /* OSC0_CR: ERCLKEN=1,EREFSTEN=0,SC2P=0,SC4P=0,SC8P=0,SC16P=0 */
mbed_official 585:a1ed5b41f74f 301 #define SYSTEM_OSC0_CR_VALUE 0x80U /* OSC0_CR */
mbed_official 585:a1ed5b41f74f 302 /* SMC_PMCTRL: RUNM=0,STOPA=0,STOPM=0 */
mbed_official 585:a1ed5b41f74f 303 #define SYSTEM_SMC_PMCTRL_VALUE 0x00U /* SMC_PMCTRL */
mbed_official 585:a1ed5b41f74f 304 /* SIM_CLKDIV1: OUTDIV1=1,OUTDIV4=1 */
mbed_official 585:a1ed5b41f74f 305 #define SYSTEM_SIM_CLKDIV1_VALUE 0x10010000U /* SIM_CLKDIV1 */
mbed_official 585:a1ed5b41f74f 306 /* SIM_SOPT1: USBREGEN=0,USBSSTBY=0,USBVSTBY=0,OSC32KSEL=3 */
mbed_official 585:a1ed5b41f74f 307 #define SYSTEM_SIM_SOPT1_VALUE 0x000C0000U /* SIM_SOPT1 */
mbed_official 585:a1ed5b41f74f 308 /* SIM_SOPT2: UART0SRC=0,TPMSRC=1,USBSRC=0,PLLFLLSEL=1,CLKOUTSEL=0,RTCCLKOUTSEL=0 */
mbed_official 585:a1ed5b41f74f 309 #define SYSTEM_SIM_SOPT2_VALUE 0x01010000U /* SIM_SOPT2 */
mbed_official 585:a1ed5b41f74f 310 #else
mbed_official 585:a1ed5b41f74f 311 #error The selected clock setup is not supported.
mbed_official 585:a1ed5b41f74f 312 #endif
mbed_official 585:a1ed5b41f74f 313 #else //#ifdef CLOCK_SETUP
mbed_official 585:a1ed5b41f74f 314 #define DEFAULT_SYSTEM_CLOCK 20971520U /* Default System clock value */
mbed_official 585:a1ed5b41f74f 315 #endif //#ifdef CLOCK_SETUP
mbed_official 585:a1ed5b41f74f 316
mbed_official 585:a1ed5b41f74f 317
mbed_official 585:a1ed5b41f74f 318 /**
mbed_official 585:a1ed5b41f74f 319 * @brief System clock frequency (core clock)
mbed_official 585:a1ed5b41f74f 320 *
mbed_official 585:a1ed5b41f74f 321 * The system clock frequency supplied to the SysTick timer and the processor
mbed_official 585:a1ed5b41f74f 322 * core clock. This variable can be used by the user application to setup the
mbed_official 585:a1ed5b41f74f 323 * SysTick timer or configure other parameters. It may also be used by debugger to
mbed_official 585:a1ed5b41f74f 324 * query the frequency of the debug timer or configure the trace clock speed
mbed_official 585:a1ed5b41f74f 325 * SystemCoreClock is initialized with a correct predefined value.
mbed_official 585:a1ed5b41f74f 326 */
mbed_official 585:a1ed5b41f74f 327 extern uint32_t SystemCoreClock;
mbed_official 585:a1ed5b41f74f 328
mbed_official 585:a1ed5b41f74f 329 /**
mbed_official 585:a1ed5b41f74f 330 * @brief Setup the microcontroller system.
mbed_official 585:a1ed5b41f74f 331 *
mbed_official 585:a1ed5b41f74f 332 * Typically this function configures the oscillator (PLL) that is part of the
mbed_official 585:a1ed5b41f74f 333 * microcontroller device. For systems with variable clock speed it also updates
mbed_official 585:a1ed5b41f74f 334 * the variable SystemCoreClock. SystemInit is called from startup_device file.
mbed_official 585:a1ed5b41f74f 335 */
mbed_official 585:a1ed5b41f74f 336 void SystemInit (void);
mbed_official 585:a1ed5b41f74f 337
mbed_official 585:a1ed5b41f74f 338 /**
mbed_official 585:a1ed5b41f74f 339 * @brief Updates the SystemCoreClock variable.
mbed_official 585:a1ed5b41f74f 340 *
mbed_official 585:a1ed5b41f74f 341 * It must be called whenever the core clock is changed during program
mbed_official 585:a1ed5b41f74f 342 * execution. SystemCoreClockUpdate() evaluates the clock register settings and calculates
mbed_official 585:a1ed5b41f74f 343 * the current core clock.
mbed_official 585:a1ed5b41f74f 344 */
mbed_official 585:a1ed5b41f74f 345 void SystemCoreClockUpdate (void);
mbed_official 585:a1ed5b41f74f 346
mbed_official 585:a1ed5b41f74f 347 #ifdef __cplusplus
mbed_official 585:a1ed5b41f74f 348 }
mbed_official 585:a1ed5b41f74f 349 #endif
mbed_official 585:a1ed5b41f74f 350
mbed_official 585:a1ed5b41f74f 351 #endif /* #if !defined(SYSTEM_MKL26Z4_H_) */