Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
fsl_smc.h
00001 /* 00002 * Copyright (c) 2015, Freescale Semiconductor, Inc. 00003 * Copyright 2016-2017 NXP 00004 * All rights reserved. 00005 * 00006 * SPDX-License-Identifier: BSD-3-Clause 00007 */ 00008 00009 #ifndef _FSL_SMC_H_ 00010 #define _FSL_SMC_H_ 00011 00012 #include "fsl_common.h" 00013 00014 /*! @addtogroup smc */ 00015 /*! @{ */ 00016 00017 /******************************************************************************* 00018 * Definitions 00019 ******************************************************************************/ 00020 00021 /*! @name Driver version */ 00022 /*@{*/ 00023 /*! @brief SMC driver version 2.0.4. */ 00024 #define FSL_SMC_DRIVER_VERSION (MAKE_VERSION(2, 0, 4)) 00025 /*@}*/ 00026 00027 /*! 00028 * @brief Power Modes Protection 00029 */ 00030 typedef enum _smc_power_mode_protection 00031 { 00032 #if (defined(FSL_FEATURE_SMC_HAS_VERY_LOW_LEAKAGE_STOP_MODE) && FSL_FEATURE_SMC_HAS_VERY_LOW_LEAKAGE_STOP_MODE) 00033 kSMC_AllowPowerModeVlls = SMC_PMPROT_AVLLS_MASK, /*!< Allow Very-low-leakage Stop Mode. */ 00034 #endif 00035 #if (defined(FSL_FEATURE_SMC_HAS_LOW_LEAKAGE_STOP_MODE) && FSL_FEATURE_SMC_HAS_LOW_LEAKAGE_STOP_MODE) 00036 kSMC_AllowPowerModeLls = SMC_PMPROT_ALLS_MASK, /*!< Allow Low-leakage Stop Mode. */ 00037 #endif /* FSL_FEATURE_SMC_HAS_LOW_LEAKAGE_STOP_MODE */ 00038 kSMC_AllowPowerModeVlp = SMC_PMPROT_AVLP_MASK, /*!< Allow Very-Low-power Mode. */ 00039 #if (defined(FSL_FEATURE_SMC_HAS_HIGH_SPEED_RUN_MODE) && FSL_FEATURE_SMC_HAS_HIGH_SPEED_RUN_MODE) 00040 kSMC_AllowPowerModeHsrun = SMC_PMPROT_AHSRUN_MASK, /*!< Allow High-speed Run mode. */ 00041 #endif /* FSL_FEATURE_SMC_HAS_HIGH_SPEED_RUN_MODE */ 00042 kSMC_AllowPowerModeAll = (0U 00043 #if (defined(FSL_FEATURE_SMC_HAS_VERY_LOW_LEAKAGE_STOP_MODE) && FSL_FEATURE_SMC_HAS_VERY_LOW_LEAKAGE_STOP_MODE) 00044 | 00045 SMC_PMPROT_AVLLS_MASK 00046 #endif 00047 #if (defined(FSL_FEATURE_SMC_HAS_LOW_LEAKAGE_STOP_MODE) && FSL_FEATURE_SMC_HAS_LOW_LEAKAGE_STOP_MODE) 00048 | 00049 SMC_PMPROT_ALLS_MASK 00050 #endif /* FSL_FEATURE_SMC_HAS_LOW_LEAKAGE_STOP_MODE */ 00051 | 00052 SMC_PMPROT_AVLP_MASK 00053 #if (defined(FSL_FEATURE_SMC_HAS_HIGH_SPEED_RUN_MODE) && FSL_FEATURE_SMC_HAS_HIGH_SPEED_RUN_MODE) 00054 | 00055 kSMC_AllowPowerModeHsrun 00056 #endif /* FSL_FEATURE_SMC_HAS_HIGH_SPEED_RUN_MODE */ 00057 ) /*!< Allow all power mode. */ 00058 } smc_power_mode_protection_t; 00059 00060 /*! 00061 * @brief Power Modes in PMSTAT 00062 */ 00063 typedef enum _smc_power_state 00064 { 00065 kSMC_PowerStateRun = 0x01U << 0U, /*!< 0000_0001 - Current power mode is RUN */ 00066 kSMC_PowerStateStop = 0x01U << 1U, /*!< 0000_0010 - Current power mode is STOP */ 00067 kSMC_PowerStateVlpr = 0x01U << 2U, /*!< 0000_0100 - Current power mode is VLPR */ 00068 kSMC_PowerStateVlpw = 0x01U << 3U, /*!< 0000_1000 - Current power mode is VLPW */ 00069 kSMC_PowerStateVlps = 0x01U << 4U, /*!< 0001_0000 - Current power mode is VLPS */ 00070 #if (defined(FSL_FEATURE_SMC_HAS_LOW_LEAKAGE_STOP_MODE) && FSL_FEATURE_SMC_HAS_LOW_LEAKAGE_STOP_MODE) 00071 kSMC_PowerStateLls = 0x01U << 5U, /*!< 0010_0000 - Current power mode is LLS */ 00072 #endif /* FSL_FEATURE_SMC_HAS_LOW_LEAKAGE_STOP_MODE */ 00073 #if (defined(FSL_FEATURE_SMC_HAS_VERY_LOW_LEAKAGE_STOP_MODE) && FSL_FEATURE_SMC_HAS_VERY_LOW_LEAKAGE_STOP_MODE) 00074 kSMC_PowerStateVlls = 0x01U << 6U, /*!< 0100_0000 - Current power mode is VLLS */ 00075 #endif 00076 #if (defined(FSL_FEATURE_SMC_HAS_HIGH_SPEED_RUN_MODE) && FSL_FEATURE_SMC_HAS_HIGH_SPEED_RUN_MODE) 00077 kSMC_PowerStateHsrun = 0x01U << 7U /*!< 1000_0000 - Current power mode is HSRUN */ 00078 #endif /* FSL_FEATURE_SMC_HAS_HIGH_SPEED_RUN_MODE */ 00079 } smc_power_state_t; 00080 00081 /*! 00082 * @brief Run mode definition 00083 */ 00084 typedef enum _smc_run_mode 00085 { 00086 kSMC_RunNormal = 0U, /*!< Normal RUN mode. */ 00087 kSMC_RunVlpr = 2U, /*!< Very-low-power RUN mode. */ 00088 #if (defined(FSL_FEATURE_SMC_HAS_HIGH_SPEED_RUN_MODE) && FSL_FEATURE_SMC_HAS_HIGH_SPEED_RUN_MODE) 00089 kSMC_Hsrun = 3U /*!< High-speed Run mode (HSRUN). */ 00090 #endif /* FSL_FEATURE_SMC_HAS_HIGH_SPEED_RUN_MODE */ 00091 } smc_run_mode_t; 00092 00093 /*! 00094 * @brief Stop mode definition 00095 */ 00096 typedef enum _smc_stop_mode 00097 { 00098 kSMC_StopNormal = 0U, /*!< Normal STOP mode. */ 00099 kSMC_StopVlps = 2U, /*!< Very-low-power STOP mode. */ 00100 #if (defined(FSL_FEATURE_SMC_HAS_LOW_LEAKAGE_STOP_MODE) && FSL_FEATURE_SMC_HAS_LOW_LEAKAGE_STOP_MODE) 00101 kSMC_StopLls = 3U, /*!< Low-leakage Stop mode. */ 00102 #endif /* FSL_FEATURE_SMC_HAS_LOW_LEAKAGE_STOP_MODE */ 00103 #if (defined(FSL_FEATURE_SMC_HAS_VERY_LOW_LEAKAGE_STOP_MODE) && FSL_FEATURE_SMC_HAS_VERY_LOW_LEAKAGE_STOP_MODE) 00104 kSMC_StopVlls = 4U /*!< Very-low-leakage Stop mode. */ 00105 #endif 00106 } smc_stop_mode_t; 00107 00108 #if (defined(FSL_FEATURE_SMC_USE_VLLSCTRL_REG) && FSL_FEATURE_SMC_USE_VLLSCTRL_REG) || \ 00109 (defined(FSL_FEATURE_SMC_USE_STOPCTRL_VLLSM) && FSL_FEATURE_SMC_USE_STOPCTRL_VLLSM) || \ 00110 (defined(FSL_FEATURE_SMC_HAS_LLS_SUBMODE) && FSL_FEATURE_SMC_HAS_LLS_SUBMODE) 00111 /*! 00112 * @brief VLLS/LLS stop sub mode definition 00113 */ 00114 typedef enum _smc_stop_submode 00115 { 00116 kSMC_StopSub0 = 0U, /*!< Stop submode 0, for VLLS0/LLS0. */ 00117 kSMC_StopSub1 = 1U, /*!< Stop submode 1, for VLLS1/LLS1. */ 00118 kSMC_StopSub2 = 2U, /*!< Stop submode 2, for VLLS2/LLS2. */ 00119 kSMC_StopSub3 = 3U /*!< Stop submode 3, for VLLS3/LLS3. */ 00120 } smc_stop_submode_t; 00121 #endif 00122 00123 /*! 00124 * @brief Partial STOP option 00125 */ 00126 typedef enum _smc_partial_stop_mode 00127 { 00128 kSMC_PartialStop = 0U, /*!< STOP - Normal Stop mode*/ 00129 kSMC_PartialStop1 = 1U, /*!< Partial Stop with both system and bus clocks disabled*/ 00130 kSMC_PartialStop2 = 2U, /*!< Partial Stop with system clock disabled and bus clock enabled*/ 00131 } smc_partial_stop_option_t; 00132 00133 /*! 00134 * @brief SMC configuration status. 00135 */ 00136 enum _smc_status 00137 { 00138 kStatus_SMC_StopAbort = MAKE_STATUS(kStatusGroup_POWER , 0) /*!< Entering Stop mode is abort*/ 00139 }; 00140 00141 #if (defined(FSL_FEATURE_SMC_HAS_VERID) && FSL_FEATURE_SMC_HAS_VERID) 00142 /*! 00143 * @brief IP version ID definition. 00144 */ 00145 typedef struct _smc_version_id 00146 { 00147 uint16_t feature ; /*!< Feature Specification Number. */ 00148 uint8_t minor ; /*!< Minor version number. */ 00149 uint8_t major ; /*!< Major version number. */ 00150 } smc_version_id_t; 00151 #endif /* FSL_FEATURE_SMC_HAS_VERID */ 00152 00153 #if (defined(FSL_FEATURE_SMC_HAS_PARAM) && FSL_FEATURE_SMC_HAS_PARAM) 00154 /*! 00155 * @brief IP parameter definition. 00156 */ 00157 typedef struct _smc_param 00158 { 00159 bool hsrunEnable ; /*!< HSRUN mode enable. */ 00160 bool llsEnable ; /*!< LLS mode enable. */ 00161 bool lls2Enable ; /*!< LLS2 mode enable. */ 00162 bool vlls0Enable ; /*!< VLLS0 mode enable. */ 00163 } smc_param_t; 00164 #endif /* FSL_FEATURE_SMC_HAS_PARAM */ 00165 00166 #if (defined(FSL_FEATURE_SMC_HAS_LLS_SUBMODE) && FSL_FEATURE_SMC_HAS_LLS_SUBMODE) || \ 00167 (defined(FSL_FEATURE_SMC_HAS_LPOPO) && FSL_FEATURE_SMC_HAS_LPOPO) 00168 /*! 00169 * @brief SMC Low-Leakage Stop power mode configuration. 00170 */ 00171 typedef struct _smc_power_mode_lls_config 00172 { 00173 #if (defined(FSL_FEATURE_SMC_HAS_LLS_SUBMODE) && FSL_FEATURE_SMC_HAS_LLS_SUBMODE) 00174 smc_stop_submode_t subMode ; /*!< Low-leakage Stop sub-mode */ 00175 #endif 00176 #if (defined(FSL_FEATURE_SMC_HAS_LPOPO) && FSL_FEATURE_SMC_HAS_LPOPO) 00177 bool enableLpoClock ; /*!< Enable LPO clock in LLS mode */ 00178 #endif 00179 } smc_power_mode_lls_config_t; 00180 #endif /* (FSL_FEATURE_SMC_HAS_LLS_SUBMODE || FSL_FEATURE_SMC_HAS_LPOPO) */ 00181 00182 #if (defined(FSL_FEATURE_SMC_HAS_VERY_LOW_LEAKAGE_STOP_MODE) && FSL_FEATURE_SMC_HAS_VERY_LOW_LEAKAGE_STOP_MODE) 00183 /*! 00184 * @brief SMC Very Low-Leakage Stop power mode configuration. 00185 */ 00186 typedef struct _smc_power_mode_vlls_config 00187 { 00188 #if (defined(FSL_FEATURE_SMC_USE_VLLSCTRL_REG) && FSL_FEATURE_SMC_USE_VLLSCTRL_REG) || \ 00189 (defined(FSL_FEATURE_SMC_USE_STOPCTRL_VLLSM) && FSL_FEATURE_SMC_USE_STOPCTRL_VLLSM) || \ 00190 (defined(FSL_FEATURE_SMC_HAS_LLS_SUBMODE) && FSL_FEATURE_SMC_HAS_LLS_SUBMODE) 00191 smc_stop_submode_t subMode ; /*!< Very Low-leakage Stop sub-mode */ 00192 #endif 00193 #if (defined(FSL_FEATURE_SMC_HAS_PORPO) && FSL_FEATURE_SMC_HAS_PORPO) 00194 bool enablePorDetectInVlls0 ; /*!< Enable Power on reset detect in VLLS mode */ 00195 #endif 00196 #if (defined(FSL_FEATURE_SMC_HAS_RAM2_POWER_OPTION) && FSL_FEATURE_SMC_HAS_RAM2_POWER_OPTION) 00197 bool enableRam2InVlls2 ; /*!< Enable RAM2 power in VLLS2 */ 00198 #endif 00199 #if (defined(FSL_FEATURE_SMC_HAS_LPOPO) && FSL_FEATURE_SMC_HAS_LPOPO) 00200 bool enableLpoClock ; /*!< Enable LPO clock in VLLS mode */ 00201 #endif 00202 } smc_power_mode_vlls_config_t; 00203 #endif 00204 00205 /******************************************************************************* 00206 * API 00207 ******************************************************************************/ 00208 00209 #if defined(__cplusplus) 00210 extern "C" { 00211 #endif /* __cplusplus */ 00212 00213 /*! @name System mode controller APIs*/ 00214 /*@{*/ 00215 00216 #if (defined(FSL_FEATURE_SMC_HAS_VERID) && FSL_FEATURE_SMC_HAS_VERID) 00217 /*! 00218 * @brief Gets the SMC version ID. 00219 * 00220 * This function gets the SMC version ID, including major version number, 00221 * minor version number, and feature specification number. 00222 * 00223 * @param base SMC peripheral base address. 00224 * @param versionId Pointer to the version ID structure. 00225 */ 00226 static inline void SMC_GetVersionId(SMC_Type *base, smc_version_id_t *versionId) 00227 { 00228 *((uint32_t *)versionId) = base->VERID; 00229 } 00230 #endif /* FSL_FEATURE_SMC_HAS_VERID */ 00231 00232 #if (defined(FSL_FEATURE_SMC_HAS_PARAM) && FSL_FEATURE_SMC_HAS_PARAM) 00233 /*! 00234 * @brief Gets the SMC parameter. 00235 * 00236 * This function gets the SMC parameter including the enabled power mdoes. 00237 * 00238 * @param base SMC peripheral base address. 00239 * @param param Pointer to the SMC param structure. 00240 */ 00241 void SMC_GetParam(SMC_Type *base, smc_param_t *param); 00242 #endif 00243 00244 /*! 00245 * @brief Configures all power mode protection settings. 00246 * 00247 * This function configures the power mode protection settings for 00248 * supported power modes in the specified chip family. The available power modes 00249 * are defined in the smc_power_mode_protection_t. This should be done at an early 00250 * system level initialization stage. See the reference manual for details. 00251 * This register can only write once after the power reset. 00252 * 00253 * The allowed modes are passed as bit map. For example, to allow LLS and VLLS, 00254 * use SMC_SetPowerModeProtection(kSMC_AllowPowerModeVlls | kSMC_AllowPowerModeVlps). 00255 * To allow all modes, use SMC_SetPowerModeProtection(kSMC_AllowPowerModeAll). 00256 * 00257 * @param base SMC peripheral base address. 00258 * @param allowedModes Bitmap of the allowed power modes. 00259 */ 00260 static inline void SMC_SetPowerModeProtection(SMC_Type *base, uint8_t allowedModes) 00261 { 00262 base->PMPROT = allowedModes; 00263 } 00264 00265 /*! 00266 * @brief Gets the current power mode status. 00267 * 00268 * This function returns the current power mode status. After the application 00269 * switches the power mode, it should always check the status to check whether it 00270 * runs into the specified mode or not. The application should check 00271 * this mode before switching to a different mode. The system requires that 00272 * only certain modes can switch to other specific modes. See the 00273 * reference manual for details and the smc_power_state_t for information about 00274 * the power status. 00275 * 00276 * @param base SMC peripheral base address. 00277 * @return Current power mode status. 00278 */ 00279 static inline smc_power_state_t SMC_GetPowerModeState(SMC_Type *base) 00280 { 00281 return (smc_power_state_t)base->PMSTAT; 00282 } 00283 00284 /*! 00285 * @brief Prepares to enter stop modes. 00286 * 00287 * This function should be called before entering STOP/VLPS/LLS/VLLS modes. 00288 */ 00289 void SMC_PreEnterStopModes(void); 00290 00291 /*! 00292 * @brief Recovers after wake up from stop modes. 00293 * 00294 * This function should be called after wake up from STOP/VLPS/LLS/VLLS modes. 00295 * It is used with @ref SMC_PreEnterStopModes. 00296 */ 00297 void SMC_PostExitStopModes(void); 00298 00299 /*! 00300 * @brief Prepares to enter wait modes. 00301 * 00302 * This function should be called before entering WAIT/VLPW modes. 00303 */ 00304 void SMC_PreEnterWaitModes(void); 00305 00306 /*! 00307 * @brief Recovers after wake up from stop modes. 00308 * 00309 * This function should be called after wake up from WAIT/VLPW modes. 00310 * It is used with @ref SMC_PreEnterWaitModes. 00311 */ 00312 void SMC_PostExitWaitModes(void); 00313 00314 /*! 00315 * @brief Configures the system to RUN power mode. 00316 * 00317 * @param base SMC peripheral base address. 00318 * @return SMC configuration error code. 00319 */ 00320 status_t SMC_SetPowerModeRun(SMC_Type *base); 00321 00322 #if (defined(FSL_FEATURE_SMC_HAS_HIGH_SPEED_RUN_MODE) && FSL_FEATURE_SMC_HAS_HIGH_SPEED_RUN_MODE) 00323 /*! 00324 * @brief Configures the system to HSRUN power mode. 00325 * 00326 * @param base SMC peripheral base address. 00327 * @return SMC configuration error code. 00328 */ 00329 status_t SMC_SetPowerModeHsrun(SMC_Type *base); 00330 #endif /* FSL_FEATURE_SMC_HAS_HIGH_SPEED_RUN_MODE */ 00331 00332 /*! 00333 * @brief Configures the system to WAIT power mode. 00334 * 00335 * @param base SMC peripheral base address. 00336 * @return SMC configuration error code. 00337 */ 00338 status_t SMC_SetPowerModeWait(SMC_Type *base); 00339 00340 /*! 00341 * @brief Configures the system to Stop power mode. 00342 * 00343 * @param base SMC peripheral base address. 00344 * @param option Partial Stop mode option. 00345 * @return SMC configuration error code. 00346 */ 00347 status_t SMC_SetPowerModeStop(SMC_Type *base, smc_partial_stop_option_t option); 00348 00349 #if (defined(FSL_FEATURE_SMC_HAS_LPWUI) && FSL_FEATURE_SMC_HAS_LPWUI) 00350 /*! 00351 * @brief Configures the system to VLPR power mode. 00352 * 00353 * @param base SMC peripheral base address. 00354 * @param wakeupMode Enter Normal Run mode if true, else stay in VLPR mode. 00355 * @return SMC configuration error code. 00356 */ 00357 status_t SMC_SetPowerModeVlpr(SMC_Type *base, bool wakeupMode); 00358 #else 00359 /*! 00360 * @brief Configures the system to VLPR power mode. 00361 * 00362 * @param base SMC peripheral base address. 00363 * @return SMC configuration error code. 00364 */ 00365 status_t SMC_SetPowerModeVlpr(SMC_Type *base); 00366 #endif /* FSL_FEATURE_SMC_HAS_LPWUI */ 00367 00368 /*! 00369 * @brief Configures the system to VLPW power mode. 00370 * 00371 * @param base SMC peripheral base address. 00372 * @return SMC configuration error code. 00373 */ 00374 status_t SMC_SetPowerModeVlpw(SMC_Type *base); 00375 00376 /*! 00377 * @brief Configures the system to VLPS power mode. 00378 * 00379 * @param base SMC peripheral base address. 00380 * @return SMC configuration error code. 00381 */ 00382 status_t SMC_SetPowerModeVlps(SMC_Type *base); 00383 00384 #if (defined(FSL_FEATURE_SMC_HAS_LOW_LEAKAGE_STOP_MODE) && FSL_FEATURE_SMC_HAS_LOW_LEAKAGE_STOP_MODE) 00385 #if ((defined(FSL_FEATURE_SMC_HAS_LLS_SUBMODE) && FSL_FEATURE_SMC_HAS_LLS_SUBMODE) || \ 00386 (defined(FSL_FEATURE_SMC_HAS_LPOPO) && FSL_FEATURE_SMC_HAS_LPOPO)) 00387 /*! 00388 * @brief Configures the system to LLS power mode. 00389 * 00390 * @param base SMC peripheral base address. 00391 * @param config The LLS power mode configuration structure 00392 * @return SMC configuration error code. 00393 */ 00394 status_t SMC_SetPowerModeLls(SMC_Type *base, const smc_power_mode_lls_config_t *config); 00395 #else 00396 /*! 00397 * @brief Configures the system to LLS power mode. 00398 * 00399 * @param base SMC peripheral base address. 00400 * @return SMC configuration error code. 00401 */ 00402 status_t SMC_SetPowerModeLls(SMC_Type *base); 00403 #endif 00404 #endif /* FSL_FEATURE_SMC_HAS_LOW_LEAKAGE_STOP_MODE */ 00405 00406 #if (defined(FSL_FEATURE_SMC_HAS_VERY_LOW_LEAKAGE_STOP_MODE) && FSL_FEATURE_SMC_HAS_VERY_LOW_LEAKAGE_STOP_MODE) 00407 /*! 00408 * @brief Configures the system to VLLS power mode. 00409 * 00410 * @param base SMC peripheral base address. 00411 * @param config The VLLS power mode configuration structure. 00412 * @return SMC configuration error code. 00413 */ 00414 status_t SMC_SetPowerModeVlls(SMC_Type *base, const smc_power_mode_vlls_config_t *config); 00415 #endif /* FSL_FEATURE_SMC_HAS_VERY_LOW_LEAKAGE_STOP_MODE */ 00416 00417 /*@}*/ 00418 00419 #if defined(__cplusplus) 00420 } 00421 #endif /* __cplusplus */ 00422 00423 /*! @}*/ 00424 00425 #endif /* _FSL_SMC_H_ */
Generated on Tue Jul 12 2022 15:37:18 by
