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

Dependents:   hello SerialTestv11 SerialTestv12 Sierpinski ... more

mbed 2

This is the mbed 2 library. If you'd like to learn about Mbed OS please see the mbed-os docs.

Committer:
AnnaBridge
Date:
Wed Feb 20 20:53:29 2019 +0000
Revision:
172:65be27845400
Parent:
171:3a7713b1edbc
mbed library release version 165

Who changed what in which revision?

UserRevisionLine numberNew contents of line
AnnaBridge 145:64910690c574 1 /*
AnnaBridge 145:64910690c574 2 * Copyright (c) 2015, Freescale Semiconductor, Inc.
AnnaBridge 145:64910690c574 3 * All rights reserved.
AnnaBridge 145:64910690c574 4 *
AnnaBridge 145:64910690c574 5 * Redistribution and use in source and binary forms, with or without modification,
AnnaBridge 145:64910690c574 6 * are permitted provided that the following conditions are met:
AnnaBridge 145:64910690c574 7 *
AnnaBridge 145:64910690c574 8 * o Redistributions of source code must retain the above copyright notice, this list
AnnaBridge 145:64910690c574 9 * of conditions and the following disclaimer.
AnnaBridge 145:64910690c574 10 *
AnnaBridge 145:64910690c574 11 * o Redistributions in binary form must reproduce the above copyright notice, this
AnnaBridge 145:64910690c574 12 * list of conditions and the following disclaimer in the documentation and/or
AnnaBridge 145:64910690c574 13 * other materials provided with the distribution.
AnnaBridge 145:64910690c574 14 *
AnnaBridge 145:64910690c574 15 * o Neither the name of Freescale Semiconductor, Inc. nor the names of its
AnnaBridge 145:64910690c574 16 * contributors may be used to endorse or promote products derived from this
AnnaBridge 145:64910690c574 17 * software without specific prior written permission.
AnnaBridge 145:64910690c574 18 *
AnnaBridge 145:64910690c574 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
AnnaBridge 145:64910690c574 20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
AnnaBridge 145:64910690c574 21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
AnnaBridge 145:64910690c574 22 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
AnnaBridge 145:64910690c574 23 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
AnnaBridge 145:64910690c574 24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
AnnaBridge 145:64910690c574 25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
AnnaBridge 145:64910690c574 26 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
AnnaBridge 145:64910690c574 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
AnnaBridge 145:64910690c574 28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
AnnaBridge 145:64910690c574 29 */
AnnaBridge 145:64910690c574 30
AnnaBridge 145:64910690c574 31 #ifndef _FSL_SMC_H_
AnnaBridge 145:64910690c574 32 #define _FSL_SMC_H_
AnnaBridge 145:64910690c574 33
AnnaBridge 145:64910690c574 34 #include "fsl_common.h"
AnnaBridge 145:64910690c574 35
AnnaBridge 145:64910690c574 36 /*! @addtogroup smc */
AnnaBridge 145:64910690c574 37 /*! @{ */
AnnaBridge 145:64910690c574 38
AnnaBridge 145:64910690c574 39
AnnaBridge 145:64910690c574 40 /*******************************************************************************
AnnaBridge 145:64910690c574 41 * Definitions
AnnaBridge 145:64910690c574 42 ******************************************************************************/
AnnaBridge 145:64910690c574 43
AnnaBridge 145:64910690c574 44 /*! @name Driver version */
AnnaBridge 145:64910690c574 45 /*@{*/
AnnaBridge 145:64910690c574 46 /*! @brief SMC driver version 2.0.3. */
AnnaBridge 145:64910690c574 47 #define FSL_SMC_DRIVER_VERSION (MAKE_VERSION(2, 0, 3))
AnnaBridge 145:64910690c574 48 /*@}*/
AnnaBridge 145:64910690c574 49
AnnaBridge 145:64910690c574 50 /*!
AnnaBridge 145:64910690c574 51 * @brief Power Modes Protection
AnnaBridge 145:64910690c574 52 */
AnnaBridge 145:64910690c574 53 typedef enum _smc_power_mode_protection
AnnaBridge 145:64910690c574 54 {
AnnaBridge 145:64910690c574 55 #if (defined(FSL_FEATURE_SMC_HAS_VERY_LOW_LEAKAGE_STOP_MODE) && FSL_FEATURE_SMC_HAS_VERY_LOW_LEAKAGE_STOP_MODE)
AnnaBridge 145:64910690c574 56 kSMC_AllowPowerModeVlls = SMC_PMPROT_AVLLS_MASK, /*!< Allow Very-low-leakage Stop Mode. */
AnnaBridge 145:64910690c574 57 #endif
AnnaBridge 145:64910690c574 58 #if (defined(FSL_FEATURE_SMC_HAS_LOW_LEAKAGE_STOP_MODE) && FSL_FEATURE_SMC_HAS_LOW_LEAKAGE_STOP_MODE)
AnnaBridge 145:64910690c574 59 kSMC_AllowPowerModeLls = SMC_PMPROT_ALLS_MASK, /*!< Allow Low-leakage Stop Mode. */
AnnaBridge 145:64910690c574 60 #endif /* FSL_FEATURE_SMC_HAS_LOW_LEAKAGE_STOP_MODE */
AnnaBridge 145:64910690c574 61 kSMC_AllowPowerModeVlp = SMC_PMPROT_AVLP_MASK, /*!< Allow Very-Low-power Mode. */
AnnaBridge 145:64910690c574 62 #if (defined(FSL_FEATURE_SMC_HAS_HIGH_SPEED_RUN_MODE) && FSL_FEATURE_SMC_HAS_HIGH_SPEED_RUN_MODE)
AnnaBridge 145:64910690c574 63 kSMC_AllowPowerModeHsrun = SMC_PMPROT_AHSRUN_MASK, /*!< Allow High-speed Run mode. */
AnnaBridge 145:64910690c574 64 #endif /* FSL_FEATURE_SMC_HAS_HIGH_SPEED_RUN_MODE */
AnnaBridge 145:64910690c574 65 kSMC_AllowPowerModeAll = (0U
AnnaBridge 145:64910690c574 66 #if (defined(FSL_FEATURE_SMC_HAS_VERY_LOW_LEAKAGE_STOP_MODE) && FSL_FEATURE_SMC_HAS_VERY_LOW_LEAKAGE_STOP_MODE)
AnnaBridge 145:64910690c574 67 |
AnnaBridge 145:64910690c574 68 SMC_PMPROT_AVLLS_MASK
AnnaBridge 145:64910690c574 69 #endif
AnnaBridge 145:64910690c574 70 #if (defined(FSL_FEATURE_SMC_HAS_LOW_LEAKAGE_STOP_MODE) && FSL_FEATURE_SMC_HAS_LOW_LEAKAGE_STOP_MODE)
AnnaBridge 145:64910690c574 71 |
AnnaBridge 145:64910690c574 72 SMC_PMPROT_ALLS_MASK
AnnaBridge 145:64910690c574 73 #endif /* FSL_FEATURE_SMC_HAS_LOW_LEAKAGE_STOP_MODE */
AnnaBridge 145:64910690c574 74 |
AnnaBridge 145:64910690c574 75 SMC_PMPROT_AVLP_MASK
AnnaBridge 145:64910690c574 76 #if (defined(FSL_FEATURE_SMC_HAS_HIGH_SPEED_RUN_MODE) && FSL_FEATURE_SMC_HAS_HIGH_SPEED_RUN_MODE)
AnnaBridge 145:64910690c574 77 |
AnnaBridge 145:64910690c574 78 kSMC_AllowPowerModeHsrun
AnnaBridge 145:64910690c574 79 #endif /* FSL_FEATURE_SMC_HAS_HIGH_SPEED_RUN_MODE */
AnnaBridge 145:64910690c574 80 ) /*!< Allow all power mode. */
AnnaBridge 145:64910690c574 81 } smc_power_mode_protection_t;
AnnaBridge 145:64910690c574 82
AnnaBridge 145:64910690c574 83 /*!
AnnaBridge 145:64910690c574 84 * @brief Power Modes in PMSTAT
AnnaBridge 145:64910690c574 85 */
AnnaBridge 145:64910690c574 86 typedef enum _smc_power_state
AnnaBridge 145:64910690c574 87 {
AnnaBridge 145:64910690c574 88 kSMC_PowerStateRun = 0x01U << 0U, /*!< 0000_0001 - Current power mode is RUN */
AnnaBridge 145:64910690c574 89 kSMC_PowerStateStop = 0x01U << 1U, /*!< 0000_0010 - Current power mode is STOP */
AnnaBridge 145:64910690c574 90 kSMC_PowerStateVlpr = 0x01U << 2U, /*!< 0000_0100 - Current power mode is VLPR */
AnnaBridge 145:64910690c574 91 kSMC_PowerStateVlpw = 0x01U << 3U, /*!< 0000_1000 - Current power mode is VLPW */
AnnaBridge 145:64910690c574 92 kSMC_PowerStateVlps = 0x01U << 4U, /*!< 0001_0000 - Current power mode is VLPS */
AnnaBridge 145:64910690c574 93 #if (defined(FSL_FEATURE_SMC_HAS_LOW_LEAKAGE_STOP_MODE) && FSL_FEATURE_SMC_HAS_LOW_LEAKAGE_STOP_MODE)
AnnaBridge 145:64910690c574 94 kSMC_PowerStateLls = 0x01U << 5U, /*!< 0010_0000 - Current power mode is LLS */
AnnaBridge 145:64910690c574 95 #endif /* FSL_FEATURE_SMC_HAS_LOW_LEAKAGE_STOP_MODE */
AnnaBridge 145:64910690c574 96 #if (defined(FSL_FEATURE_SMC_HAS_VERY_LOW_LEAKAGE_STOP_MODE) && FSL_FEATURE_SMC_HAS_VERY_LOW_LEAKAGE_STOP_MODE)
AnnaBridge 145:64910690c574 97 kSMC_PowerStateVlls = 0x01U << 6U, /*!< 0100_0000 - Current power mode is VLLS */
AnnaBridge 145:64910690c574 98 #endif
AnnaBridge 145:64910690c574 99 #if (defined(FSL_FEATURE_SMC_HAS_HIGH_SPEED_RUN_MODE) && FSL_FEATURE_SMC_HAS_HIGH_SPEED_RUN_MODE)
AnnaBridge 145:64910690c574 100 kSMC_PowerStateHsrun = 0x01U << 7U /*!< 1000_0000 - Current power mode is HSRUN */
AnnaBridge 145:64910690c574 101 #endif /* FSL_FEATURE_SMC_HAS_HIGH_SPEED_RUN_MODE */
AnnaBridge 145:64910690c574 102 } smc_power_state_t;
AnnaBridge 145:64910690c574 103
AnnaBridge 145:64910690c574 104 /*!
AnnaBridge 145:64910690c574 105 * @brief Run mode definition
AnnaBridge 145:64910690c574 106 */
AnnaBridge 145:64910690c574 107 typedef enum _smc_run_mode
AnnaBridge 145:64910690c574 108 {
AnnaBridge 145:64910690c574 109 kSMC_RunNormal = 0U, /*!< Normal RUN mode. */
AnnaBridge 145:64910690c574 110 kSMC_RunVlpr = 2U, /*!< Very-low-power RUN mode. */
AnnaBridge 145:64910690c574 111 #if (defined(FSL_FEATURE_SMC_HAS_HIGH_SPEED_RUN_MODE) && FSL_FEATURE_SMC_HAS_HIGH_SPEED_RUN_MODE)
AnnaBridge 145:64910690c574 112 kSMC_Hsrun = 3U /*!< High-speed Run mode (HSRUN). */
AnnaBridge 145:64910690c574 113 #endif /* FSL_FEATURE_SMC_HAS_HIGH_SPEED_RUN_MODE */
AnnaBridge 145:64910690c574 114 } smc_run_mode_t;
AnnaBridge 145:64910690c574 115
AnnaBridge 145:64910690c574 116 /*!
AnnaBridge 145:64910690c574 117 * @brief Stop mode definition
AnnaBridge 145:64910690c574 118 */
AnnaBridge 145:64910690c574 119 typedef enum _smc_stop_mode
AnnaBridge 145:64910690c574 120 {
AnnaBridge 145:64910690c574 121 kSMC_StopNormal = 0U, /*!< Normal STOP mode. */
AnnaBridge 145:64910690c574 122 kSMC_StopVlps = 2U, /*!< Very-low-power STOP mode. */
AnnaBridge 145:64910690c574 123 #if (defined(FSL_FEATURE_SMC_HAS_LOW_LEAKAGE_STOP_MODE) && FSL_FEATURE_SMC_HAS_LOW_LEAKAGE_STOP_MODE)
AnnaBridge 145:64910690c574 124 kSMC_StopLls = 3U, /*!< Low-leakage Stop mode. */
AnnaBridge 145:64910690c574 125 #endif /* FSL_FEATURE_SMC_HAS_LOW_LEAKAGE_STOP_MODE */
AnnaBridge 145:64910690c574 126 #if (defined(FSL_FEATURE_SMC_HAS_VERY_LOW_LEAKAGE_STOP_MODE) && FSL_FEATURE_SMC_HAS_VERY_LOW_LEAKAGE_STOP_MODE)
AnnaBridge 145:64910690c574 127 kSMC_StopVlls = 4U /*!< Very-low-leakage Stop mode. */
AnnaBridge 145:64910690c574 128 #endif
AnnaBridge 145:64910690c574 129 } smc_stop_mode_t;
AnnaBridge 145:64910690c574 130
AnnaBridge 145:64910690c574 131 #if (defined(FSL_FEATURE_SMC_USE_VLLSCTRL_REG) && FSL_FEATURE_SMC_USE_VLLSCTRL_REG) || \
AnnaBridge 145:64910690c574 132 (defined(FSL_FEATURE_SMC_USE_STOPCTRL_VLLSM) && FSL_FEATURE_SMC_USE_STOPCTRL_VLLSM) || \
AnnaBridge 145:64910690c574 133 (defined(FSL_FEATURE_SMC_HAS_LLS_SUBMODE) && FSL_FEATURE_SMC_HAS_LLS_SUBMODE)
AnnaBridge 145:64910690c574 134 /*!
AnnaBridge 145:64910690c574 135 * @brief VLLS/LLS stop sub mode definition
AnnaBridge 145:64910690c574 136 */
AnnaBridge 145:64910690c574 137 typedef enum _smc_stop_submode
AnnaBridge 145:64910690c574 138 {
AnnaBridge 145:64910690c574 139 kSMC_StopSub0 = 0U, /*!< Stop submode 0, for VLLS0/LLS0. */
AnnaBridge 145:64910690c574 140 kSMC_StopSub1 = 1U, /*!< Stop submode 1, for VLLS1/LLS1. */
AnnaBridge 145:64910690c574 141 kSMC_StopSub2 = 2U, /*!< Stop submode 2, for VLLS2/LLS2. */
AnnaBridge 145:64910690c574 142 kSMC_StopSub3 = 3U /*!< Stop submode 3, for VLLS3/LLS3. */
AnnaBridge 145:64910690c574 143 } smc_stop_submode_t;
AnnaBridge 145:64910690c574 144 #endif
AnnaBridge 145:64910690c574 145
AnnaBridge 145:64910690c574 146 /*!
AnnaBridge 145:64910690c574 147 * @brief Partial STOP option
AnnaBridge 145:64910690c574 148 */
AnnaBridge 145:64910690c574 149 typedef enum _smc_partial_stop_mode
AnnaBridge 145:64910690c574 150 {
AnnaBridge 145:64910690c574 151 kSMC_PartialStop = 0U, /*!< STOP - Normal Stop mode*/
AnnaBridge 145:64910690c574 152 kSMC_PartialStop1 = 1U, /*!< Partial Stop with both system and bus clocks disabled*/
AnnaBridge 145:64910690c574 153 kSMC_PartialStop2 = 2U, /*!< Partial Stop with system clock disabled and bus clock enabled*/
AnnaBridge 145:64910690c574 154 } smc_partial_stop_option_t;
AnnaBridge 145:64910690c574 155
AnnaBridge 145:64910690c574 156 /*!
AnnaBridge 145:64910690c574 157 * @brief SMC configuration status.
AnnaBridge 145:64910690c574 158 */
AnnaBridge 145:64910690c574 159 enum _smc_status
AnnaBridge 145:64910690c574 160 {
AnnaBridge 145:64910690c574 161 kStatus_SMC_StopAbort = MAKE_STATUS(kStatusGroup_POWER, 0) /*!< Entering Stop mode is abort*/
AnnaBridge 145:64910690c574 162 };
AnnaBridge 145:64910690c574 163
AnnaBridge 145:64910690c574 164 #if (defined(FSL_FEATURE_SMC_HAS_VERID) && FSL_FEATURE_SMC_HAS_VERID)
AnnaBridge 145:64910690c574 165 /*!
AnnaBridge 145:64910690c574 166 * @brief IP version ID definition.
AnnaBridge 145:64910690c574 167 */
AnnaBridge 145:64910690c574 168 typedef struct _smc_version_id
AnnaBridge 145:64910690c574 169 {
AnnaBridge 145:64910690c574 170 uint16_t feature; /*!< Feature Specification Number. */
AnnaBridge 145:64910690c574 171 uint8_t minor; /*!< Minor version number. */
AnnaBridge 145:64910690c574 172 uint8_t major; /*!< Major version number. */
AnnaBridge 145:64910690c574 173 } smc_version_id_t;
AnnaBridge 145:64910690c574 174 #endif /* FSL_FEATURE_SMC_HAS_VERID */
AnnaBridge 145:64910690c574 175
AnnaBridge 145:64910690c574 176 #if (defined(FSL_FEATURE_SMC_HAS_PARAM) && FSL_FEATURE_SMC_HAS_PARAM)
AnnaBridge 145:64910690c574 177 /*!
AnnaBridge 145:64910690c574 178 * @brief IP parameter definition.
AnnaBridge 145:64910690c574 179 */
AnnaBridge 145:64910690c574 180 typedef struct _smc_param
AnnaBridge 145:64910690c574 181 {
AnnaBridge 145:64910690c574 182 bool hsrunEnable; /*!< HSRUN mode enable. */
AnnaBridge 145:64910690c574 183 bool llsEnable; /*!< LLS mode enable. */
AnnaBridge 145:64910690c574 184 bool lls2Enable; /*!< LLS2 mode enable. */
AnnaBridge 145:64910690c574 185 bool vlls0Enable; /*!< VLLS0 mode enable. */
AnnaBridge 145:64910690c574 186 } smc_param_t;
AnnaBridge 145:64910690c574 187 #endif /* FSL_FEATURE_SMC_HAS_PARAM */
AnnaBridge 145:64910690c574 188
AnnaBridge 145:64910690c574 189 #if (defined(FSL_FEATURE_SMC_HAS_LLS_SUBMODE) && FSL_FEATURE_SMC_HAS_LLS_SUBMODE) || \
AnnaBridge 145:64910690c574 190 (defined(FSL_FEATURE_SMC_HAS_LPOPO) && FSL_FEATURE_SMC_HAS_LPOPO)
AnnaBridge 145:64910690c574 191 /*!
AnnaBridge 145:64910690c574 192 * @brief SMC Low-Leakage Stop power mode configuration.
AnnaBridge 145:64910690c574 193 */
AnnaBridge 145:64910690c574 194 typedef struct _smc_power_mode_lls_config
AnnaBridge 145:64910690c574 195 {
AnnaBridge 145:64910690c574 196 #if (defined(FSL_FEATURE_SMC_HAS_LLS_SUBMODE) && FSL_FEATURE_SMC_HAS_LLS_SUBMODE)
AnnaBridge 145:64910690c574 197 smc_stop_submode_t subMode; /*!< Low-leakage Stop sub-mode */
AnnaBridge 145:64910690c574 198 #endif
AnnaBridge 145:64910690c574 199 #if (defined(FSL_FEATURE_SMC_HAS_LPOPO) && FSL_FEATURE_SMC_HAS_LPOPO)
AnnaBridge 145:64910690c574 200 bool enableLpoClock; /*!< Enable LPO clock in LLS mode */
AnnaBridge 145:64910690c574 201 #endif
AnnaBridge 145:64910690c574 202 } smc_power_mode_lls_config_t;
AnnaBridge 145:64910690c574 203 #endif /* (FSL_FEATURE_SMC_HAS_LLS_SUBMODE || FSL_FEATURE_SMC_HAS_LPOPO) */
AnnaBridge 145:64910690c574 204
AnnaBridge 145:64910690c574 205 #if (defined(FSL_FEATURE_SMC_HAS_VERY_LOW_LEAKAGE_STOP_MODE) && FSL_FEATURE_SMC_HAS_VERY_LOW_LEAKAGE_STOP_MODE)
AnnaBridge 145:64910690c574 206 /*!
AnnaBridge 145:64910690c574 207 * @brief SMC Very Low-Leakage Stop power mode configuration.
AnnaBridge 145:64910690c574 208 */
AnnaBridge 145:64910690c574 209 typedef struct _smc_power_mode_vlls_config
AnnaBridge 145:64910690c574 210 {
AnnaBridge 145:64910690c574 211 #if (defined(FSL_FEATURE_SMC_USE_VLLSCTRL_REG) && FSL_FEATURE_SMC_USE_VLLSCTRL_REG) || \
AnnaBridge 145:64910690c574 212 (defined(FSL_FEATURE_SMC_USE_STOPCTRL_VLLSM) && FSL_FEATURE_SMC_USE_STOPCTRL_VLLSM) || \
AnnaBridge 145:64910690c574 213 (defined(FSL_FEATURE_SMC_HAS_LLS_SUBMODE) && FSL_FEATURE_SMC_HAS_LLS_SUBMODE)
AnnaBridge 145:64910690c574 214 smc_stop_submode_t subMode; /*!< Very Low-leakage Stop sub-mode */
AnnaBridge 145:64910690c574 215 #endif
AnnaBridge 145:64910690c574 216 #if (defined(FSL_FEATURE_SMC_HAS_PORPO) && FSL_FEATURE_SMC_HAS_PORPO)
AnnaBridge 145:64910690c574 217 bool enablePorDetectInVlls0; /*!< Enable Power on reset detect in VLLS mode */
AnnaBridge 145:64910690c574 218 #endif
AnnaBridge 145:64910690c574 219 #if (defined(FSL_FEATURE_SMC_HAS_RAM2_POWER_OPTION) && FSL_FEATURE_SMC_HAS_RAM2_POWER_OPTION)
AnnaBridge 145:64910690c574 220 bool enableRam2InVlls2; /*!< Enable RAM2 power in VLLS2 */
AnnaBridge 145:64910690c574 221 #endif
AnnaBridge 145:64910690c574 222 #if (defined(FSL_FEATURE_SMC_HAS_LPOPO) && FSL_FEATURE_SMC_HAS_LPOPO)
AnnaBridge 145:64910690c574 223 bool enableLpoClock; /*!< Enable LPO clock in VLLS mode */
AnnaBridge 145:64910690c574 224 #endif
AnnaBridge 145:64910690c574 225 } smc_power_mode_vlls_config_t;
AnnaBridge 145:64910690c574 226 #endif
AnnaBridge 145:64910690c574 227
AnnaBridge 145:64910690c574 228 /*******************************************************************************
AnnaBridge 145:64910690c574 229 * API
AnnaBridge 145:64910690c574 230 ******************************************************************************/
AnnaBridge 145:64910690c574 231
AnnaBridge 145:64910690c574 232 #if defined(__cplusplus)
AnnaBridge 145:64910690c574 233 extern "C" {
AnnaBridge 145:64910690c574 234 #endif /* __cplusplus */
AnnaBridge 145:64910690c574 235
AnnaBridge 145:64910690c574 236 /*! @name System mode controller APIs*/
AnnaBridge 145:64910690c574 237 /*@{*/
AnnaBridge 145:64910690c574 238
AnnaBridge 145:64910690c574 239 #if (defined(FSL_FEATURE_SMC_HAS_VERID) && FSL_FEATURE_SMC_HAS_VERID)
AnnaBridge 145:64910690c574 240 /*!
AnnaBridge 145:64910690c574 241 * @brief Gets the SMC version ID.
AnnaBridge 145:64910690c574 242 *
AnnaBridge 145:64910690c574 243 * This function gets the SMC version ID, including major version number,
AnnaBridge 145:64910690c574 244 * minor version number, and feature specification number.
AnnaBridge 145:64910690c574 245 *
AnnaBridge 145:64910690c574 246 * @param base SMC peripheral base address.
AnnaBridge 145:64910690c574 247 * @param versionId Pointer to the version ID structure.
AnnaBridge 145:64910690c574 248 */
AnnaBridge 145:64910690c574 249 static inline void SMC_GetVersionId(SMC_Type *base, smc_version_id_t *versionId)
AnnaBridge 145:64910690c574 250 {
AnnaBridge 145:64910690c574 251 *((uint32_t *)versionId) = base->VERID;
AnnaBridge 145:64910690c574 252 }
AnnaBridge 145:64910690c574 253 #endif /* FSL_FEATURE_SMC_HAS_VERID */
AnnaBridge 145:64910690c574 254
AnnaBridge 145:64910690c574 255 #if (defined(FSL_FEATURE_SMC_HAS_PARAM) && FSL_FEATURE_SMC_HAS_PARAM)
AnnaBridge 145:64910690c574 256 /*!
AnnaBridge 145:64910690c574 257 * @brief Gets the SMC parameter.
AnnaBridge 145:64910690c574 258 *
AnnaBridge 145:64910690c574 259 * This function gets the SMC parameter including the enabled power mdoes.
AnnaBridge 145:64910690c574 260 *
AnnaBridge 145:64910690c574 261 * @param base SMC peripheral base address.
AnnaBridge 145:64910690c574 262 * @param param Pointer to the SMC param structure.
AnnaBridge 145:64910690c574 263 */
AnnaBridge 145:64910690c574 264 void SMC_GetParam(SMC_Type *base, smc_param_t *param);
AnnaBridge 145:64910690c574 265 #endif
AnnaBridge 145:64910690c574 266
AnnaBridge 145:64910690c574 267 /*!
AnnaBridge 145:64910690c574 268 * @brief Configures all power mode protection settings.
AnnaBridge 145:64910690c574 269 *
AnnaBridge 145:64910690c574 270 * This function configures the power mode protection settings for
AnnaBridge 145:64910690c574 271 * supported power modes in the specified chip family. The available power modes
AnnaBridge 145:64910690c574 272 * are defined in the smc_power_mode_protection_t. This should be done at an early
AnnaBridge 145:64910690c574 273 * system level initialization stage. See the reference manual for details.
AnnaBridge 145:64910690c574 274 * This register can only write once after the power reset.
AnnaBridge 145:64910690c574 275 *
AnnaBridge 145:64910690c574 276 * The allowed modes are passed as bit map. For example, to allow LLS and VLLS,
AnnaBridge 145:64910690c574 277 * use SMC_SetPowerModeProtection(kSMC_AllowPowerModeVlls | kSMC_AllowPowerModeVlps).
AnnaBridge 145:64910690c574 278 * To allow all modes, use SMC_SetPowerModeProtection(kSMC_AllowPowerModeAll).
AnnaBridge 145:64910690c574 279 *
AnnaBridge 145:64910690c574 280 * @param base SMC peripheral base address.
AnnaBridge 145:64910690c574 281 * @param allowedModes Bitmap of the allowed power modes.
AnnaBridge 145:64910690c574 282 */
AnnaBridge 145:64910690c574 283 static inline void SMC_SetPowerModeProtection(SMC_Type *base, uint8_t allowedModes)
AnnaBridge 145:64910690c574 284 {
AnnaBridge 145:64910690c574 285 base->PMPROT = allowedModes;
AnnaBridge 145:64910690c574 286 }
AnnaBridge 145:64910690c574 287
AnnaBridge 145:64910690c574 288 /*!
AnnaBridge 145:64910690c574 289 * @brief Gets the current power mode status.
AnnaBridge 145:64910690c574 290 *
AnnaBridge 145:64910690c574 291 * This function returns the current power mode status. After the application
AnnaBridge 145:64910690c574 292 * switches the power mode, it should always check the status to check whether it
AnnaBridge 145:64910690c574 293 * runs into the specified mode or not. The application should check
AnnaBridge 145:64910690c574 294 * this mode before switching to a different mode. The system requires that
AnnaBridge 145:64910690c574 295 * only certain modes can switch to other specific modes. See the
AnnaBridge 145:64910690c574 296 * reference manual for details and the smc_power_state_t for information about
AnnaBridge 145:64910690c574 297 * the power status.
AnnaBridge 145:64910690c574 298 *
AnnaBridge 145:64910690c574 299 * @param base SMC peripheral base address.
AnnaBridge 145:64910690c574 300 * @return Current power mode status.
AnnaBridge 145:64910690c574 301 */
AnnaBridge 145:64910690c574 302 static inline smc_power_state_t SMC_GetPowerModeState(SMC_Type *base)
AnnaBridge 145:64910690c574 303 {
AnnaBridge 145:64910690c574 304 return (smc_power_state_t)base->PMSTAT;
AnnaBridge 145:64910690c574 305 }
AnnaBridge 145:64910690c574 306
AnnaBridge 145:64910690c574 307 /*!
AnnaBridge 145:64910690c574 308 * @brief Prepares to enter stop modes.
AnnaBridge 145:64910690c574 309 *
AnnaBridge 145:64910690c574 310 * This function should be called before entering STOP/VLPS/LLS/VLLS modes.
AnnaBridge 145:64910690c574 311 */
AnnaBridge 145:64910690c574 312 void SMC_PreEnterStopModes(void);
AnnaBridge 145:64910690c574 313
AnnaBridge 145:64910690c574 314 /*!
AnnaBridge 145:64910690c574 315 * @brief Recovers after wake up from stop modes.
AnnaBridge 145:64910690c574 316 *
AnnaBridge 145:64910690c574 317 * This function should be called after wake up from STOP/VLPS/LLS/VLLS modes.
AnnaBridge 145:64910690c574 318 * It is used with @ref SMC_PreEnterStopModes.
AnnaBridge 145:64910690c574 319 */
AnnaBridge 145:64910690c574 320 void SMC_PostExitStopModes(void);
AnnaBridge 145:64910690c574 321
AnnaBridge 145:64910690c574 322 /*!
AnnaBridge 145:64910690c574 323 * @brief Prepares to enter wait modes.
AnnaBridge 145:64910690c574 324 *
AnnaBridge 145:64910690c574 325 * This function should be called before entering WAIT/VLPW modes.
AnnaBridge 145:64910690c574 326 */
AnnaBridge 145:64910690c574 327 static inline void SMC_PreEnterWaitModes(void)
AnnaBridge 145:64910690c574 328 {
AnnaBridge 145:64910690c574 329 __disable_irq();
AnnaBridge 145:64910690c574 330 __ISB();
AnnaBridge 145:64910690c574 331 }
AnnaBridge 145:64910690c574 332
AnnaBridge 145:64910690c574 333 /*!
AnnaBridge 145:64910690c574 334 * @brief Recovers after wake up from stop modes.
AnnaBridge 145:64910690c574 335 *
AnnaBridge 145:64910690c574 336 * This function should be called after wake up from WAIT/VLPW modes.
AnnaBridge 145:64910690c574 337 * It is used with @ref SMC_PreEnterWaitModes.
AnnaBridge 145:64910690c574 338 */
AnnaBridge 145:64910690c574 339 static inline void SMC_PostExitWaitModes(void)
AnnaBridge 145:64910690c574 340 {
AnnaBridge 145:64910690c574 341 __enable_irq();
AnnaBridge 145:64910690c574 342 __ISB();
AnnaBridge 145:64910690c574 343 }
AnnaBridge 145:64910690c574 344
AnnaBridge 145:64910690c574 345 /*!
AnnaBridge 145:64910690c574 346 * @brief Configures the system to RUN power mode.
AnnaBridge 145:64910690c574 347 *
AnnaBridge 145:64910690c574 348 * @param base SMC peripheral base address.
AnnaBridge 145:64910690c574 349 * @return SMC configuration error code.
AnnaBridge 145:64910690c574 350 */
AnnaBridge 145:64910690c574 351 status_t SMC_SetPowerModeRun(SMC_Type *base);
AnnaBridge 145:64910690c574 352
AnnaBridge 145:64910690c574 353 #if (defined(FSL_FEATURE_SMC_HAS_HIGH_SPEED_RUN_MODE) && FSL_FEATURE_SMC_HAS_HIGH_SPEED_RUN_MODE)
AnnaBridge 145:64910690c574 354 /*!
AnnaBridge 145:64910690c574 355 * @brief Configures the system to HSRUN power mode.
AnnaBridge 145:64910690c574 356 *
AnnaBridge 145:64910690c574 357 * @param base SMC peripheral base address.
AnnaBridge 145:64910690c574 358 * @return SMC configuration error code.
AnnaBridge 145:64910690c574 359 */
AnnaBridge 145:64910690c574 360 status_t SMC_SetPowerModeHsrun(SMC_Type *base);
AnnaBridge 145:64910690c574 361 #endif /* FSL_FEATURE_SMC_HAS_HIGH_SPEED_RUN_MODE */
AnnaBridge 145:64910690c574 362
AnnaBridge 145:64910690c574 363 /*!
AnnaBridge 145:64910690c574 364 * @brief Configures the system to WAIT power mode.
AnnaBridge 145:64910690c574 365 *
AnnaBridge 145:64910690c574 366 * @param base SMC peripheral base address.
AnnaBridge 145:64910690c574 367 * @return SMC configuration error code.
AnnaBridge 145:64910690c574 368 */
AnnaBridge 145:64910690c574 369 status_t SMC_SetPowerModeWait(SMC_Type *base);
AnnaBridge 145:64910690c574 370
AnnaBridge 145:64910690c574 371 /*!
AnnaBridge 145:64910690c574 372 * @brief Configures the system to Stop power mode.
AnnaBridge 145:64910690c574 373 *
AnnaBridge 145:64910690c574 374 * @param base SMC peripheral base address.
AnnaBridge 145:64910690c574 375 * @param option Partial Stop mode option.
AnnaBridge 145:64910690c574 376 * @return SMC configuration error code.
AnnaBridge 145:64910690c574 377 */
AnnaBridge 145:64910690c574 378 status_t SMC_SetPowerModeStop(SMC_Type *base, smc_partial_stop_option_t option);
AnnaBridge 145:64910690c574 379
AnnaBridge 145:64910690c574 380 #if (defined(FSL_FEATURE_SMC_HAS_LPWUI) && FSL_FEATURE_SMC_HAS_LPWUI)
AnnaBridge 145:64910690c574 381 /*!
AnnaBridge 145:64910690c574 382 * @brief Configures the system to VLPR power mode.
AnnaBridge 145:64910690c574 383 *
AnnaBridge 145:64910690c574 384 * @param base SMC peripheral base address.
AnnaBridge 145:64910690c574 385 * @param wakeupMode Enter Normal Run mode if true, else stay in VLPR mode.
AnnaBridge 145:64910690c574 386 * @return SMC configuration error code.
AnnaBridge 145:64910690c574 387 */
AnnaBridge 145:64910690c574 388 status_t SMC_SetPowerModeVlpr(SMC_Type *base, bool wakeupMode);
AnnaBridge 145:64910690c574 389 #else
AnnaBridge 145:64910690c574 390 /*!
AnnaBridge 145:64910690c574 391 * @brief Configures the system to VLPR power mode.
AnnaBridge 145:64910690c574 392 *
AnnaBridge 145:64910690c574 393 * @param base SMC peripheral base address.
AnnaBridge 145:64910690c574 394 * @return SMC configuration error code.
AnnaBridge 145:64910690c574 395 */
AnnaBridge 145:64910690c574 396 status_t SMC_SetPowerModeVlpr(SMC_Type *base);
AnnaBridge 145:64910690c574 397 #endif /* FSL_FEATURE_SMC_HAS_LPWUI */
AnnaBridge 145:64910690c574 398
AnnaBridge 145:64910690c574 399 /*!
AnnaBridge 145:64910690c574 400 * @brief Configures the system to VLPW power mode.
AnnaBridge 145:64910690c574 401 *
AnnaBridge 145:64910690c574 402 * @param base SMC peripheral base address.
AnnaBridge 145:64910690c574 403 * @return SMC configuration error code.
AnnaBridge 145:64910690c574 404 */
AnnaBridge 145:64910690c574 405 status_t SMC_SetPowerModeVlpw(SMC_Type *base);
AnnaBridge 145:64910690c574 406
AnnaBridge 145:64910690c574 407 /*!
AnnaBridge 145:64910690c574 408 * @brief Configures the system to VLPS power mode.
AnnaBridge 145:64910690c574 409 *
AnnaBridge 145:64910690c574 410 * @param base SMC peripheral base address.
AnnaBridge 145:64910690c574 411 * @return SMC configuration error code.
AnnaBridge 145:64910690c574 412 */
AnnaBridge 145:64910690c574 413 status_t SMC_SetPowerModeVlps(SMC_Type *base);
AnnaBridge 145:64910690c574 414
AnnaBridge 145:64910690c574 415 #if (defined(FSL_FEATURE_SMC_HAS_LOW_LEAKAGE_STOP_MODE) && FSL_FEATURE_SMC_HAS_LOW_LEAKAGE_STOP_MODE)
AnnaBridge 145:64910690c574 416 #if ((defined(FSL_FEATURE_SMC_HAS_LLS_SUBMODE) && FSL_FEATURE_SMC_HAS_LLS_SUBMODE) || \
AnnaBridge 145:64910690c574 417 (defined(FSL_FEATURE_SMC_HAS_LPOPO) && FSL_FEATURE_SMC_HAS_LPOPO))
AnnaBridge 145:64910690c574 418 /*!
AnnaBridge 145:64910690c574 419 * @brief Configures the system to LLS power mode.
AnnaBridge 145:64910690c574 420 *
AnnaBridge 145:64910690c574 421 * @param base SMC peripheral base address.
AnnaBridge 145:64910690c574 422 * @param config The LLS power mode configuration structure
AnnaBridge 145:64910690c574 423 * @return SMC configuration error code.
AnnaBridge 145:64910690c574 424 */
AnnaBridge 145:64910690c574 425 status_t SMC_SetPowerModeLls(SMC_Type *base, const smc_power_mode_lls_config_t *config);
AnnaBridge 145:64910690c574 426 #else
AnnaBridge 145:64910690c574 427 /*!
AnnaBridge 145:64910690c574 428 * @brief Configures the system to LLS power mode.
AnnaBridge 145:64910690c574 429 *
AnnaBridge 145:64910690c574 430 * @param base SMC peripheral base address.
AnnaBridge 145:64910690c574 431 * @return SMC configuration error code.
AnnaBridge 145:64910690c574 432 */
AnnaBridge 145:64910690c574 433 status_t SMC_SetPowerModeLls(SMC_Type *base);
AnnaBridge 145:64910690c574 434 #endif
AnnaBridge 145:64910690c574 435 #endif /* FSL_FEATURE_SMC_HAS_LOW_LEAKAGE_STOP_MODE */
AnnaBridge 145:64910690c574 436
AnnaBridge 145:64910690c574 437 #if (defined(FSL_FEATURE_SMC_HAS_VERY_LOW_LEAKAGE_STOP_MODE) && FSL_FEATURE_SMC_HAS_VERY_LOW_LEAKAGE_STOP_MODE)
AnnaBridge 145:64910690c574 438 /*!
AnnaBridge 145:64910690c574 439 * @brief Configures the system to VLLS power mode.
AnnaBridge 145:64910690c574 440 *
AnnaBridge 145:64910690c574 441 * @param base SMC peripheral base address.
AnnaBridge 145:64910690c574 442 * @param config The VLLS power mode configuration structure.
AnnaBridge 145:64910690c574 443 * @return SMC configuration error code.
AnnaBridge 145:64910690c574 444 */
AnnaBridge 145:64910690c574 445 status_t SMC_SetPowerModeVlls(SMC_Type *base, const smc_power_mode_vlls_config_t *config);
AnnaBridge 145:64910690c574 446 #endif /* FSL_FEATURE_SMC_HAS_VERY_LOW_LEAKAGE_STOP_MODE */
AnnaBridge 145:64910690c574 447
AnnaBridge 145:64910690c574 448 /*@}*/
AnnaBridge 145:64910690c574 449
AnnaBridge 145:64910690c574 450 #if defined(__cplusplus)
AnnaBridge 145:64910690c574 451 }
AnnaBridge 145:64910690c574 452 #endif /* __cplusplus */
AnnaBridge 145:64910690c574 453
AnnaBridge 145:64910690c574 454 /*! @}*/
AnnaBridge 145:64910690c574 455
AnnaBridge 145:64910690c574 456 #endif /* _FSL_SMC_H_ */