EFR32 Blue Gecko 12 Software Documentation
efr32bg12-doc-5.1.2
|
Energy Modes management driver.
Energy Modes Management Driver.
This is a energy modes management module consisting of sleep.c and sleep.h source files. The main purpose of the module is to ease energy optimization with a simple API. The module allows the system to always sleep in the lowest possible energy mode. Users could set up callbacks that are being called before and after each and every sleep. A counting semaphore is available for each low energy mode (EM2/EM3) to protect certain system states from being corrupted. This semaphore has limit set to maximum 255 locks.
Macros | |
#define | SLEEP_EM4_WAKEUP_CALLBACK_ENABLED true |
#define | SLEEP_HW_LOW_ENERGY_BLOCK_ENABLED true |
#define | SLEEP_LOWEST_ENERGY_MODE_DEFAULT sleepEM3 |
Typedefs | |
typedef void(* | SLEEP_CbFuncPtr_t) (SLEEP_EnergyMode_t) |
Enumerations | |
enum | SLEEP_EnergyMode_t { sleepEM0 = 0, sleepEM1 = 1, sleepEM2 = 2, sleepEM3 = 3, sleepEM4 = 4 } |
Functions | |
void | SLEEP_ForceSleepInEM4 (void) |
Force the device to go to EM4 without doing any checks. More... | |
void | SLEEP_Init (SLEEP_CbFuncPtr_t pSleepCb, SLEEP_CbFuncPtr_t pWakeUpCb) |
Initialize the Sleep module. More... | |
SLEEP_EnergyMode_t | SLEEP_LowestEnergyModeGet (void) |
Gets the lowest energy mode that the system is allowed to be set to. More... | |
SLEEP_EnergyMode_t | SLEEP_Sleep (void) |
Sets the system to sleep into the lowest possible energy mode. More... | |
void | SLEEP_SleepBlockBegin (SLEEP_EnergyMode_t eMode) |
Begin sleep block in the requested energy mode. More... | |
void | SLEEP_SleepBlockEnd (SLEEP_EnergyMode_t eMode) |
End sleep block in the requested energy mode. More... | |
#define SLEEP_EM4_WAKEUP_CALLBACK_ENABLED true |
#define SLEEP_HW_LOW_ENERGY_BLOCK_ENABLED true |
#define SLEEP_LOWEST_ENERGY_MODE_DEFAULT sleepEM3 |
Configure default lowest energy mode that the system can be set to. Possible values:
Definition at line 90 of file sleep.h.
Referenced by SLEEP_LowestEnergyModeGet().
typedef void(* SLEEP_CbFuncPtr_t) (SLEEP_EnergyMode_t) |
enum SLEEP_EnergyMode_t |
void SLEEP_ForceSleepInEM4 | ( | void | ) |
Force the device to go to EM4 without doing any checks.
This function unblocks the low energy sleep block then goes to EM4.
Definition at line 214 of file sleep.c.
References EMU_EM2UnBlock(), and sleepEM4.
void SLEEP_Init | ( | SLEEP_CbFuncPtr_t | pSleepCb, |
SLEEP_CbFuncPtr_t | pWakeUpCb | ||
) |
Initialize the Sleep module.
Use this function to initialize the Sleep module, should be called only once! Pointers to sleep and wake-up callback functions shall be provided when calling this function. If SLEEP_EM4_WAKEUP_CALLBACK_ENABLED is set to true, this function checks for the cause of the reset that implicitly called it and calls the wakeup callback if the reset was a wakeup from EM4 (does not work on Gecko MCU).
[in] | pSleepCb | Pointer to the callback function that is being called before the device is going to sleep. |
[in] | pWakeUpCb | Pointer to the callback function that is being called after wake up. |
Definition at line 131 of file sleep.c.
References RMU_ResetCauseClear(), RMU_ResetCauseGet(), RMU_RSTCAUSE_EM4RST, and sleepEM4.
SLEEP_EnergyMode_t SLEEP_LowestEnergyModeGet | ( | void | ) |
Gets the lowest energy mode that the system is allowed to be set to.
This function uses the low energy mode block counters to determine the lowest possible that the system is allowed to be set to.
Definition at line 331 of file sleep.c.
References SLEEP_LOWEST_ENERGY_MODE_DEFAULT, sleepEM1, sleepEM2, and sleepEM3.
Referenced by SLEEP_Sleep().
SLEEP_EnergyMode_t SLEEP_Sleep | ( | void | ) |
Sets the system to sleep into the lowest possible energy mode.
This function takes care of the system states protected by the sleep block provided by SLEEP_SleepBlockBegin() / SLEEP_SleepBlockEnd(). It allows the system to go into the lowest possible energy mode that the device can be set into at the time of the call of this function. This function will not go lower than EM3 because leaving EM4 requires resetting MCU. To enter into EM4 call SLEEP_ForceSleepInEM4().
Definition at line 179 of file sleep.c.
References CORE_DECLARE_IRQ_STATE, CORE_ENTER_CRITICAL, CORE_EXIT_CRITICAL, SLEEP_LowestEnergyModeGet(), sleepEM0, sleepEM1, and sleepEM3.
void SLEEP_SleepBlockBegin | ( | SLEEP_EnergyMode_t | eMode | ) |
Begin sleep block in the requested energy mode.
Blocking a critical system state from a certain energy mode makes sure that the system is not set to that energy mode while the block is not being released. Every SLEEP_SleepBlockBegin() increases the corresponding counter and every SLEEP_SleepBlockEnd() decreases it.
Example:
[in] | eMode | Energy mode to begin to block. Possible values:
|
Example:
[in] | eMode | Energy mode to begin to block. Possible values:
|
Definition at line 249 of file sleep.c.
References EMU_EM2Block(), sleepEM2, sleepEM3, and sleepEM4.
Referenced by RTCDRV_Init(), and RTCDRV_StartTimer().
void SLEEP_SleepBlockEnd | ( | SLEEP_EnergyMode_t | eMode | ) |
End sleep block in the requested energy mode.
Release restriction for entering certain energy mode. Every call of this function reduce the blocking counter by 1. Once the counter for specific energy mode is 0 and all counters for lower energy modes are 0 as well, using a particular energy mode is allowed. Every SLEEP_SleepBlockBegin() increases the corresponding counter and every SLEEP_SleepBlockEnd() decreases it.
Example:
[in] | eMode | Energy mode to end to block. Possible values:
|
Example:
[in] | eMode | Energy mode to end to block. Possible values:
|
Definition at line 295 of file sleep.c.
References EMU_EM2UnBlock(), sleepEM2, sleepEM3, and sleepEM4.
Referenced by RTCDRV_DeInit().