HAL PWR How to Use ¶
- group PWR_How_To_Use
-
PWR peripheral overview ¶
This section provides an overview of the supply architecture for the different power domains and of the supply configuration controller.
This file provides firmware functions to manage the following features:
Wakeup pin management functions.
RTC domain write protection management functions.
Low power mode management functions.
Voltage monitoring management functions.
Item retention management functions.
I/O pull management functions.
How to use the PWR HAL module driver ¶
This module provides different sets of APIs that allow:
Manage the wakeup pin: Use a wakeup pin to wake up the system from low power modes.
Configure the wakeup pin polarity and pull without enabling it:
Call HAL_PWR_LP_SetConfigWakeupPin() to configure wakeup polarity and pull. Use the p_config pointer to provide the configuration.
When p_config is null, this function returns HAL_INVALID_PARAM.
Get the wakeup pin polarity and pull configuration:
Call HAL_PWR_LP_GetConfigWakeupPin() to get the wakeup pin polarity and pull configuration.
Enable, disable, and check the wakeup pin:
Call HAL_PWR_LP_EnableWakeupPin(), HAL_PWR_LP_DisableWakeupPin(), and HAL_PWR_LP_IsEnabledWakeupPin() to enable, disable, and check the wakeup pin.
Get and clean wakeup sources:
Call HAL_PWR_LP_GetWakeupSource() and HAL_PWR_LP_CleanWakeupSource() to read and clear wakeup sources.
Manage RTC domain write protection: After a system reset, the RTC domain is protected against possible unwanted write accesses.
Enable, disable, and check write protection for the RTC domain:
Call HAL_PWR_EnableRTCDomainWriteProtection(), HAL_PWR_DisableRTCDomainWriteProtection(), and HAL_PWR_IsEnabledRTCDomainWriteProtection() to enable, disable, and check write protection.
Manage low power mode: Use available power modes to reduce power consumption.
Clear the core pending event to clear the internal Cortex event before entering sleep or stop x mode:
Call HAL_PWR_ClearCorePendingEvent() to clear the core pending event.
Enter the MCU into low power modes:
Enter the MCU into sleep mode through a WFE or WFI request:
Call HAL_PWR_EnterSleepMode() to enter sleep mode.
Enter the MCU into stop x mode through a WFE or WFI request:
Call HAL_PWR_EnterStopMode() to enter stop x mode.
Enter the MCU into standby mode:
Call HAL_PWR_EnterStandbyMode() to enter standby mode.
Configure the core deep sleep mode:
Call HAL_PWR_SetCoreSleepMode() to configure the core deep sleep mode.
Get the core deep sleep mode configuration:
Call HAL_PWR_GetCoreSleepMode() to get the core deep sleep mode configuration.
Enable, disable, and check core sleep on exit. This feature allows the core to enter sleep mode immediately after interrupt handling completes without returning to the main program.
Call HAL_PWR_EnableCoreSleepOnExit(), HAL_PWR_DisableCoreSleepOnExit(), and HAL_PWR_IsEnabledCoreSleepOnExit() to enable, disable, and check core sleep on exit.
Enable, disable, and check core send event on pending. This feature allows the Cortex to generate an event signal whenever there is a pending interrupt or exception. Use this event signal to wake up the processor from a low-power state and ensure that the system responds promptly to interrupts.
Call HAL_PWR_EnableCoreSendEventOnPending(), HAL_PWR_DisableCoreSendEventOnPending(), and HAL_PWR_IsEnabledCoreSendEventOnPending() to enable, disable, and check core send event on pending.
Get and clean the previous system power mode:
Call HAL_PWR_GetPreviousSystemPowerMode() to get the previous system power mode.
Call HAL_PWR_CleanPreviousSystemPowerMode() to clean the previous system power mode flag(s) before entering a low power mode.
Manage monitoring: Use the monitor to manage the power supplies and supply domains.
Enable, disable, and check the programmable voltage detector:
Call HAL_PWR_EnableProgrammableVoltageDetector(), HAL_PWR_DisableProgrammableVoltageDetector(), and HAL_PWR_IsEnabledProgrammableVoltageDetector() to enable, disable, and check the programmable voltage detector.
Get the programmable voltage detector output:
Call HAL_PWR_GetProgrammableVoltageDetectorOutput() to read the PVD output level.
Manage memory retention: After entering low power mode, the volatile memory (SRAM) content can be retained or not according to application needs.
Enable, disable, and check memory retention:
Call HAL_PWR_LP_EnableMemoryRetention(), HAL_PWR_LP_DisableMemoryRetention(), and HAL_PWR_LP_IsEnabledMemoryRetention() to enable, disable, and check memory retention.
Enable, disable, and check memory retention per page (not available on all devices):
Call HAL_PWR_LP_EnableMemoryPageRetention(), HAL_PWR_LP_DisableMemoryPageRetention(), and HAL_PWR_LP_IsEnabledMemoryPageRetention() to enable, disable, and check memory retention per page.
Manage memory power modes: The flash memory can be configured to enter low power mode when the MCU enters a low power mode.
Enable, disable, and check the flash low power mode in stop modes:
Call HAL_PWR_LP_EnableFlashLowPWRMode(), HAL_PWR_LP_DisableFlashLowPWRMode(), and HAL_PWR_LP_IsEnabledFlashLowPWRMode() to enable, disable, and check the flash low power mode.
Manage the I/O retention: The I/O retention feature allows maintaining the state of I/Os during low-power modes. Several APIs are available to retain or release the output of I/Os.
Enable, disable, and check I/O retention:
Call HAL_PWR_LP_EnableIORetention(), HAL_PWR_LP_DisableIORetention(), and HAL_PWR_LP_IsEnabledIORetention() to enable, disable, and check I/O retention.
Manage privilege attribute: Use the privilege attribute to set the PWR register access mode (privileged or not).
Set and get the privilege attribute:
Call HAL_PWR_SetPrivAttr() and HAL_PWR_GetPrivAttr() to set and get the privilege attribute.