Kinetis SDK v.1.3 API Reference Manual  Rev. 0
Freescale Semiconductor, Inc.
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages

Overview

The section describes the programming interface of the SMC HAL driver. The System Mode Controller (SMC) sequences the system in and out of all low-power stop and run modes. Specifically, it monitors events to trigger transitions between the power modes while controlling the power, clocks, and memories of the system to achieve the power consumption and functionality of that mode. It also provides a set of functions to configure the power mode protection, the power mode, and other configuration settings.

Power Mode Configuration APIs

The function SMC_HAL_SetMode() configures the power mode based on the configuration. If it cannot switch to the target mode directly, this function performs an internal check and chooses the right path.
If an interrupt or a reset occurs during a stop entry sequence, the SMC can abort the transition early without completely entering the stop mode. The function SMC_HAL_IsStopAbort() checks whether the previous stop mode entry was aborted.
To get the current power mode, use the function SMC_HAL_GetStat().

This is an example of the SMC manager APIs.

#include "fsl_smc_hal.h"
// power mode configuration structure //
// power mode and option mode //
smcConfig.powerModeName = kPowerModeRun;
// set the power mode //
SMC_HAL_SetMode(&smcConfig);

Power Mode Protection APIs

To configure the allowed power mode, use the function SMC_HAL_SetProtection() and pass the allowed power modes. This function should only be called once after system reset.
This example shows how to use this function:

#include "fsl_smc_hal.h"
// Allow LLS mode and VLLS mode.
SMC_HAL_SetProtection(SMC, kAllowPowerModeLls | kAllowPowerModeVlls);

At the same time, the function SMC_HAL_GetProtection() checks whether the specified modes are allowed.

Files

file  fsl_smc_hal.h
 

Data Structures

struct  smc_power_mode_config_t
 Power mode control configuration used for calling the SMC_SYS_SetPowerMode API. More...
 

Enumerations

enum  power_modes_t
 Power Modes.
 
enum  smc_hal_error_code_t {
  kSmcHalSuccess,
  kSmcHalNoSuchModeName,
  kSmcHalAlreadyInTheState,
  kSmcHalFailed
}
 Error code definition for the system mode controller manager APIs. More...
 
enum  power_mode_stat_t {
  kStatRun = 0x01U,
  kStatStop = 0x02U,
  kStatVlpr = 0x04U,
  kStatVlpw = 0x08U,
  kStatVlps = 0x10U,
  kStatVlls = 0x40U
}
 Power Modes in PMSTAT. More...
 
enum  power_modes_protect_t {
  kAllowPowerModeVlls = SMC_PMPROT_AVLLS_MASK,
  kAllowPowerModeVlp = SMC_PMPROT_AVLP_MASK,
  kAllowPowerModeAll
}
 Power Modes Protection. More...
 
enum  smc_run_mode_t {
  kSmcRun ,
  kSmcVlpr
}
 Run mode definition. More...
 
enum  smc_stop_mode_t {
  kSmcStop = 0U,
  kSmcReservedStop1 = 1U,
  kSmcVlps = 2U,
  kSmcVlls = 4U
}
 Stop mode definition. More...
 
enum  smc_stop_submode_t {
  kSmcStopSub0,
  kSmcStopSub1,
  kSmcStopSub2,
  kSmcStopSub3
}
 VLLS/LLS stop sub mode definition. More...
 
enum  smc_lpwui_option_t {
  kSmcLpwuiDisabled,
  kSmcLpwuiEnabled
}
 Low Power Wake Up on Interrupt option. More...
 
enum  smc_pstop_option_t {
  kSmcPstopStop,
  kSmcPstopStop1,
  kSmcPstopStop2
}
 Partial STOP option. More...
 
enum  smc_por_option_t {
  kSmcPorEnabled,
  kSmcPorDisabled
}
 POR option. More...
 
enum  smc_ram2_option_t {
  kSmcRam2DisPowered,
  kSmcRam2Powered
}
 RAM2 power option. More...
 
enum  smc_lpo_option_t {
  kSmcLpoEnabled,
  kSmcLpoDisabled
}
 LPO power option. More...
 

System mode controller APIs

smc_hal_error_code_t SMC_HAL_SetMode (SMC_Type *base, const smc_power_mode_config_t *powerModeConfig)
 Configures the power mode. More...
 
static void SMC_HAL_SetProtection (SMC_Type *base, uint8_t allowedModes)
 Configures all power mode protection settings. More...
 
static uint8_t SMC_HAL_GetProtection (SMC_Type *base, uint8_t modes)
 Gets the power mode protection setting. More...
 
static bool SMC_HAL_IsStopAbort (SMC_Type *base)
 Checks whether the previous stop mode entry was successful. More...
 
power_mode_stat_t SMC_HAL_GetStat (SMC_Type *base)
 Gets the current power mode status. More...
 

Data Structure Documentation

struct smc_power_mode_config_t

Data Fields

power_modes_t powerModeName
 Power mode(enum), see power_modes_t.
 
smc_stop_submode_t stopSubMode
 Stop submode(enum), see smc_stop_submode_t.
 

Enumeration Type Documentation

Enumerator
kSmcHalSuccess 

Success.

kSmcHalNoSuchModeName 

Cannot find the mode name specified.

kSmcHalAlreadyInTheState 

Already in the required state.

kSmcHalFailed 

Unknown error, operation failed.

Enumerator
kStatRun 

0000_0001 - Current power mode is RUN

kStatStop 

0000_0010 - Current power mode is STOP

kStatVlpr 

0000_0100 - Current power mode is VLPR

kStatVlpw 

0000_1000 - Current power mode is VLPW

kStatVlps 

0001_0000 - Current power mode is VLPS

kStatVlls 

0100_0000 - Current power mode is VLLS

Enumerator
kAllowPowerModeVlls 

Allow Very-Low-Leakage Stop Mode.

kAllowPowerModeVlp 

Allow Very-Low-Power Modes.

kAllowPowerModeAll 

Allow all power modes.

Enumerator
kSmcRun 

normal RUN mode

kSmcVlpr 

Very-Low-Power RUN mode.

Enumerator
kSmcStop 

Normal STOP mode.

kSmcReservedStop1 

Reserved.

kSmcVlps 

Very-Low-Power STOP mode.

kSmcVlls 

Very-Low-Leakage Stop mode.

Enumerator
kSmcStopSub0 

Stop submode 0, for VLLS0/LLS0.

kSmcStopSub1 

Stop submode 1, for VLLS1/LLS1.

kSmcStopSub2 

Stop submode 2, for VLLS2/LLS2.

kSmcStopSub3 

Stop submode 3, for VLLS3/LLS3.

Enumerator
kSmcLpwuiDisabled 

Low Power Wake Up on Interrupt disabled.

kSmcLpwuiEnabled 

Low Power Wake Up on Interrupt enabled.

Enumerator
kSmcPstopStop 

STOP - Normal Stop mode.

kSmcPstopStop1 

Partial Stop with both system and bus clocks disabled.

kSmcPstopStop2 

Partial Stop with system clock disabled and bus clock enabled.

Enumerator
kSmcPorEnabled 

POR detect circuit is enabled in VLLS0.

kSmcPorDisabled 

POR detect circuit is disabled in VLLS0.

Enumerator
kSmcRam2DisPowered 

RAM2 not powered in LLS2/VLLS2.

kSmcRam2Powered 

RAM2 powered in LLS2/VLLS2.

Enumerator
kSmcLpoEnabled 

LPO clock is enabled in LLS/VLLSx.

kSmcLpoDisabled 

LPO clock is disabled in LLS/VLLSx.

Function Documentation

smc_hal_error_code_t SMC_HAL_SetMode ( SMC_Type *  base,
const smc_power_mode_config_t powerModeConfig 
)

This function configures the power mode base on configuration structure. If it not possible to switch to the target mode directly, this function checks internally and chooses the right path.

Parameters
baseBase address for current SMC instance.
powerModeConfigPower mode configuration structure smc_power_mode_config_t
Returns
SMC error code.
static void SMC_HAL_SetProtection ( SMC_Type *  base,
uint8_t  allowedModes 
)
inlinestatic

This function configures the power mode protection settings for supported power modes in the specified chip family. The available power modes are defined in the power_modes_protect_t. This should be done at an early system level initialization stage. See the reference manual for details. This register can only write once after the power reset.

The allowed modes are passed as bit map, for example, to allow LLS and VLLS, use SMC_HAL_SetProtection(SMC, kAllowPowerModeLls | kAllowPowerModeVlls). To allow all modes, use SMC_HAL_SetProtection(SMC, kAllowPowerModeAll).

Parameters
baseBase address for current SMC instance.
allowedModesBitmap of the allowed power modes.
static uint8_t SMC_HAL_GetProtection ( SMC_Type *  base,
uint8_t  modes 
)
inlinestatic

This function checks whether the power modes are allowed. The modes to check are passed as a bit map, for example, to check LLS and VLLS, use SMC_HAL_GetProtection(SMC, kAllowPowerModeLls | kAllowPowerModeVlls). To test all modes, use SMC_HAL_GetProtection(SMC, kAllowPowerModeAll).

Parameters
baseBase address for current SMC instance.
modesBitmap of the power modes to check.
Returns
Bitmap of the allowed power modes.
static bool SMC_HAL_IsStopAbort ( SMC_Type *  base)
inlinestatic
Parameters
baseBase address for current SMC instance.
Returns
The previous stop mode entry status.
Return values
trueThe previous stop mode entry was aborted.
falseThe previous stop mode entry was successful.
power_mode_stat_t SMC_HAL_GetStat ( SMC_Type *  base)

This function returns the current power mode stat. Once application switches the power mode, it should always check the stat to check whether it runs into the specified mode or not. An application should check this mode before switching to a different mode. The system requires that only certain modes can switch to other specific modes. See the reference manual for details and the _power_mode_stat for information about the power stat.

Parameters
baseBase address for current SMC instance.
Returns
Current power mode status.