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:
Thu Sep 18 14:00:17 2014 +0100
Revision:
324:406fd2029f23
Parent:
149:1fb5f62b92bd
Synchronized with git revision a73f28e6fbca9559fbed2726410eeb4c0534a4a5

Full URL: https://github.com/mbedmicro/mbed/commit/a73f28e6fbca9559fbed2726410eeb4c0534a4a5/

Extended #476, which does not break ethernet for K64F

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 146:f64d43ff0c18 1 /*
mbed_official 146:f64d43ff0c18 2 * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc.
mbed_official 146:f64d43ff0c18 3 * All rights reserved.
mbed_official 146:f64d43ff0c18 4 *
mbed_official 146:f64d43ff0c18 5 * Redistribution and use in source and binary forms, with or without modification,
mbed_official 146:f64d43ff0c18 6 * are permitted provided that the following conditions are met:
mbed_official 146:f64d43ff0c18 7 *
mbed_official 146:f64d43ff0c18 8 * o Redistributions of source code must retain the above copyright notice, this list
mbed_official 146:f64d43ff0c18 9 * of conditions and the following disclaimer.
mbed_official 146:f64d43ff0c18 10 *
mbed_official 146:f64d43ff0c18 11 * o Redistributions in binary form must reproduce the above copyright notice, this
mbed_official 146:f64d43ff0c18 12 * list of conditions and the following disclaimer in the documentation and/or
mbed_official 146:f64d43ff0c18 13 * other materials provided with the distribution.
mbed_official 146:f64d43ff0c18 14 *
mbed_official 146:f64d43ff0c18 15 * o Neither the name of Freescale Semiconductor, Inc. nor the names of its
mbed_official 146:f64d43ff0c18 16 * contributors may be used to endorse or promote products derived from this
mbed_official 146:f64d43ff0c18 17 * software without specific prior written permission.
mbed_official 146:f64d43ff0c18 18 *
mbed_official 146:f64d43ff0c18 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
mbed_official 146:f64d43ff0c18 20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
mbed_official 146:f64d43ff0c18 21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
mbed_official 146:f64d43ff0c18 22 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
mbed_official 146:f64d43ff0c18 23 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
mbed_official 146:f64d43ff0c18 24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
mbed_official 146:f64d43ff0c18 25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
mbed_official 146:f64d43ff0c18 26 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
mbed_official 146:f64d43ff0c18 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
mbed_official 146:f64d43ff0c18 28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
mbed_official 146:f64d43ff0c18 29 */
mbed_official 146:f64d43ff0c18 30
mbed_official 146:f64d43ff0c18 31 #include "fsl_smc_hal.h"
mbed_official 146:f64d43ff0c18 32
mbed_official 146:f64d43ff0c18 33 /*******************************************************************************
mbed_official 146:f64d43ff0c18 34 * Definitions
mbed_official 146:f64d43ff0c18 35 ******************************************************************************/
mbed_official 146:f64d43ff0c18 36
mbed_official 146:f64d43ff0c18 37 /*******************************************************************************
mbed_official 146:f64d43ff0c18 38 * Code
mbed_official 146:f64d43ff0c18 39 ******************************************************************************/
mbed_official 324:406fd2029f23 40 /*FUNCTION**********************************************************************
mbed_official 324:406fd2029f23 41 *
mbed_official 324:406fd2029f23 42 * Function Name : SMC_HAL_SetMode
mbed_official 324:406fd2029f23 43 * Description : Config the power mode
mbed_official 324:406fd2029f23 44 * This function will configure the power mode control for any run, stop and
mbed_official 324:406fd2029f23 45 * stop submode if needed. It will also configure the power options for specific
mbed_official 324:406fd2029f23 46 * power mode. Application should follow the proper procedure to configure and
mbed_official 324:406fd2029f23 47 * switch power mode between the different run and stop mode. Refer to reference
mbed_official 324:406fd2029f23 48 * manual for the proper procedure and supported power mode that can be configured
mbed_official 324:406fd2029f23 49 * and switch between each other. Refert to smc_power_mode_config_t for required
mbed_official 324:406fd2029f23 50 * parameters to configure the power mode and the supported options. Other options
mbed_official 324:406fd2029f23 51 * may need to configure through the hal driver individaully. Refer to hal driver
mbed_official 324:406fd2029f23 52 * header for details.
mbed_official 324:406fd2029f23 53 *
mbed_official 324:406fd2029f23 54 *END**************************************************************************/
mbed_official 324:406fd2029f23 55 smc_hal_error_code_t SMC_HAL_SetMode(uint32_t baseAddr, const smc_power_mode_config_t *powerModeConfig)
mbed_official 324:406fd2029f23 56 {
mbed_official 324:406fd2029f23 57 smc_hal_error_code_t retCode = kSmcHalSuccess;
mbed_official 324:406fd2029f23 58 uint8_t currentStat;
mbed_official 324:406fd2029f23 59 volatile unsigned int dummyread;
mbed_official 324:406fd2029f23 60 smc_stop_mode_t stopMode;
mbed_official 324:406fd2029f23 61 smc_run_mode_t runMode;
mbed_official 324:406fd2029f23 62 power_mode_stat_t modeStat;
mbed_official 324:406fd2029f23 63 power_modes_t powerModeName = powerModeConfig->powerModeName;
mbed_official 324:406fd2029f23 64
mbed_official 324:406fd2029f23 65 /* verify the power mode name*/
mbed_official 324:406fd2029f23 66 assert(powerModeName < kPowerModeMax);
mbed_official 324:406fd2029f23 67
mbed_official 324:406fd2029f23 68 #if FSL_FEATURE_SMC_HAS_LPWUI
mbed_official 324:406fd2029f23 69 /* check lpwui option*/
mbed_official 324:406fd2029f23 70 if (powerModeConfig->lpwuiOption)
mbed_official 324:406fd2029f23 71 {
mbed_official 324:406fd2029f23 72 /* check current stat*/
mbed_official 324:406fd2029f23 73 currentStat = SMC_HAL_GetStat(baseAddr);
mbed_official 324:406fd2029f23 74
mbed_official 324:406fd2029f23 75 /* if not in VLPR stat, could not set to RUN*/
mbed_official 324:406fd2029f23 76 if (currentStat == kStatRun)
mbed_official 324:406fd2029f23 77 {
mbed_official 324:406fd2029f23 78 SMC_HAL_SetLpwuiMode(baseAddr, powerModeConfig->lpwuiOptionValue);
mbed_official 324:406fd2029f23 79 }
mbed_official 324:406fd2029f23 80 }
mbed_official 324:406fd2029f23 81 #endif
mbed_official 324:406fd2029f23 82
mbed_official 324:406fd2029f23 83 /* branch based on power mode name*/
mbed_official 324:406fd2029f23 84 switch (powerModeName)
mbed_official 324:406fd2029f23 85 {
mbed_official 324:406fd2029f23 86 case kPowerModeRun:
mbed_official 324:406fd2029f23 87 case kPowerModeVlpr:
mbed_official 324:406fd2029f23 88 if (powerModeName == kPowerModeRun)
mbed_official 324:406fd2029f23 89 {
mbed_official 324:406fd2029f23 90 /* mode setting for normal RUN*/
mbed_official 324:406fd2029f23 91 runMode = kSmcRun;
mbed_official 324:406fd2029f23 92 modeStat = kStatVlpr;
mbed_official 324:406fd2029f23 93 }
mbed_official 324:406fd2029f23 94 else
mbed_official 324:406fd2029f23 95 {
mbed_official 324:406fd2029f23 96 /* mode setting for VLPR*/
mbed_official 324:406fd2029f23 97 runMode = kSmcVlpr;
mbed_official 324:406fd2029f23 98 modeStat = kStatRun;
mbed_official 324:406fd2029f23 99 }
mbed_official 324:406fd2029f23 100
mbed_official 324:406fd2029f23 101 /* check current stat*/
mbed_official 324:406fd2029f23 102 currentStat = SMC_HAL_GetStat(baseAddr);
mbed_official 324:406fd2029f23 103
mbed_official 324:406fd2029f23 104 /* if not in VLPR stat, could not set to RUN*/
mbed_official 324:406fd2029f23 105 if (currentStat != modeStat)
mbed_official 324:406fd2029f23 106 {
mbed_official 324:406fd2029f23 107 retCode = kSmcHalFailed;
mbed_official 324:406fd2029f23 108 }
mbed_official 324:406fd2029f23 109 else
mbed_official 324:406fd2029f23 110 {
mbed_official 324:406fd2029f23 111 /* set power mode to normal RUN or VLPR*/
mbed_official 324:406fd2029f23 112 SMC_HAL_SetRunMode(baseAddr, runMode);
mbed_official 324:406fd2029f23 113 }
mbed_official 324:406fd2029f23 114 break;
mbed_official 324:406fd2029f23 115
mbed_official 324:406fd2029f23 116 #if FSL_FEATURE_SMC_HAS_HIGH_SPEED_RUN_MODE
mbed_official 324:406fd2029f23 117 case kPowerModeHsrun:
mbed_official 324:406fd2029f23 118 /* mode setting for HSRUN (high speed run) */
mbed_official 324:406fd2029f23 119 runMode = kSmcHsrun;
mbed_official 324:406fd2029f23 120 modeStat = kStatRun;
mbed_official 324:406fd2029f23 121
mbed_official 324:406fd2029f23 122 /* check current stat*/
mbed_official 324:406fd2029f23 123 currentStat = SMC_HAL_GetStat(baseAddr);
mbed_official 324:406fd2029f23 124
mbed_official 324:406fd2029f23 125 if (currentStat != modeStat)
mbed_official 324:406fd2029f23 126 {
mbed_official 324:406fd2029f23 127 /* if not in the mode, return error*/
mbed_official 324:406fd2029f23 128 retCode = kSmcHalFailed;
mbed_official 324:406fd2029f23 129 }
mbed_official 324:406fd2029f23 130 else
mbed_official 324:406fd2029f23 131 {
mbed_official 324:406fd2029f23 132 /* set power mode to normal RUN or VLPR mode first*/
mbed_official 324:406fd2029f23 133 SMC_HAL_SetRunMode(baseAddr, runMode);
mbed_official 324:406fd2029f23 134 }
mbed_official 324:406fd2029f23 135
mbed_official 324:406fd2029f23 136 break;
mbed_official 324:406fd2029f23 137 #endif
mbed_official 324:406fd2029f23 138
mbed_official 324:406fd2029f23 139 case kPowerModeWait:
mbed_official 324:406fd2029f23 140 case kPowerModeVlpw:
mbed_official 324:406fd2029f23 141 if (powerModeName == kPowerModeWait)
mbed_official 324:406fd2029f23 142 {
mbed_official 324:406fd2029f23 143 /* mode setting for normal RUN*/
mbed_official 324:406fd2029f23 144 runMode = kSmcRun;
mbed_official 324:406fd2029f23 145 modeStat = kStatRun;
mbed_official 324:406fd2029f23 146 }
mbed_official 324:406fd2029f23 147 else
mbed_official 324:406fd2029f23 148 {
mbed_official 324:406fd2029f23 149 /* mode setting for VLPR*/
mbed_official 324:406fd2029f23 150 runMode = kSmcVlpr;
mbed_official 324:406fd2029f23 151 modeStat = kStatVlpr;
mbed_official 324:406fd2029f23 152 }
mbed_official 324:406fd2029f23 153
mbed_official 324:406fd2029f23 154 /* check current stat*/
mbed_official 324:406fd2029f23 155 currentStat = SMC_HAL_GetStat(baseAddr);
mbed_official 324:406fd2029f23 156
mbed_official 324:406fd2029f23 157 if (currentStat != modeStat)
mbed_official 324:406fd2029f23 158 {
mbed_official 324:406fd2029f23 159 /* if not in the mode, return error*/
mbed_official 324:406fd2029f23 160 retCode = kSmcHalFailed;
mbed_official 324:406fd2029f23 161 }
mbed_official 324:406fd2029f23 162 else
mbed_official 324:406fd2029f23 163 {
mbed_official 324:406fd2029f23 164 /* set power mode to normal RUN or VLPR mode first*/
mbed_official 324:406fd2029f23 165 SMC_HAL_SetRunMode(baseAddr, runMode);
mbed_official 324:406fd2029f23 166 }
mbed_official 324:406fd2029f23 167
mbed_official 324:406fd2029f23 168 if (retCode == kSmcHalSuccess)
mbed_official 324:406fd2029f23 169 {
mbed_official 324:406fd2029f23 170 /* Clear the SLEEPDEEP bit to disable deep sleep mode - enter wait mode*/
mbed_official 324:406fd2029f23 171 SCB->SCR &= ~SCB_SCR_SLEEPDEEP_Msk;
mbed_official 324:406fd2029f23 172 __WFI();
mbed_official 324:406fd2029f23 173 }
mbed_official 324:406fd2029f23 174 break;
mbed_official 324:406fd2029f23 175
mbed_official 324:406fd2029f23 176 case kPowerModeStop:
mbed_official 324:406fd2029f23 177 case kPowerModeVlps:
mbed_official 324:406fd2029f23 178 case kPowerModeLls:
mbed_official 324:406fd2029f23 179 if (powerModeName == kPowerModeStop)
mbed_official 324:406fd2029f23 180 {
mbed_official 324:406fd2029f23 181 #if FSL_FEATURE_SMC_HAS_HIGH_SPEED_RUN_MODE
mbed_official 324:406fd2029f23 182 /* check current stat*/
mbed_official 324:406fd2029f23 183 currentStat = SMC_HAL_GetStat(baseAddr);
mbed_official 324:406fd2029f23 184
mbed_official 324:406fd2029f23 185 if ((currentStat == kStatHsrun) || (SMC_HAL_GetRunMode(baseAddr) == kSmcHsrun))
mbed_official 324:406fd2029f23 186 {
mbed_official 324:406fd2029f23 187 retCode = kSmcHalFailed;
mbed_official 324:406fd2029f23 188 break;
mbed_official 324:406fd2029f23 189 }
mbed_official 324:406fd2029f23 190 #endif
mbed_official 324:406fd2029f23 191 stopMode = kSmcStop;
mbed_official 324:406fd2029f23 192 #if FSL_FEATURE_SMC_HAS_PSTOPO
mbed_official 324:406fd2029f23 193 if (powerModeConfig->pstopOption)
mbed_official 324:406fd2029f23 194 {
mbed_official 324:406fd2029f23 195 SMC_HAL_SetPstopMode(baseAddr, powerModeConfig->pstopOptionValue);
mbed_official 324:406fd2029f23 196 }
mbed_official 324:406fd2029f23 197 #endif
mbed_official 324:406fd2029f23 198 }
mbed_official 324:406fd2029f23 199 else if (powerModeName == kPowerModeVlps)
mbed_official 324:406fd2029f23 200 {
mbed_official 324:406fd2029f23 201 stopMode = kSmcVlps;
mbed_official 324:406fd2029f23 202 }
mbed_official 324:406fd2029f23 203 else
mbed_official 324:406fd2029f23 204 {
mbed_official 324:406fd2029f23 205 stopMode = kSmcLls;
mbed_official 324:406fd2029f23 206 }
mbed_official 324:406fd2029f23 207
mbed_official 324:406fd2029f23 208 /* set power mode to specified STOP mode*/
mbed_official 324:406fd2029f23 209 SMC_HAL_SetStopMode(baseAddr, stopMode);
mbed_official 324:406fd2029f23 210
mbed_official 324:406fd2029f23 211 #if FSL_FEATURE_SMC_HAS_LLS_SUBMODE
mbed_official 324:406fd2029f23 212 if (powerModeName == kPowerModeLls)
mbed_official 324:406fd2029f23 213 {
mbed_official 324:406fd2029f23 214 /* further set the stop sub mode configuration*/
mbed_official 324:406fd2029f23 215 SMC_HAL_SetStopSubMode(baseAddr, powerModeConfig->stopSubMode);
mbed_official 324:406fd2029f23 216 }
mbed_official 324:406fd2029f23 217 #endif
mbed_official 324:406fd2029f23 218
mbed_official 324:406fd2029f23 219 /* wait for write to complete to SMC before stopping core */
mbed_official 324:406fd2029f23 220 dummyread = SMC_HAL_GetStat(baseAddr);
mbed_official 324:406fd2029f23 221 dummyread = dummyread + 1;
mbed_official 324:406fd2029f23 222
mbed_official 324:406fd2029f23 223 /* Set the SLEEPDEEP bit to enable deep sleep mode (STOP)*/
mbed_official 324:406fd2029f23 224 SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk;
mbed_official 324:406fd2029f23 225 __WFI();
mbed_official 324:406fd2029f23 226
mbed_official 324:406fd2029f23 227 break;
mbed_official 324:406fd2029f23 228
mbed_official 324:406fd2029f23 229 case kPowerModeVlls:
mbed_official 324:406fd2029f23 230 /* set power mode to specified STOP mode*/
mbed_official 324:406fd2029f23 231 SMC_HAL_SetStopMode(baseAddr, kSmcVlls);
mbed_official 324:406fd2029f23 232
mbed_official 324:406fd2029f23 233 /* further set the stop sub mode configuration*/
mbed_official 324:406fd2029f23 234 SMC_HAL_SetStopSubMode(baseAddr, powerModeConfig->stopSubMode);
mbed_official 324:406fd2029f23 235
mbed_official 324:406fd2029f23 236 /* check if Vlls0 option needs configuration*/
mbed_official 324:406fd2029f23 237 if (powerModeConfig->stopSubMode == kSmcStopSub0)
mbed_official 324:406fd2029f23 238 {
mbed_official 324:406fd2029f23 239 #if FSL_FEATURE_SMC_HAS_PORPO
mbed_official 324:406fd2029f23 240 if (powerModeConfig->porOption)
mbed_official 324:406fd2029f23 241 {
mbed_official 324:406fd2029f23 242 SMC_HAL_SetPorMode(baseAddr, powerModeConfig->porOptionValue);
mbed_official 324:406fd2029f23 243 }
mbed_official 324:406fd2029f23 244 #endif
mbed_official 324:406fd2029f23 245 }
mbed_official 324:406fd2029f23 246
mbed_official 324:406fd2029f23 247 /* wait for write to complete to SMC before stopping core */
mbed_official 324:406fd2029f23 248 dummyread = SMC_HAL_GetStat(baseAddr);
mbed_official 324:406fd2029f23 249 dummyread = dummyread + 1;
mbed_official 324:406fd2029f23 250
mbed_official 324:406fd2029f23 251 /* Set the SLEEPDEEP bit to enable deep sleep mode (STOP)*/
mbed_official 324:406fd2029f23 252 SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk;
mbed_official 324:406fd2029f23 253 __WFI();
mbed_official 324:406fd2029f23 254
mbed_official 324:406fd2029f23 255 break;
mbed_official 324:406fd2029f23 256 default:
mbed_official 324:406fd2029f23 257 retCode = kSmcHalNoSuchModeName;
mbed_official 324:406fd2029f23 258 break;
mbed_official 324:406fd2029f23 259 }
mbed_official 324:406fd2029f23 260
mbed_official 324:406fd2029f23 261 return retCode;
mbed_official 324:406fd2029f23 262 }
mbed_official 146:f64d43ff0c18 263
mbed_official 146:f64d43ff0c18 264 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 265 *
mbed_official 324:406fd2029f23 266 * Function Name : SMC_HAL_SetProtection
mbed_official 146:f64d43ff0c18 267 * Description : Config all power mode protection settings
mbed_official 146:f64d43ff0c18 268 * This function will configure the power mode protection settings for
mbed_official 146:f64d43ff0c18 269 * supported power mode on the specified chip family. The availabe power modes
mbed_official 146:f64d43ff0c18 270 * are defined in smc_power_mode_protection_config_t. Application should provide
mbed_official 146:f64d43ff0c18 271 * the protect settings for all supported power mode on the chip and aslo this
mbed_official 146:f64d43ff0c18 272 * should be done at early system level init stage. Refer to reference manual
mbed_official 146:f64d43ff0c18 273 * for details. This register can only write once after power reset. So either
mbed_official 146:f64d43ff0c18 274 * use this function or use the individual set function if you only have single
mbed_official 146:f64d43ff0c18 275 * option to set.
mbed_official 146:f64d43ff0c18 276 *
mbed_official 146:f64d43ff0c18 277 *END**************************************************************************/
mbed_official 324:406fd2029f23 278 void SMC_HAL_SetProtection(uint32_t baseAddr, smc_power_mode_protection_config_t *protectConfig)
mbed_official 146:f64d43ff0c18 279 {
mbed_official 146:f64d43ff0c18 280 /* initialize the setting */
mbed_official 146:f64d43ff0c18 281 uint8_t regValue = 0;
mbed_official 146:f64d43ff0c18 282
mbed_official 146:f64d43ff0c18 283 /* check configurations for each mode and combine the seting together */
mbed_official 146:f64d43ff0c18 284 if (protectConfig->vlpProt)
mbed_official 146:f64d43ff0c18 285 {
mbed_official 146:f64d43ff0c18 286 regValue |= BF_SMC_PMPROT_AVLP(1);
mbed_official 146:f64d43ff0c18 287 }
mbed_official 146:f64d43ff0c18 288
mbed_official 146:f64d43ff0c18 289 if (protectConfig->llsProt)
mbed_official 146:f64d43ff0c18 290 {
mbed_official 146:f64d43ff0c18 291 regValue |= BF_SMC_PMPROT_ALLS(1);
mbed_official 146:f64d43ff0c18 292 }
mbed_official 146:f64d43ff0c18 293
mbed_official 146:f64d43ff0c18 294 if (protectConfig->vllsProt)
mbed_official 146:f64d43ff0c18 295 {
mbed_official 146:f64d43ff0c18 296 regValue |= BF_SMC_PMPROT_AVLLS(1);
mbed_official 146:f64d43ff0c18 297 }
mbed_official 146:f64d43ff0c18 298
mbed_official 324:406fd2029f23 299 #if FSL_FEATURE_SMC_HAS_HIGH_SPEED_RUN_MODE
mbed_official 324:406fd2029f23 300 if (protectConfig->hsrunProt)
mbed_official 324:406fd2029f23 301 {
mbed_official 324:406fd2029f23 302 regValue |= BF_SMC_PMPROT_AHSRUN(1);
mbed_official 324:406fd2029f23 303 }
mbed_official 324:406fd2029f23 304 #endif
mbed_official 324:406fd2029f23 305
mbed_official 146:f64d43ff0c18 306 /* write once into pmprot register*/
mbed_official 324:406fd2029f23 307 HW_SMC_PMPROT_SET(baseAddr, regValue);
mbed_official 146:f64d43ff0c18 308 }
mbed_official 146:f64d43ff0c18 309
mbed_official 146:f64d43ff0c18 310 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 311 *
mbed_official 324:406fd2029f23 312 * Function Name : SMC_HAL_SetProtectionMode
mbed_official 146:f64d43ff0c18 313 * Description : Config the individual power mode protection setting
mbed_official 146:f64d43ff0c18 314 * This function will only configure the power mode protection settings for
mbed_official 146:f64d43ff0c18 315 * a specified power mode on the specified chip family. The availabe power modes
mbed_official 146:f64d43ff0c18 316 * are defined in smc_power_mode_protection_config_t. Refer to reference manual
mbed_official 146:f64d43ff0c18 317 * for details. This register can only write once after power reset.
mbed_official 146:f64d43ff0c18 318 *
mbed_official 146:f64d43ff0c18 319 *END**************************************************************************/
mbed_official 324:406fd2029f23 320 void SMC_HAL_SetProtectionMode(uint32_t baseAddr, power_modes_protect_t protect, bool allow)
mbed_official 146:f64d43ff0c18 321 {
mbed_official 146:f64d43ff0c18 322 /* check the setting range */
mbed_official 146:f64d43ff0c18 323 assert(protect < kAllowMax);
mbed_official 146:f64d43ff0c18 324
mbed_official 146:f64d43ff0c18 325 /* branch according to mode and write the setting */
mbed_official 146:f64d43ff0c18 326 switch (protect)
mbed_official 146:f64d43ff0c18 327 {
mbed_official 146:f64d43ff0c18 328 case kAllowVlp:
mbed_official 146:f64d43ff0c18 329 if (allow)
mbed_official 146:f64d43ff0c18 330 {
mbed_official 324:406fd2029f23 331 BW_SMC_PMPROT_AVLP(baseAddr, 1);
mbed_official 146:f64d43ff0c18 332 }
mbed_official 146:f64d43ff0c18 333 else
mbed_official 146:f64d43ff0c18 334 {
mbed_official 324:406fd2029f23 335 BW_SMC_PMPROT_AVLP(baseAddr, 0);
mbed_official 146:f64d43ff0c18 336 }
mbed_official 146:f64d43ff0c18 337 break;
mbed_official 146:f64d43ff0c18 338 case kAllowLls:
mbed_official 146:f64d43ff0c18 339 if (allow)
mbed_official 146:f64d43ff0c18 340 {
mbed_official 324:406fd2029f23 341 BW_SMC_PMPROT_ALLS(baseAddr, 1);
mbed_official 146:f64d43ff0c18 342 }
mbed_official 146:f64d43ff0c18 343 else
mbed_official 146:f64d43ff0c18 344 {
mbed_official 324:406fd2029f23 345 BW_SMC_PMPROT_ALLS(baseAddr, 0);
mbed_official 146:f64d43ff0c18 346 }
mbed_official 146:f64d43ff0c18 347 break;
mbed_official 146:f64d43ff0c18 348 case kAllowVlls:
mbed_official 146:f64d43ff0c18 349 if (allow)
mbed_official 146:f64d43ff0c18 350 {
mbed_official 324:406fd2029f23 351 BW_SMC_PMPROT_AVLLS(baseAddr, 1);
mbed_official 146:f64d43ff0c18 352 }
mbed_official 146:f64d43ff0c18 353 else
mbed_official 146:f64d43ff0c18 354 {
mbed_official 324:406fd2029f23 355 BW_SMC_PMPROT_AVLLS(baseAddr, 0);
mbed_official 146:f64d43ff0c18 356 }
mbed_official 146:f64d43ff0c18 357 break;
mbed_official 324:406fd2029f23 358 #if FSL_FEATURE_SMC_HAS_HIGH_SPEED_RUN_MODE
mbed_official 324:406fd2029f23 359 case kAllowHsrun:
mbed_official 324:406fd2029f23 360 if (allow)
mbed_official 324:406fd2029f23 361 {
mbed_official 324:406fd2029f23 362 BW_SMC_PMPROT_AHSRUN(baseAddr, 1);
mbed_official 324:406fd2029f23 363 }
mbed_official 324:406fd2029f23 364 else
mbed_official 324:406fd2029f23 365 {
mbed_official 324:406fd2029f23 366 BW_SMC_PMPROT_AHSRUN(baseAddr, 0);
mbed_official 324:406fd2029f23 367 }
mbed_official 324:406fd2029f23 368 break;
mbed_official 324:406fd2029f23 369 #endif
mbed_official 146:f64d43ff0c18 370 default:
mbed_official 146:f64d43ff0c18 371 break;
mbed_official 146:f64d43ff0c18 372 }
mbed_official 146:f64d43ff0c18 373 }
mbed_official 146:f64d43ff0c18 374
mbed_official 146:f64d43ff0c18 375 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 376 *
mbed_official 324:406fd2029f23 377 * Function Name : SMC_HAL_GetProtectionMode
mbed_official 146:f64d43ff0c18 378 * Description : Get the current power mode protection setting
mbed_official 146:f64d43ff0c18 379 * This function will get the current power mode protection settings for
mbed_official 146:f64d43ff0c18 380 * a specified power mode.
mbed_official 146:f64d43ff0c18 381 *
mbed_official 146:f64d43ff0c18 382 *END**************************************************************************/
mbed_official 324:406fd2029f23 383 bool SMC_HAL_GetProtectionMode(uint32_t baseAddr, power_modes_protect_t protect)
mbed_official 146:f64d43ff0c18 384 {
mbed_official 324:406fd2029f23 385 bool retValue = false;
mbed_official 324:406fd2029f23 386
mbed_official 146:f64d43ff0c18 387 /* check the mode range */
mbed_official 146:f64d43ff0c18 388 assert(protect < kAllowMax);
mbed_official 146:f64d43ff0c18 389
mbed_official 146:f64d43ff0c18 390 /* branch according to the mode and read the setting */
mbed_official 146:f64d43ff0c18 391 switch (protect)
mbed_official 146:f64d43ff0c18 392 {
mbed_official 146:f64d43ff0c18 393 case kAllowVlp:
mbed_official 324:406fd2029f23 394 retValue = BR_SMC_PMPROT_AVLP(baseAddr);
mbed_official 324:406fd2029f23 395 break;
mbed_official 146:f64d43ff0c18 396 case kAllowLls:
mbed_official 324:406fd2029f23 397 retValue = BR_SMC_PMPROT_ALLS(baseAddr);
mbed_official 324:406fd2029f23 398 break;
mbed_official 146:f64d43ff0c18 399 case kAllowVlls:
mbed_official 324:406fd2029f23 400 retValue = BR_SMC_PMPROT_AVLLS(baseAddr);
mbed_official 324:406fd2029f23 401 break;
mbed_official 324:406fd2029f23 402 #if FSL_FEATURE_SMC_HAS_HIGH_SPEED_RUN_MODE
mbed_official 324:406fd2029f23 403 case kAllowHsrun:
mbed_official 324:406fd2029f23 404 retValue = BR_SMC_PMPROT_AHSRUN(baseAddr);
mbed_official 324:406fd2029f23 405 break;
mbed_official 324:406fd2029f23 406 #endif
mbed_official 146:f64d43ff0c18 407 default:
mbed_official 146:f64d43ff0c18 408 break;
mbed_official 146:f64d43ff0c18 409 }
mbed_official 324:406fd2029f23 410 return retValue;
mbed_official 146:f64d43ff0c18 411 }
mbed_official 146:f64d43ff0c18 412
mbed_official 146:f64d43ff0c18 413 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 414 *
mbed_official 324:406fd2029f23 415 * Function Name : SMC_HAL_SetRunMode
mbed_official 146:f64d43ff0c18 416 * Description : Config the RUN mode control setting
mbed_official 146:f64d43ff0c18 417 * This function will set the run mode settings. For example, normal run mode,
mbed_official 146:f64d43ff0c18 418 * very lower power run mode, etc. Refer to smc_run_mode_t for supported run
mbed_official 146:f64d43ff0c18 419 * mode on the chip family. Refer to reference manual for details about the
mbed_official 146:f64d43ff0c18 420 * run mode.
mbed_official 146:f64d43ff0c18 421 *
mbed_official 146:f64d43ff0c18 422 *END**************************************************************************/
mbed_official 324:406fd2029f23 423 void SMC_HAL_SetRunMode(uint32_t baseAddr, smc_run_mode_t runMode)
mbed_official 146:f64d43ff0c18 424 {
mbed_official 324:406fd2029f23 425 BW_SMC_PMCTRL_RUNM(baseAddr, runMode);
mbed_official 146:f64d43ff0c18 426 }
mbed_official 146:f64d43ff0c18 427
mbed_official 146:f64d43ff0c18 428 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 429 *
mbed_official 324:406fd2029f23 430 * Function Name : SMC_HAL_GetRunMode
mbed_official 146:f64d43ff0c18 431 * Description : Get the current RUN mode config
mbed_official 146:f64d43ff0c18 432 * This function will get the run mode settings. Refer to smc_run_mode_t
mbed_official 146:f64d43ff0c18 433 * for supported run mode on the chip family. Refer to reference manual for
mbed_official 146:f64d43ff0c18 434 * details about the run mode.
mbed_official 146:f64d43ff0c18 435 *
mbed_official 146:f64d43ff0c18 436 *END**************************************************************************/
mbed_official 324:406fd2029f23 437 smc_run_mode_t SMC_HAL_GetRunMode(uint32_t baseAddr)
mbed_official 146:f64d43ff0c18 438 {
mbed_official 324:406fd2029f23 439 return (smc_run_mode_t)BR_SMC_PMCTRL_RUNM(baseAddr);
mbed_official 146:f64d43ff0c18 440 }
mbed_official 146:f64d43ff0c18 441
mbed_official 146:f64d43ff0c18 442 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 443 *
mbed_official 324:406fd2029f23 444 * Function Name : SMC_HAL_SetStopMode
mbed_official 146:f64d43ff0c18 445 * Description : Config the STOP mode control setting
mbed_official 146:f64d43ff0c18 446 * This function will set the stop mode settings. For example, normal stop mode,
mbed_official 146:f64d43ff0c18 447 * very lower power stop mode, etc. Refer to smc_stop_mode_t for supported stop
mbed_official 146:f64d43ff0c18 448 * mode on the chip family. Refer to reference manual for details about the
mbed_official 146:f64d43ff0c18 449 * stop mode.
mbed_official 146:f64d43ff0c18 450 *
mbed_official 146:f64d43ff0c18 451 *END**************************************************************************/
mbed_official 324:406fd2029f23 452 void SMC_HAL_SetStopMode(uint32_t baseAddr, smc_stop_mode_t stopMode)
mbed_official 146:f64d43ff0c18 453 {
mbed_official 324:406fd2029f23 454 BW_SMC_PMCTRL_STOPM(baseAddr, stopMode);
mbed_official 146:f64d43ff0c18 455 }
mbed_official 146:f64d43ff0c18 456
mbed_official 146:f64d43ff0c18 457 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 458 *
mbed_official 324:406fd2029f23 459 * Function Name : SMC_HAL_GetStopMode
mbed_official 146:f64d43ff0c18 460 * Description : Get the current STOP mode control setting
mbed_official 146:f64d43ff0c18 461 * This function will get the stop mode settings. For example, normal stop mode,
mbed_official 146:f64d43ff0c18 462 * very lower power stop mode, etc. Refer to smc_stop_mode_t for supported stop
mbed_official 146:f64d43ff0c18 463 * mode on the chip family. Refer to reference manual for details about the
mbed_official 146:f64d43ff0c18 464 * stop mode.
mbed_official 146:f64d43ff0c18 465 *
mbed_official 146:f64d43ff0c18 466 *END**************************************************************************/
mbed_official 324:406fd2029f23 467 smc_stop_mode_t SMC_HAL_GetStopMode(uint32_t baseAddr)
mbed_official 146:f64d43ff0c18 468 {
mbed_official 324:406fd2029f23 469 return (smc_stop_mode_t)BR_SMC_PMCTRL_STOPM(baseAddr);
mbed_official 146:f64d43ff0c18 470 }
mbed_official 146:f64d43ff0c18 471
mbed_official 146:f64d43ff0c18 472 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 473 *
mbed_official 324:406fd2029f23 474 * Function Name : SMC_HAL_SetStopSubMode
mbed_official 146:f64d43ff0c18 475 * Description : Config the stop sub mode control setting
mbed_official 146:f64d43ff0c18 476 * This function will set the stop submode settings. Some of the stop mode will
mbed_official 146:f64d43ff0c18 477 * further have submode supported. Refer to smc_stop_submode_t for supported
mbed_official 146:f64d43ff0c18 478 * stop submode and Refer to reference manual for details about the submode
mbed_official 146:f64d43ff0c18 479 * for specific stop mode.
mbed_official 146:f64d43ff0c18 480 *
mbed_official 146:f64d43ff0c18 481 *END**************************************************************************/
mbed_official 324:406fd2029f23 482 void SMC_HAL_SetStopSubMode(uint32_t baseAddr, smc_stop_submode_t stopSubMode)
mbed_official 146:f64d43ff0c18 483 {
mbed_official 146:f64d43ff0c18 484 #if FSL_FEATURE_SMC_USE_VLLSCTRL_REG
mbed_official 324:406fd2029f23 485 BW_SMC_VLLSCTRL_VLLSM(baseAddr, stopSubMode);
mbed_official 146:f64d43ff0c18 486 #else
mbed_official 146:f64d43ff0c18 487 #if FSL_FEATURE_SMC_USE_STOPCTRL_VLLSM
mbed_official 324:406fd2029f23 488 BW_SMC_STOPCTRL_VLLSM(baseAddr, stopSubMode);
mbed_official 146:f64d43ff0c18 489 #else
mbed_official 324:406fd2029f23 490 BW_SMC_STOPCTRL_LLSM(baseAddr, stopSubMode);
mbed_official 146:f64d43ff0c18 491 #endif
mbed_official 146:f64d43ff0c18 492 #endif
mbed_official 146:f64d43ff0c18 493 }
mbed_official 146:f64d43ff0c18 494
mbed_official 146:f64d43ff0c18 495 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 496 *
mbed_official 324:406fd2029f23 497 * Function Name : SMC_HAL_GetStopSubMode
mbed_official 146:f64d43ff0c18 498 * Description : Get the current stop submode config
mbed_official 146:f64d43ff0c18 499 * This function will get the stop submode settings. Some of the stop mode will
mbed_official 146:f64d43ff0c18 500 * further have submode supported. Refer to smc_stop_submode_t for supported
mbed_official 146:f64d43ff0c18 501 * stop submode and Refer to reference manual for details about the submode
mbed_official 146:f64d43ff0c18 502 * for specific stop mode.
mbed_official 146:f64d43ff0c18 503 *
mbed_official 146:f64d43ff0c18 504 *END**************************************************************************/
mbed_official 324:406fd2029f23 505 smc_stop_submode_t SMC_HAL_GetStopSubMode(uint32_t baseAddr)
mbed_official 146:f64d43ff0c18 506 {
mbed_official 146:f64d43ff0c18 507 #if FSL_FEATURE_SMC_USE_VLLSCTRL_REG
mbed_official 324:406fd2029f23 508 return (smc_stop_submode_t)BR_SMC_VLLSCTRL_VLLSM(baseAddr);
mbed_official 146:f64d43ff0c18 509 #else
mbed_official 146:f64d43ff0c18 510 #if FSL_FEATURE_SMC_USE_STOPCTRL_VLLSM
mbed_official 324:406fd2029f23 511 return (smc_stop_submode_t)BR_SMC_STOPCTRL_VLLSM(baseAddr);
mbed_official 146:f64d43ff0c18 512 #else
mbed_official 324:406fd2029f23 513 return (smc_stop_submode_t)BR_SMC_STOPCTRL_LLSM(baseAddr);
mbed_official 146:f64d43ff0c18 514 #endif
mbed_official 146:f64d43ff0c18 515 #endif
mbed_official 146:f64d43ff0c18 516 }
mbed_official 146:f64d43ff0c18 517
mbed_official 146:f64d43ff0c18 518 #if FSL_FEATURE_SMC_HAS_PORPO
mbed_official 146:f64d43ff0c18 519 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 520 *
mbed_official 324:406fd2029f23 521 * Function Name : SMC_HAL_SetPorMode
mbed_official 146:f64d43ff0c18 522 * Description : Config the POR (power-on-reset) option
mbed_official 146:f64d43ff0c18 523 * This function will set the POR power option setting. It controls whether the
mbed_official 146:f64d43ff0c18 524 * POR detect circuit (for brown-out detection) is enabled in certain stop mode.
mbed_official 146:f64d43ff0c18 525 * The setting will be either enable or disable the above feature when POR
mbed_official 146:f64d43ff0c18 526 * happened. Refer to reference manual for details.
mbed_official 146:f64d43ff0c18 527 *
mbed_official 146:f64d43ff0c18 528 *END**************************************************************************/
mbed_official 324:406fd2029f23 529 void SMC_HAL_SetPorMode(uint32_t baseAddr, smc_por_option_t option)
mbed_official 146:f64d43ff0c18 530 {
mbed_official 146:f64d43ff0c18 531 #if FSL_FEATURE_SMC_USE_VLLSCTRL_REG
mbed_official 324:406fd2029f23 532 BW_SMC_VLLSCTRL_PORPO(baseAddr, option);
mbed_official 146:f64d43ff0c18 533 #else
mbed_official 324:406fd2029f23 534 BW_SMC_STOPCTRL_PORPO(baseAddr, option);
mbed_official 146:f64d43ff0c18 535 #endif
mbed_official 146:f64d43ff0c18 536 }
mbed_official 146:f64d43ff0c18 537
mbed_official 146:f64d43ff0c18 538 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 539 *
mbed_official 324:406fd2029f23 540 * Function Name : SMC_HAL_GetPorMode
mbed_official 146:f64d43ff0c18 541 * Description : Get the config of POR option
mbed_official 146:f64d43ff0c18 542 * This function will set the POR power option setting. See config function
mbed_official 146:f64d43ff0c18 543 * header for details.
mbed_official 146:f64d43ff0c18 544 *
mbed_official 146:f64d43ff0c18 545 *END**************************************************************************/
mbed_official 324:406fd2029f23 546 smc_por_option_t SMC_HAL_GetPorMode(uint32_t baseAddr)
mbed_official 146:f64d43ff0c18 547 {
mbed_official 146:f64d43ff0c18 548 #if FSL_FEATURE_SMC_USE_VLLSCTRL_REG
mbed_official 324:406fd2029f23 549 return (smc_por_option_t)BR_SMC_VLLSCTRL_PORPO(baseAddr);
mbed_official 146:f64d43ff0c18 550 #else
mbed_official 324:406fd2029f23 551 return (smc_por_option_t)BR_SMC_STOPCTRL_PORPO(baseAddr);
mbed_official 146:f64d43ff0c18 552 #endif
mbed_official 146:f64d43ff0c18 553 }
mbed_official 146:f64d43ff0c18 554 #endif
mbed_official 146:f64d43ff0c18 555
mbed_official 146:f64d43ff0c18 556 #if FSL_FEATURE_SMC_HAS_PSTOPO
mbed_official 146:f64d43ff0c18 557 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 558 *
mbed_official 324:406fd2029f23 559 * Function Name : SMC_HAL_GetPorMode
mbed_official 324:406fd2029f23 560 * Description : Config the PSTOPO (Partial Stop Option)
mbed_official 324:406fd2029f23 561 * This function will set the PSTOPO option. It controls whether a Partial
mbed_official 146:f64d43ff0c18 562 * Stop mode is entered when STOPM=STOP. When entering a Partial Stop mode from
mbed_official 146:f64d43ff0c18 563 * RUN mode, the PMC, MCG and flash remain fully powered, allowing the device
mbed_official 146:f64d43ff0c18 564 * to wakeup almost instantaneously at the expense of higher power consumption.
mbed_official 146:f64d43ff0c18 565 * In PSTOP2, only system clocks are gated allowing peripherals running on bus
mbed_official 146:f64d43ff0c18 566 * clock to remain fully functional. In PSTOP1, both system and bus clocks are
mbed_official 146:f64d43ff0c18 567 * gated. Refer to smc_pstop_option_t for supported options. Refer to reference
mbed_official 146:f64d43ff0c18 568 * manual for details.
mbed_official 146:f64d43ff0c18 569 *
mbed_official 146:f64d43ff0c18 570 *END**************************************************************************/
mbed_official 324:406fd2029f23 571 void SMC_HAL_SetPstopMode(uint32_t baseAddr, smc_pstop_option_t option)
mbed_official 146:f64d43ff0c18 572 {
mbed_official 324:406fd2029f23 573 BW_SMC_STOPCTRL_PSTOPO(baseAddr, option);
mbed_official 146:f64d43ff0c18 574 }
mbed_official 146:f64d43ff0c18 575
mbed_official 146:f64d43ff0c18 576 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 577 *
mbed_official 324:406fd2029f23 578 * Function Name : SMC_HAL_GetPorMode
mbed_official 146:f64d43ff0c18 579 * Description : Get the config of PSTOPO option
mbed_official 324:406fd2029f23 580 * This function will get the current PSTOPO option setting. Refer to config
mbed_official 146:f64d43ff0c18 581 * function for more details.
mbed_official 146:f64d43ff0c18 582 *
mbed_official 146:f64d43ff0c18 583 *END**************************************************************************/
mbed_official 324:406fd2029f23 584 smc_pstop_option_t SMC_HAL_GetPstopMode(uint32_t baseAddr)
mbed_official 146:f64d43ff0c18 585 {
mbed_official 324:406fd2029f23 586 return (smc_pstop_option_t)BR_SMC_STOPCTRL_PSTOPO(baseAddr);
mbed_official 146:f64d43ff0c18 587 }
mbed_official 146:f64d43ff0c18 588 #endif
mbed_official 146:f64d43ff0c18 589
mbed_official 146:f64d43ff0c18 590 #if FSL_FEATURE_SMC_HAS_LPOPO
mbed_official 146:f64d43ff0c18 591 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 592 *
mbed_official 324:406fd2029f23 593 * Function Name : SMC_HAL_GetPorMode
mbed_official 146:f64d43ff0c18 594 * Description : Config the LPO option setting
mbed_official 146:f64d43ff0c18 595 * This function will set the LPO option setting. It controls whether the 1kHZ
mbed_official 146:f64d43ff0c18 596 * LPO clock is enabled in certain lower power stop modes. Refer to
mbed_official 146:f64d43ff0c18 597 * smc_lpo_option_t for supported options and refer to reference manual for
mbed_official 146:f64d43ff0c18 598 * details about this option.
mbed_official 146:f64d43ff0c18 599 *
mbed_official 146:f64d43ff0c18 600 *END**************************************************************************/
mbed_official 324:406fd2029f23 601 void SMC_HAL_SetLpoMode(uint32_t baseAddr, smc_lpo_option_t option)
mbed_official 146:f64d43ff0c18 602 {
mbed_official 324:406fd2029f23 603 BW_SMC_STOPCTRL_LPOPO(baseAddr, option);
mbed_official 146:f64d43ff0c18 604 }
mbed_official 146:f64d43ff0c18 605
mbed_official 146:f64d43ff0c18 606 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 607 *
mbed_official 324:406fd2029f23 608 * Function Name : SMC_HAL_GetPorMode
mbed_official 146:f64d43ff0c18 609 * Description : Get the config of LPO option
mbed_official 146:f64d43ff0c18 610 * This function will get the current LPO option setting. Refer to config
mbed_official 146:f64d43ff0c18 611 * function for details.
mbed_official 146:f64d43ff0c18 612 *
mbed_official 146:f64d43ff0c18 613 *END**************************************************************************/
mbed_official 324:406fd2029f23 614 smc_por_option_t SMC_HAL_GetLpoMode(uint32_t baseAddr)
mbed_official 146:f64d43ff0c18 615 {
mbed_official 324:406fd2029f23 616 return (smc_por_option_t)BR_SMC_STOPCTRL_LPOPO(baseAddr);
mbed_official 146:f64d43ff0c18 617 }
mbed_official 146:f64d43ff0c18 618 #endif
mbed_official 146:f64d43ff0c18 619
mbed_official 146:f64d43ff0c18 620 #if FSL_FEATURE_SMC_HAS_LPWUI
mbed_official 146:f64d43ff0c18 621 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 622 *
mbed_official 324:406fd2029f23 623 * Function Name : SMC_HAL_SetLpwuiMode
mbed_official 146:f64d43ff0c18 624 * Description : Config the LPWUI (Low Power Wake Up on interrup) option
mbed_official 146:f64d43ff0c18 625 * This function will set the LPWUI option. It will cause the system to exit
mbed_official 146:f64d43ff0c18 626 * to normal RUN mode when any active interrupt occurs while in a certain lower
mbed_official 146:f64d43ff0c18 627 * power mode. Refer to smc_lpwui_option_t for supported options and refer to
mbed_official 146:f64d43ff0c18 628 * reference manual for more details about this option.
mbed_official 146:f64d43ff0c18 629 *
mbed_official 146:f64d43ff0c18 630 *END**************************************************************************/
mbed_official 324:406fd2029f23 631 void SMC_HAL_SetLpwuiMode(uint32_t baseAddr, smc_lpwui_option_t option)
mbed_official 146:f64d43ff0c18 632 {
mbed_official 324:406fd2029f23 633 BW_SMC_PMCTRL_LPWUI(baseAddr, option);
mbed_official 146:f64d43ff0c18 634 }
mbed_official 146:f64d43ff0c18 635
mbed_official 146:f64d43ff0c18 636 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 637 *
mbed_official 324:406fd2029f23 638 * Function Name : SMC_HAL_SetLpwuiMode
mbed_official 146:f64d43ff0c18 639 * Description : Get the current LPWUI option
mbed_official 146:f64d43ff0c18 640 * This function will get the LPWUI option. Refer to config function for more
mbed_official 146:f64d43ff0c18 641 * details.
mbed_official 146:f64d43ff0c18 642 *
mbed_official 146:f64d43ff0c18 643 *END**************************************************************************/
mbed_official 324:406fd2029f23 644 smc_lpwui_option_t SMC_HAL_GetLpwuiMode(uint32_t baseAddr)
mbed_official 146:f64d43ff0c18 645 {
mbed_official 324:406fd2029f23 646 return (smc_lpwui_option_t)BR_SMC_PMCTRL_LPWUI(baseAddr);
mbed_official 146:f64d43ff0c18 647 }
mbed_official 146:f64d43ff0c18 648 #endif
mbed_official 146:f64d43ff0c18 649
mbed_official 146:f64d43ff0c18 650 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 651 *
mbed_official 324:406fd2029f23 652 * Function Name : SMC_HAL_GetStat
mbed_official 146:f64d43ff0c18 653 * Description : Get the current power mode stat
mbed_official 146:f64d43ff0c18 654 * This function will return the current power mode stat. Once application is
mbed_official 146:f64d43ff0c18 655 * switching the power mode, it should always check the stat to make sure it
mbed_official 146:f64d43ff0c18 656 * runs into the specified mode or not. Also application will need to check
mbed_official 146:f64d43ff0c18 657 * this mode before switching to certain mode. The system will require that
mbed_official 146:f64d43ff0c18 658 * only certain mode could switch to other specific mode. Refer to the
mbed_official 146:f64d43ff0c18 659 * reference manual for details. Refer to _power_mode_stat for the meaning
mbed_official 146:f64d43ff0c18 660 * of the power stat
mbed_official 146:f64d43ff0c18 661 *
mbed_official 146:f64d43ff0c18 662 *END**************************************************************************/
mbed_official 324:406fd2029f23 663 uint8_t SMC_HAL_GetStat(uint32_t baseAddr)
mbed_official 146:f64d43ff0c18 664 {
mbed_official 324:406fd2029f23 665 return BR_SMC_PMSTAT_PMSTAT(baseAddr);
mbed_official 146:f64d43ff0c18 666 }
mbed_official 146:f64d43ff0c18 667
mbed_official 146:f64d43ff0c18 668 /*******************************************************************************
mbed_official 146:f64d43ff0c18 669 * EOF
mbed_official 146:f64d43ff0c18 670 ******************************************************************************/
mbed_official 146:f64d43ff0c18 671