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.
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:
At the same time, the function SMC_HAL_GetProtection() checks whether the specified modes are allowed.
|
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...
|
|
struct smc_power_mode_config_t |
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.
|
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
-
base | Base address for current SMC instance. |
powerModeConfig | Power 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
-
base | Base address for current SMC instance. |
allowedModes | Bitmap 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
-
base | Base address for current SMC instance. |
modes | Bitmap of the power modes to check. |
- Returns
- Bitmap of the allowed power modes.
static bool SMC_HAL_IsStopAbort |
( |
SMC_Type * |
base | ) |
|
|
inlinestatic |
- Parameters
-
base | Base address for current SMC instance. |
- Returns
- The previous stop mode entry status.
- Return values
-
true | The previous stop mode entry was aborted. |
false | The previous stop mode entry was successful. |
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
-
base | Base address for current SMC instance. |
- Returns
- Current power mode status.