EFM32 Wonder Gecko Software Documentation
efm32wg-doc-4.2.1
|
Energy Modes management driver. More...
Macros | |
#define | SLEEP_HW_LOW_ENERGY_BLOCK_ENABLED true |
#define | SLEEP_EM4_WAKEUP_CALLBACK_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_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_ForceSleepInEM4 (void) |
Force the device to go to EM4 without doing any checks. 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... | |
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 (EM1/EM2/EM3) to protect certain system states from being corrupted. This semaphore has limit set to maximum 255 locks.
#define SLEEP_HW_LOW_ENERGY_BLOCK_ENABLED true |
#define SLEEP_EM4_WAKEUP_CALLBACK_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 91 of file sleep.h.
Referenced by SLEEP_LowestEnergyModeGet().
typedef void(* SLEEP_CbFuncPtr_t) (SLEEP_EnergyMode_t) |
enum SLEEP_EnergyMode_t |
void SLEEP_Init | ( | SLEEP_CbFuncPtr_t | pSleepCb, |
SLEEP_CbFuncPtr_t | pWakeUpCb | ||
) |
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 137 of file sleep.c.
References RMU_ResetCauseClear(), RMU_ResetCauseGet(), RMU_RSTCAUSE_EM4WURST, and sleepEM4.
SLEEP_EnergyMode_t SLEEP_LowestEnergyModeGet | ( | void | ) |
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 333 of file sleep.c.
References SLEEP_LOWEST_ENERGY_MODE_DEFAULT, sleepEM0, sleepEM1, sleepEM2, and sleepEM3.
Referenced by SLEEP_Sleep().
SLEEP_EnergyMode_t SLEEP_Sleep | ( | void | ) |
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 183 of file sleep.c.
References INT_Disable(), INT_Enable(), SLEEP_LowestEnergyModeGet(), sleepEM0, sleepEM1, and sleepEM3.
void SLEEP_ForceSleepInEM4 | ( | void | ) |
This function unblocks the low energy sleep block then goes to EM4.
Definition at line 219 of file sleep.c.
References EMU_EM2UnBlock(), and sleepEM4.
void SLEEP_SleepBlockBegin | ( | SLEEP_EnergyMode_t | eMode | ) |
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:
|
Definition at line 255 of file sleep.c.
References EMU_EM2Block(), sleepEM1, sleepEM2, and sleepEM4.
Referenced by RTCDRV_Init(), and RTCDRV_StartTimer().
void SLEEP_SleepBlockEnd | ( | SLEEP_EnergyMode_t | eMode | ) |
Release restriction for entering certain energy mode. Every call of this function reduce 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 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:
|
Definition at line 299 of file sleep.c.
References EMU_EM2UnBlock(), sleepEM1, sleepEM2, and sleepEM4.
Referenced by RTCDRV_DeInit().