Sleep
Functionality to help when putting the system to an EM2/EM3/EM4 sleep states where the high frequency clock is disabled.
Enumerations | |
enum | RAIL_SleepConfig_t { RAIL_SLEEP_CONFIG_TIMERSYNC_DISABLED, RAIL_SLEEP_CONFIG_TIMERSYNC_ENABLED } |
The configuration. |
Functions | |
RAIL_Status_t | RAIL_ConfigSleep (RAIL_Handle_t railHandle, RAIL_SleepConfig_t sleepConfig) |
Initialize RAIL timer synchronization. | |
RAIL_Status_t | RAIL_Sleep (uint16_t wakeupProcessTime, bool *deepSleepAllowed) |
Stop the RAIL timer and prepare RAIL for sleep. | |
RAIL_Status_t | RAIL_Wake (RAIL_Time_t elapsedTime) |
Wake RAIL from sleep and restart the RAIL timer. |
Detailed Description
Functionality to help when putting the system to an EM2/EM3/EM4 sleep states where the high frequency clock is disabled.
The RAIL library has its own timebase and the ability to schedule operations into the future. When going to any power mode that disables the HF clock used for the radio (EM2/EM3/EM4) it is important that this timebase is synchronized to a running LFCLK and the chip is set to wakeup before the next scheduled event. The APIs in this block are responsible for performing this synchronization. When synchronizing the time base there are two options:
Sleep with timer synchronization:
When sleeping with timer synchronization you must first get the required LFCLK up and running and leave it running across sleep so that the high frequency clock that drives the RAIL time base can be synchronized to it. The RAIL_Sleep() API will also setup a wake event on the timer to wake up wakeupTime before the next timer event so that it can run successfully. See the EFR32 sections on Low-Frequency Clocks and RAIL Timer Synchronization for more setup details.
This is useful for scenarios where you want to maintain packet timestamps across sleep or use the scheduled Rx/Tx APIs while sleeping in between. It does take more time and code to do this synchronization so if your application does not need this it should be avoided.
Example:
Sleep without timer synchronization:
When sleeping without timer synchronization you are free to enable only the LFCLK's and wake sources required by the application. RAIL will not attempt to configure any wake events and may miss anything that occurs over sleep.
This is useful for scenarios where your application does not care about packet timestamps or scheduling operations accurately over sleep.
Example:
Enumeration Type Documentation
◆ RAIL_SleepConfig_t
enum RAIL_SleepConfig_t |
Function Documentation
◆ RAIL_ConfigSleep()
RAIL_Status_t RAIL_ConfigSleep | ( | RAIL_Handle_t | railHandle, |
RAIL_SleepConfig_t | sleepConfig |
||
) |
Initialize RAIL timer synchronization.
- Parameters
-
[in] railHandle
A RAIL instance handle. [in] sleepConfig
A sleep configuration.
- Returns
- Status code indicating success of the function call.
◆ RAIL_Sleep()
RAIL_Status_t RAIL_Sleep | ( | uint16_t | wakeupProcessTime, |
bool * | deepSleepAllowed |
||
) |
Stop the RAIL timer and prepare RAIL for sleep.
- Parameters
-
[in] wakeupProcessTime
Time in microseconds that the application and hardware need to recover from sleep state. [out] deepSleepAllowed
true - system can go to deep sleep. false - system should not go to deep sleep. Deep sleep should be blocked in this case.
- Returns
- Status code indicating success of the function call.
- Warning
- The active RAIL configuration must be idle to enable sleep.
◆ RAIL_Wake()
RAIL_Status_t RAIL_Wake | ( | RAIL_Time_t | elapsedTime | ) |
Wake RAIL from sleep and restart the RAIL timer.
- Parameters
-
[in] elapsedTime
Add the sleep duration to the RAIL timer before restarting the RAIL timer.
- Returns
- Status code indicating success of the function call.
If the timer sync was enabled by RAIL_ConfigSleep, synchronize the RAIL timer using an alternate timer. Otherwise, add elapsedTime to the RAIL timer.