rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
Typedefs | Functions | Variables
fsl_smc.c File Reference

Typedefs

typedef void(* smc_stop_ram_func_t) (void)
 

Functions

static void SMC_EnterStopRamFunc (void)
 
void SMC_GetParam (SMC_Type *base, smc_param_t *param)
 Gets the SMC parameter.
 
void SMC_PreEnterStopModes (void)
 Prepares to enter stop modes.
 
void SMC_PostExitStopModes (void)
 Recovers after wake up from stop modes.
 
void SMC_PreEnterWaitModes (void)
 Prepares to enter wait modes.
 
void SMC_PostExitWaitModes (void)
 Recovers after wake up from stop modes.
 
status_t SMC_SetPowerModeRun (SMC_Type *base)
 Configures the system to RUN power mode.
 
status_t SMC_SetPowerModeHsrun (SMC_Type *base)
 Configures the system to HSRUN power mode.
 
status_t SMC_SetPowerModeWait (SMC_Type *base)
 Configures the system to WAIT power mode.
 
status_t SMC_SetPowerModeStop (SMC_Type *base, smc_partial_stop_option_t option)
 Configures the system to Stop power mode.
 
status_t SMC_SetPowerModeVlpr (SMC_Type *base #if(defined(FSL_FEATURE_SMC_HAS_LPWUI) &&FSL_FEATURE_SMC_HAS_LPWUI), bool wakeupMode #endif)
 
status_t SMC_SetPowerModeVlpw (SMC_Type *base)
 Configures the system to VLPW power mode.
 
status_t SMC_SetPowerModeVlps (SMC_Type *base)
 Configures the system to VLPS power mode.
 
status_t SMC_SetPowerModeLls (SMC_Type *base #if((defined(FSL_FEATURE_SMC_HAS_LLS_SUBMODE) &&FSL_FEATURE_SMC_HAS_LLS_SUBMODE)||\‍(defined(FSL_FEATURE_SMC_HAS_LPOPO) &&FSL_FEATURE_SMC_HAS_LPOPO)), const smc_power_mode_lls_config_t *config #endif)
 
status_t SMC_SetPowerModeVlls (SMC_Type *base, const smc_power_mode_vlls_config_t *config)
 Configures the system to VLLS power mode.
 

Variables

static uint32_t g_savedPrimask
 
static uint16_t s_stopRamFuncArray []
 

Typedef Documentation

◆ smc_stop_ram_func_t

typedef void(* smc_stop_ram_func_t) (void)

Definition at line 21 of file fsl_smc.c.

Function Documentation

◆ SMC_EnterStopRamFunc()

static void SMC_EnterStopRamFunc ( void  )
static

Definition at line 69 of file fsl_smc.c.

70{
71 uint32_t ramFuncEntry = ((uint32_t)(s_stopRamFuncArray)) + 1U;
72 smc_stop_ram_func_t stopRamFunc = (smc_stop_ram_func_t)ramFuncEntry;
73 stopRamFunc();
74}
void(* smc_stop_ram_func_t)(void)
Definition fsl_smc.c:21
static uint16_t s_stopRamFuncArray[]
Definition fsl_smc.c:53

Referenced by SMC_SetPowerModeLls(), SMC_SetPowerModeStop(), SMC_SetPowerModeVlls(), and SMC_SetPowerModeVlps().

Here is the caller graph for this function:

◆ SMC_SetPowerModeLls()

status_t SMC_SetPowerModeLls ( SMC_Type *base #  if(defined(FSL_FEATURE_SMC_HAS_LLS_SUBMODE) &&FSL_FEATURE_SMC_HAS_LLS_SUBMODE)||\‍(defined(FSL_FEATURE_SMC_HAS_LPOPO) &&FSL_FEATURE_SMC_HAS_LPOPO),
const smc_power_mode_lls_config_t *config endif 
)

brief Configures the system to LLS power mode.

param base SMC peripheral base address. return SMC configuration error code.

Definition at line 338 of file fsl_smc.c.

345{
346 uint8_t reg;
347
348 /* configure to LLS mode */
349 reg = base->PMCTRL;
350 reg &= ~SMC_PMCTRL_STOPM_MASK;
351 reg |= (kSMC_StopLls << SMC_PMCTRL_STOPM_SHIFT);
352 base->PMCTRL = reg;
353
354/* configure LLS sub-mode*/
355#if (defined(FSL_FEATURE_SMC_HAS_LLS_SUBMODE) && FSL_FEATURE_SMC_HAS_LLS_SUBMODE)
356 reg = base->STOPCTRL;
357 reg &= ~SMC_STOPCTRL_LLSM_MASK;
358 reg |= ((uint32_t)config->subMode << SMC_STOPCTRL_LLSM_SHIFT);
359 base->STOPCTRL = reg;
360#endif /* FSL_FEATURE_SMC_HAS_LLS_SUBMODE */
361
362#if (defined(FSL_FEATURE_SMC_HAS_LPOPO) && FSL_FEATURE_SMC_HAS_LPOPO)
363 if (config->enableLpoClock)
364 {
365 base->STOPCTRL &= ~SMC_STOPCTRL_LPOPO_MASK;
366 }
367 else
368 {
369 base->STOPCTRL |= SMC_STOPCTRL_LPOPO_MASK;
370 }
371#endif /* FSL_FEATURE_SMC_HAS_LPOPO */
372
373 /* Set the SLEEPDEEP bit to enable deep sleep mode */
374 SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk;
375
376 /* read back to make sure the configuration valid before enter stop mode */
377 (void)base->PMCTRL;
379
380 /* check whether the power mode enter LLS mode succeed */
381 if (base->PMCTRL & SMC_PMCTRL_STOPA_MASK)
382 {
384 }
385 else
386 {
387 return kStatus_Success;
388 }
389}
static constexpr persistent_config_s * config
static void SMC_EnterStopRamFunc(void)
Definition fsl_smc.c:69
@ kStatus_Success
Definition fsl_common.h:159
@ kSMC_StopLls
Definition fsl_smc.h:101
@ kStatus_SMC_StopAbort
Definition fsl_smc.h:138
Here is the call graph for this function:

◆ SMC_SetPowerModeVlpr()

status_t SMC_SetPowerModeVlpr ( SMC_Type *base #  ifdefined(FSL_FEATURE_SMC_HAS_LPWUI) &&FSL_FEATURE_SMC_HAS_LPWUI,
bool wakeupMode #  endif 
)

brief Configures the system to VLPR power mode.

param base SMC peripheral base address. return SMC configuration error code.

Definition at line 247 of file fsl_smc.c.

253{
254 uint8_t reg;
255
256 reg = base->PMCTRL;
257#if (defined(FSL_FEATURE_SMC_HAS_LPWUI) && FSL_FEATURE_SMC_HAS_LPWUI)
258 /* configure whether the system remains in VLP mode on an interrupt */
259 if (wakeupMode)
260 {
261 /* exits to RUN mode on an interrupt */
262 reg |= SMC_PMCTRL_LPWUI_MASK;
263 }
264 else
265 {
266 /* remains in VLP mode on an interrupt */
267 reg &= ~SMC_PMCTRL_LPWUI_MASK;
268 }
269#endif /* FSL_FEATURE_SMC_HAS_LPWUI */
270
271 /* configure VLPR mode */
272 reg &= ~SMC_PMCTRL_RUNM_MASK;
273 reg |= (kSMC_RunVlpr << SMC_PMCTRL_RUNM_SHIFT);
274 base->PMCTRL = reg;
275
276 return kStatus_Success;
277}
@ kSMC_RunVlpr
Definition fsl_smc.h:87

Variable Documentation

◆ g_savedPrimask

uint32_t g_savedPrimask
static

◆ s_stopRamFuncArray

uint16_t s_stopRamFuncArray[]
static
Initial value:
= {
0x2000,
0x2808,
0xD202,
0xBF00,
0x1C40,
0xE7FA,
0xF3BF, 0x8F4F,
0xBF30,
0xF3BF, 0x8F6F,
0x4770,
}

Definition at line 53 of file fsl_smc.c.

53 {
54 0x2000, /* MOVS R0, #0 */
55 0x2808, /* CMP R0, #8 */
56 0xD202, /* BCS.N */
57 0xBF00, /* NOP */
58 0x1C40, /* ADDS R0, R0, #1 */
59 0xE7FA, /* B.N */
60 0xF3BF, 0x8F4F, /* DSB */
61 0xBF30, /* WFI */
62 0xF3BF, 0x8F6F, /* ISB */
63 0x4770, /* BX LR */
64};

Referenced by SMC_EnterStopRamFunc().

Go to the source code of this file.