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:
Power supply management functions.
Low power mode management functions.
Wake-up pins management functions.
RTC domain access management functions.
Voltage monitoring management functions.
Memory retention management functions.
Memory low power management functions.
Battery management functions.
UCPD management functions.
Standby I/O pull management functions.
How to use the PWR HAL module driver ¶
This module provides different sets of APIs that allow:
Manage power supplies: The power supplies can be configured to manage application power consumption and performance.
Configure the main regulator voltage scaling range for different power modes:
Call HAL_PWR_SetMainRegulatorVoltageScalingRange() to configure the voltage scaling range.
Get the voltage scaling range configuration:
Call HAL_PWR_GetMainRegulatorVoltageScalingRange() to get the voltage scaling range configuration.
Get the active voltage scaling range:
Call HAL_PWR_GetMainRegulatorActiveVoltageScalingRange() to get the active voltage scaling range.
Configure the main regulator voltage scaling range during stop mode:
Call HAL_PWR_LP_SetMainRegulatorStopVoltageScalingRange() to configure the voltage scaling range during stop mode.
Get the voltage scaling range configuration during stop mode:
Call HAL_PWR_LP_GetMainRegulatorStopVoltageScalingRange() to get the voltage scaling range configuration during stop mode.
Get the configured main regulator supply source:
Call HAL_PWR_GetMainRegulatorSupply() to get the configured main regulator supply source.
Get the main regulator supply source status:
Call HAL_PWR_GetMainRegulatorSupplyStatus() to get the main regulator supply source status.
Set the analog IO switch supply source:
Call HAL_PWR_SetAnalogIOSwitchSupply() to set the analog IO switch supply source.
Get the analog IO switch supply source:
Call HAL_PWR_GetAnalogIOSwitchSupply() to get the analog IO switch supply source.
Manage low power modes: Use available power modes to reduce power consumption.
Clear the core pending event to clear internal Cortex event before entering sleep or stop 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 mode through a WFE or WFI request:
Call HAL_PWR_EnterStopMode() to enter stop 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.
Handle the PWR wake-up interrupt from Stop low power mode:
This functionality is ensured by HAL_PWR_WakeupPin_IRQHandler().
Manage the wake-up pins: Use a wake-up pin to wake up the system from low power modes.
Configure the wake-up pin polarity and pull without enabling it:
Call HAL_PWR_LP_SetConfigWakeupPin() to configure wake-up polarity and pull. Use the p_config pointer to provide the configuration.
When p_config is null, this function returns an HAL_INVALID_PARAM.
Get the wake-up pin polarity and pull configuration:
Call HAL_PWR_LP_GetConfigWakeupPin() to get the wake-up pin polarity and pull configuration.
Enable, disable and check the wake-up pin:
Call HAL_PWR_LP_EnableWakeupPin(), HAL_PWR_LP_DisableWakeupPin(), and HAL_PWR_LP_IsEnabledWakeupPin() to enable, disable and check the wake-up pin.
Get and clean the wake-up sources:
Call HAL_PWR_LP_GetWakeupSource() and HAL_PWR_LP_CleanWakeupSource() to read and clear wake-up sources.
Manage RTC domain write protection: After a system reset, the RTC domain is protected against possible unwanted write accesses.
Enable, disable and check the 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 voltage monitoring: The monitor can be used to manage the power supplies and supply domains.
Configure the voltage threshold detector by the programmable voltage detector:
Call HAL_PWR_SetProgrammableVoltageDetectorLevel() to configure the programmable voltage detector level.
Get the programmable voltage detector configuration:
Call HAL_PWR_GetProgrammableVoltageDetectorLevel() to get the programmable voltage detector configuration.
Enable, disable and check the programmable voltage detector status:
Call HAL_PWR_EnableProgrammableVoltageDetector(), HAL_PWR_DisableProgrammableVoltageDetector(), and HAL_PWR_IsEnabledProgrammableVoltageDetector() to enable, disable, and check the programmable voltage detector status.
Get the programmable voltage detector output:
Call HAL_PWR_GetProgrammableVoltageDetectorOutput() to get the programmable voltage detector output.
Configure the voltage threshold detector by the analog voltage detector:
Call HAL_PWR_SetAnalogVoltageDetectorLevel() to configure the analog voltage detector level.
Get the analog voltage detector configuration:
Call HAL_PWR_GetAnalogVoltageDetectorLevel() to get the analog voltage detector configuration.
Enable, disable and check the analog voltage detector status:
Call HAL_PWR_EnableAnalogVoltageDetector(), HAL_PWR_DisableAnalogVoltageDetector(), and HAL_PWR_IsEnabledAnalogVoltageDetector() to enable, disable, and check the analog voltage detector status.
Get the analog voltage detector output:
Call HAL_PWR_GetAnalogVoltageDetectorOutput() to get the analog voltage detector output.
Enable, disable and check the peripheral voltage monitoring status:
Call HAL_PWR_EnableTemperatureVbatMonitor(), HAL_PWR_DisableTemperatureVbatMonitor(), and HAL_PWR_IsEnabledTemperatureVbatMonitor() to enable, disable, and check the peripheral voltage monitoring status.
Get the temperature level status:
Call HAL_PWR_GetTemperatureLevelStatus() to get the temperature level status.
Get the VBAT voltage level status:
Call HAL_PWR_GetVbatVoltageLevelStatus() to get the VBAT voltage level status.
Manage memory retention: After entering low power mode, the volatile memory 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.
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 mode:
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 battery charging: Several APIs are available to manage the battery charging:
Set and get battery charging resistor configuration:
Call HAL_PWR_SetConfigBatteryCharging() and HAL_PWR_GetConfigBatteryCharging() to set and get the battery charging resistor configuration.
Enable, disable, and check the battery charging:
Call HAL_PWR_EnableBatteryCharging(), HAL_PWR_DisableBatteryCharging(), and HAL_PWR_IsEnabledBatteryCharging() to enable, disable, and check the battery charging.
Manage UCPD: Several APIs are available to enable or disable the UCPD dead battery feature:
Enable, disable, and check UCPD dead battery: (*)
Call HAL_PWR_LP_EnableUCPDDeadBattery(), HAL_PWR_LP_DisableUCPDDeadBattery(), and HAL_PWR_LP_IsEnabledUCPDDeadBattery() to enable, disable, and check the UCPD dead battery feature.
Enable, disable, and check UCPD configuration retention: (*)
Call HAL_PWR_LP_EnableUCPDRetention(), HAL_PWR_LP_DisableUCPDRetention(), and HAL_PWR_LP_IsEnabledUCPDRetention() to enable, disable, and check the UCPD configuration retention.
Manage Standby I/O pull configuration: Several APIs are available to manage pull-up or pull-down I/O for I3C1 and XSPI1 during standby.
Enable, disable, and check pull status:
Call HAL_PWR_EnableGPIOPull(), HAL_PWR_DisableGPIOPull(), and HAL_PWR_IsEnabledGPIOPull() to enable, disable, and check the pull status.
Set and get pull configuration for I3C1 and XSPI1:
Call HAL_PWR_SetConfigPeriphGPIOPull() and HAL_PWR_GetConfigPeriphGPIOPull() to set and get the peripheral pull configuration.
(*) This feature is not available on all devices.