## HAL Power Modes Function Documentation

### Sys_PowerModes_SetWakeupConfig

void Sys_PowerModes_SetWakeupConfig(uint32_t wakeup_cfg)

Set up the wakeup configuration.

Initializes the ACS_WAKEUP_CFG register with the specified wakeup sources. Clears any wakeup event flags triggered during the initialization.

Location: power_modes.h:434

Parameters

Direction | Name | Description
--- | --- | ---
in | wakeup_cfg | (uint32_t) The wakeup configuration contained in the LowPowerModeCfg_t instance.

NOTE: This function will modify the ACS_WAKEUP_CFG register.

Example Code for Sys_PowerModes_SetWakeupConfig
// Using the default configuration, update wakeup sources app_lowpower_mode_cfg.wakeup_cfg = WAKEUP_DELAY_2 | WAKEUP_GPIO0_ENABLE | WAKEUP_GPIO0_FALLING | WAKEUP_GPIO1_ENABLE | WAKEUP_GPIO1_FALLING | WAKEUP_DCDC_OVERLOAD_DISABLE | WAKEUP_FIFO_ENABLE; // Initialize wakeup configuration before entering sleep Sys_PowerModes_SetWakeupConfig(app_lowpower_mode_cfg.wakeup_cfg);

### Sys_PowerModes_EnableWakeupSources

void Sys_PowerModes_EnableWakeupSources(uint32_t wakeup_src, uint32_t * p_wakeup_cfg)

Enable one or more wakeup sources.

Adds the provided wakeup source to the provided wakeup configuration and then enables the wakeup source in the ACS_WAKEUP_CFG register. The provided wakeup source can be several sources OR'd together to enable multiple at a time.

Location: power_modes.h:456

Parameters

Direction | Name | Description
--- | --- | ---
in | wakeup_src | (uint32_t) The wakeup sources to enable. Use the defined constants WAKEUP_DCDC_OVERLOAD_ENABLE, WAKEUP_GPIO*_FALLING, WAKEUP_GPIO*_ENABLE, WAKEUP_RTC_OVERFLOW_ENABLE, WAKEUP_FIFO_ENABLE.
in | p_wakeup_cfg | (uint32_t *) A pointer to the wakeup configuration in the LowPowerModeCfg_t instance.

NOTE: This function will only modify the corresponding source enable bits. The wakeup event flags are not cleared in the process.

Example Code for Sys_PowerModes_EnableWakeupSources
// Power Mode wakeup configuration enable Sys_PowerModes_EnableWakeupSources((WAKEUP_FIFO_ENABLE | WAKEUP_GPIO1_ENABLE), &app_lowpower_mode_cfg->wakeup_cfg);

### Sys_PowerModes_DisableWakeupSources

void Sys_PowerModes_DisableWakeupSources(uint32_t wakeup_src, uint32_t * p_wakeup_cfg)

Disable one or more wakeup sources.

Removes the provided wakeup source from the provided wakeup configuration and then disables the wakeup source in the ACS_WAKEUP_CFG register. The provided wakeup source can be several sources OR'd together to disable multiple at a time.

Location: power_modes.h:478

Parameters

Direction | Name | Description
--- | --- | ---
| wakeup_src |
in | p_wakeup_cfg | (uint32_t *) A pointer to the wakeup configuration in the LowPowerModeCfg_t instance.

NOTE: This function will only modify the corresponding source enable bits. The wakeup event flags are not cleared in the process.

Example Code for Sys_PowerModes_DisableWakeupSources
// Power Mode wakeup configuration disable Sys_PowerModes_DisableWakeupSources(WAKEUP_FIFO_ENABLE | WAKEUP_GPIO1_ENABLE), &app_lowpower_mode_cfg->wakeup_cfg);

### Sys_PowerModes_EnterPowerMode

void Sys_PowerModes_EnterPowerMode(LowPowerModeCfg_t * p_power_mode_cfg)

Enter a low-power mode based on the provided configuration.

Powers down the system according to the selected Power Mode and retention type. The system reawakens when a configured wakeup event occurs.

Location: power_modes.h:493

Parameters

Direction | Name | Description
--- | --- | ---
in | p_power_mode_cfg | (LowPowerModeCfg_t *) A pointer to the LowPowerModeCfg_t instance.

NOTE: This function will enter a low-power mode if there are no wakeup events or NVIC interrupts pending, otherwise it will continue to RUN mode and service pending events and interrupts. This function will modify the ACS_BOOT_CFG register.

Example Code for Sys_PowerModes_EnterPowerMode
// Define variables to store GPIO register states during sleep static uint32_t gpio_cfg[GPIO_PAD_COUNT] = {0}; static uint32_t gpio_output = 0; static uint32_t gpio_jtag_sw_pad_cfg = 0; // Define a function to save the GPIO register states static void App_GPIOSaveStates(void) { for (uint8_t i = 0; i < GPIO_PAD_COUNT; i++) { gpio_cfg[i] = GPIO->CFG[i]; } gpio_output = GPIO->OUTPUT_DATA; gpio_jtag_sw_pad_cfg = GPIO->JTAG_SW_PAD_CFG; } // Define a function to restore the GPIO register states static void App_GPIORestoreStates(void) { for (uint8_t i = 0; i < GPIO_PAD_COUNT; i++) { GPIO->CFG[i] = gpio_cfg[i]; } GPIO->OUTPUT_DATA = gpio_output; GPIO->JTAG_SW_PAD_CFG = gpio_jtag_sw_pad_cfg; } // Use the default low-power configuration and provide a resume address app_lowpower_mode_cfg.p_app_resume = App_MainLoop; // Add the peripheral (GPIO) save & restore functions to the config app_lowpower_mode_cfg.p_save_peripherals = App_GPIOSaveStates; app_lowpower_mode_cfg.p_save_peripherals = App_GPIORestoreStates; // Power Mode enter sleep with memory retention Sys_PowerModes_EnterPowerMode(&app_lowpower_mode_cfg);

### Sys_PowerModes_WakeupWithReset

void Sys_PowerModes_WakeupWithReset(LowPowerModeCfg_t * p_power_mode_cfg)

Wakeup from flash after a sleep reset.

Wakes up the system from flash after the system has awoken from a reset caused by Sleep Mode without retention.

Location: power_modes.h:504

Parameters

Direction | Name | Description
--- | --- | ---
in | p_power_mode_cfg | (LowPowerModeCfg_t *) A pointer to the LowPowerModeCfg_t instance.

NOTE: This function initializes the system after a wakeup with reset.

Example Code for Sys_PowerModes_WakeupWithReset
// Initialize the system after a wakeup where the system was reset (no retention). Sys_PowerModes_WakeupWithReset(&app_lowpower_mode_cfg);

### Sys_PowerModes_IdleUntilBBAwake

void Sys_PowerModes_IdleUntilBBAwake()

Place the system into Idle Mode until the baseband is awake.

Performs an atomic check to see if the baseband is awake and if not places the system into Idle Mode until the baseband related interrupt becomes pending.

Location: power_modes.h:512