MCUXpresso SDK API Reference Manual  Rev. 0
NXP Semiconductors
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
SMC: System Mode Controller Driver

Data Structures

struct  smc_version_id_t
 IP version ID definition. More...
 
struct  smc_param_t
 IP parameter definition. More...
 
struct  smc_power_mode_lls_config_t
 SMC Low-Leakage Stop power mode configuration. More...
 
struct  smc_power_mode_vlls_config_t
 SMC Very Low-Leakage Stop power mode configuration. More...
 

Enumerations

enum  smc_power_mode_protection_t {
  kSMC_AllowPowerModeVlls = SMC_PMPROT_AVLLS_MASK,
  kSMC_AllowPowerModeLls = SMC_PMPROT_ALLS_MASK,
  kSMC_AllowPowerModeVlp = SMC_PMPROT_AVLP_MASK,
  kSMC_AllowPowerModeHsrun = SMC_PMPROT_AHSRUN_MASK,
  kSMC_AllowPowerModeAll
}
 Power Modes Protection. More...
 
enum  smc_power_state_t {
  kSMC_PowerStateRun = 0x01U << 0U,
  kSMC_PowerStateStop = 0x01U << 1U,
  kSMC_PowerStateVlpr = 0x01U << 2U,
  kSMC_PowerStateVlpw = 0x01U << 3U,
  kSMC_PowerStateVlps = 0x01U << 4U,
  kSMC_PowerStateLls = 0x01U << 5U,
  kSMC_PowerStateVlls = 0x01U << 6U,
  kSMC_PowerStateHsrun = 0x01U << 7U
}
 Power Modes in PMSTAT. More...
 
enum  smc_run_mode_t {
  kSMC_RunNormal = 0U,
  kSMC_RunVlpr = 2U,
  kSMC_Hsrun = 3U
}
 Run mode definition. More...
 
enum  smc_stop_mode_t {
  kSMC_StopNormal = 0U,
  kSMC_StopVlps = 2U,
  kSMC_StopLls = 3U,
  kSMC_StopVlls = 4U
}
 Stop mode definition. More...
 
enum  smc_stop_submode_t {
  kSMC_StopSub0 = 0U,
  kSMC_StopSub1 = 1U,
  kSMC_StopSub2 = 2U,
  kSMC_StopSub3 = 3U
}
 VLLS/LLS stop sub mode definition. More...
 
enum  smc_partial_stop_option_t {
  kSMC_PartialStop = 0U,
  kSMC_PartialStop1 = 1U,
  kSMC_PartialStop2 = 2U
}
 Partial STOP option. More...
 
enum  _smc_status { kStatus_SMC_StopAbort = MAKE_STATUS(kStatusGroup_POWER, 0) }
 SMC configuration status. More...
 

Driver version

#define FSL_SMC_DRIVER_VERSION   (MAKE_VERSION(2, 0, 6))
 SMC driver version 2.0.6. More...
 

System mode controller APIs

static void SMC_GetVersionId (SMC_Type *base, smc_version_id_t *versionId)
 Gets the SMC version ID. More...
 
void SMC_GetParam (SMC_Type *base, smc_param_t *param)
 Gets the SMC parameter. More...
 
static void SMC_SetPowerModeProtection (SMC_Type *base, uint8_t allowedModes)
 Configures all power mode protection settings. More...
 
static smc_power_state_t SMC_GetPowerModeState (SMC_Type *base)
 Gets the current power mode status. More...
 
void SMC_PreEnterStopModes (void)
 Prepares to enter stop modes. More...
 
void SMC_PostExitStopModes (void)
 Recovers after wake up from stop modes. More...
 
void SMC_PreEnterWaitModes (void)
 Prepares to enter wait modes. More...
 
void SMC_PostExitWaitModes (void)
 Recovers after wake up from stop modes. More...
 
status_t SMC_SetPowerModeRun (SMC_Type *base)
 Configures the system to RUN power mode. More...
 
status_t SMC_SetPowerModeHsrun (SMC_Type *base)
 Configures the system to HSRUN power mode. More...
 
status_t SMC_SetPowerModeWait (SMC_Type *base)
 Configures the system to WAIT power mode. More...
 
status_t SMC_SetPowerModeStop (SMC_Type *base, smc_partial_stop_option_t option)
 Configures the system to Stop power mode. More...
 
status_t SMC_SetPowerModeVlpr (SMC_Type *base)
 Configures the system to VLPR power mode. More...
 
status_t SMC_SetPowerModeVlpw (SMC_Type *base)
 Configures the system to VLPW power mode. More...
 
status_t SMC_SetPowerModeVlps (SMC_Type *base)
 Configures the system to VLPS power mode. More...
 
status_t SMC_SetPowerModeLls (SMC_Type *base, const smc_power_mode_lls_config_t *config)
 Configures the system to LLS power mode. More...
 
status_t SMC_SetPowerModeVlls (SMC_Type *base, const smc_power_mode_vlls_config_t *config)
 Configures the system to VLLS power mode. More...
 

Detailed Description

The MCUXpresso SDK provides a peripheral driver for the System Mode Controller (SMC) module of MCUXpresso SDK devices. The SMC module sequences the system in and out of all low-power stop and run modes.

API functions are provided to configure the system for working in a dedicated power mode. For different power modes, SMC_SetPowerModexxx() function accepts different parameters. System power mode state transitions are not available between power modes. For details about available transitions, see the power mode transitions section in the SoC reference manual.

Typical use case

Enter wait or stop modes

SMC driver provides APIs to set MCU to different wait modes and stop modes. Pre and post functions are used for setting the modes. The pre functions and post functions are used as follows.

Disable/enable the interrupt through PRIMASK. This is an example use case. The application sets the wakeup interrupt and calls SMC function SMC_SetPowerModeStop to set the MCU to STOP mode, but the wakeup interrupt happens so quickly that the ISR completes before the function SMC_SetPowerModeStop. As a result, the MCU enters the STOP mode and never is woken up by the interrupt. In this use case, the application first disables the interrupt through PRIMASK, sets the wakeup interrupt, and enters the STOP mode. After wakeup, enable the interrupt through PRIMASK. The MCU can still be woken up by disabling the interrupt through PRIMASK. The pre and post functions handle the PRIMASK.

/* Enable the wakeup interrupt here. */

For legacy Kinetis, when entering stop modes, the flash speculation might be interrupted. As a result, the prefetched code or data might be broken. To make sure the flash is idle when entring the stop modes, smc driver allocates a RAM region, the code to enter stop modes are excuted in RAM, thus the flash is idle and no prefetch is performed while entring stop modes. Application should make sure that, the rw data of fsl_smc.c is located in memory region which is not powered off in stop modes, especially LLS2 modes.

For STOP, VLPS, and LLS3, the whole RAM are powered up, so after woken up, the RAM function could continue excuting. For VLLS mode, the system resets after woken up, the RAM content might be re-initialized. For LLS2 mode, only part of RAM are powered on, so application must make sure that, the rw data of fsl_smc.c is located in memory region which is not powered off, otherwise after woken up, the MCU could not get right code to excute.


Data Structure Documentation

struct smc_version_id_t

Data Fields

uint16_t feature
 Feature Specification Number. More...
 
uint8_t minor
 Minor version number. More...
 
uint8_t major
 Major version number. More...
 

Field Documentation

uint16_t smc_version_id_t::feature
uint8_t smc_version_id_t::minor
uint8_t smc_version_id_t::major
struct smc_param_t

Data Fields

bool hsrunEnable
 HSRUN mode enable. More...
 
bool llsEnable
 LLS mode enable. More...
 
bool lls2Enable
 LLS2 mode enable. More...
 
bool vlls0Enable
 VLLS0 mode enable. More...
 

Field Documentation

bool smc_param_t::hsrunEnable
bool smc_param_t::llsEnable
bool smc_param_t::lls2Enable
bool smc_param_t::vlls0Enable
struct smc_power_mode_lls_config_t

Data Fields

smc_stop_submode_t subMode
 Low-leakage Stop sub-mode.
 
bool enableLpoClock
 Enable LPO clock in LLS mode.
 
struct smc_power_mode_vlls_config_t

Data Fields

smc_stop_submode_t subMode
 Very Low-leakage Stop sub-mode.
 
bool enablePorDetectInVlls0
 Enable Power on reset detect in VLLS mode.
 
bool enableLpoClock
 Enable LPO clock in VLLS mode.
 

Macro Definition Documentation

#define FSL_SMC_DRIVER_VERSION   (MAKE_VERSION(2, 0, 6))

Enumeration Type Documentation

Enumerator
kSMC_AllowPowerModeVlls 

Allow Very-low-leakage Stop Mode.

kSMC_AllowPowerModeLls 

Allow Low-leakage Stop Mode.

kSMC_AllowPowerModeVlp 

Allow Very-Low-power Mode.

kSMC_AllowPowerModeHsrun 

Allow High-speed Run mode.

kSMC_AllowPowerModeAll 

Allow all power mode.

Enumerator
kSMC_PowerStateRun 

0000_0001 - Current power mode is RUN

kSMC_PowerStateStop 

0000_0010 - Current power mode is STOP

kSMC_PowerStateVlpr 

0000_0100 - Current power mode is VLPR

kSMC_PowerStateVlpw 

0000_1000 - Current power mode is VLPW

kSMC_PowerStateVlps 

0001_0000 - Current power mode is VLPS

kSMC_PowerStateLls 

0010_0000 - Current power mode is LLS

kSMC_PowerStateVlls 

0100_0000 - Current power mode is VLLS

kSMC_PowerStateHsrun 

1000_0000 - Current power mode is HSRUN

Enumerator
kSMC_RunNormal 

Normal RUN mode.

kSMC_RunVlpr 

Very-low-power RUN mode.

kSMC_Hsrun 

High-speed Run mode (HSRUN).

Enumerator
kSMC_StopNormal 

Normal STOP mode.

kSMC_StopVlps 

Very-low-power STOP mode.

kSMC_StopLls 

Low-leakage Stop mode.

kSMC_StopVlls 

Very-low-leakage Stop mode.

Enumerator
kSMC_StopSub0 

Stop submode 0, for VLLS0/LLS0.

kSMC_StopSub1 

Stop submode 1, for VLLS1/LLS1.

kSMC_StopSub2 

Stop submode 2, for VLLS2/LLS2.

kSMC_StopSub3 

Stop submode 3, for VLLS3/LLS3.

Enumerator
kSMC_PartialStop 

STOP - Normal Stop mode.

kSMC_PartialStop1 

Partial Stop with both system and bus clocks disabled.

kSMC_PartialStop2 

Partial Stop with system clock disabled and bus clock enabled.

Enumerator
kStatus_SMC_StopAbort 

Entering Stop mode is abort.

Function Documentation

static void SMC_GetVersionId ( SMC_Type *  base,
smc_version_id_t versionId 
)
inlinestatic

This function gets the SMC version ID, including major version number, minor version number, and feature specification number.

Parameters
baseSMC peripheral base address.
versionIdPointer to the version ID structure.
void SMC_GetParam ( SMC_Type *  base,
smc_param_t param 
)

This function gets the SMC parameter including the enabled power mdoes.

Parameters
baseSMC peripheral base address.
paramPointer to the SMC param structure.
static void SMC_SetPowerModeProtection ( 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 smc_power_mode_protection_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_SetPowerModeProtection(kSMC_AllowPowerModeVlls | kSMC_AllowPowerModeVlps). To allow all modes, use SMC_SetPowerModeProtection(kSMC_AllowPowerModeAll).

Parameters
baseSMC peripheral base address.
allowedModesBitmap of the allowed power modes.
static smc_power_state_t SMC_GetPowerModeState ( SMC_Type *  base)
inlinestatic

This function returns the current power mode status. After the application switches the power mode, it should always check the status to check whether it runs into the specified mode or not. The 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 smc_power_state_t for information about the power status.

Parameters
baseSMC peripheral base address.
Returns
Current power mode status.
void SMC_PreEnterStopModes ( void  )

This function should be called before entering STOP/VLPS/LLS/VLLS modes.

void SMC_PostExitStopModes ( void  )

This function should be called after wake up from STOP/VLPS/LLS/VLLS modes. It is used with SMC_PreEnterStopModes.

void SMC_PreEnterWaitModes ( void  )

This function should be called before entering WAIT/VLPW modes.

void SMC_PostExitWaitModes ( void  )

This function should be called after wake up from WAIT/VLPW modes. It is used with SMC_PreEnterWaitModes.

status_t SMC_SetPowerModeRun ( SMC_Type *  base)
Parameters
baseSMC peripheral base address.
Returns
SMC configuration error code.
status_t SMC_SetPowerModeHsrun ( SMC_Type *  base)
Parameters
baseSMC peripheral base address.
Returns
SMC configuration error code.
status_t SMC_SetPowerModeWait ( SMC_Type *  base)
Parameters
baseSMC peripheral base address.
Returns
SMC configuration error code.
status_t SMC_SetPowerModeStop ( SMC_Type *  base,
smc_partial_stop_option_t  option 
)
Parameters
baseSMC peripheral base address.
optionPartial Stop mode option.
Returns
SMC configuration error code.
status_t SMC_SetPowerModeVlpr ( SMC_Type *  base)
Parameters
baseSMC peripheral base address.
Returns
SMC configuration error code.
status_t SMC_SetPowerModeVlpw ( SMC_Type *  base)
Parameters
baseSMC peripheral base address.
Returns
SMC configuration error code.
status_t SMC_SetPowerModeVlps ( SMC_Type *  base)
Parameters
baseSMC peripheral base address.
Returns
SMC configuration error code.
status_t SMC_SetPowerModeLls ( SMC_Type *  base,
const smc_power_mode_lls_config_t config 
)
Parameters
baseSMC peripheral base address.
configThe LLS power mode configuration structure
Returns
SMC configuration error code.
status_t SMC_SetPowerModeVlls ( SMC_Type *  base,
const smc_power_mode_vlls_config_t config 
)
Parameters
baseSMC peripheral base address.
configThe VLLS power mode configuration structure.
Returns
SMC configuration error code.