![]() |
|
|||
File indexing completed on 2025-05-11 08:23:08
0001 /** 0002 ****************************************************************************** 0003 * @file stm32h7xx_hal_pwr_ex.c 0004 * @author MCD Application Team 0005 * @brief Extended PWR HAL module driver. 0006 * This file provides firmware functions to manage the following 0007 * functionalities of PWR extension peripheral: 0008 * + Peripheral Extended features functions 0009 ****************************************************************************** 0010 * @attention 0011 * 0012 * Copyright (c) 2017 STMicroelectronics. 0013 * All rights reserved. 0014 * 0015 * This software is licensed under terms that can be found in the LICENSE file 0016 * in the root directory of this software component. 0017 * If no LICENSE file comes with this software, it is provided AS-IS. 0018 * 0019 ****************************************************************************** 0020 @verbatim 0021 ============================================================================== 0022 ##### How to use this driver ##### 0023 ============================================================================== 0024 [..] 0025 (#) Call HAL_PWREx_ConfigSupply() function to configure the regulator supply 0026 with the following different setups according to hardware (support SMPS): 0027 (+) PWR_DIRECT_SMPS_SUPPLY 0028 (+) PWR_SMPS_1V8_SUPPLIES_LDO 0029 (+) PWR_SMPS_2V5_SUPPLIES_LDO 0030 (+) PWR_SMPS_1V8_SUPPLIES_EXT_AND_LDO 0031 (+) PWR_SMPS_2V5_SUPPLIES_EXT_AND_LDO 0032 (+) PWR_SMPS_1V8_SUPPLIES_EXT 0033 (+) PWR_SMPS_2V5_SUPPLIES_EXT 0034 (+) PWR_LDO_SUPPLY 0035 (+) PWR_EXTERNAL_SOURCE_SUPPLY 0036 0037 (#) Call HAL_PWREx_GetSupplyConfig() function to get the current supply setup. 0038 0039 (#) Call HAL_PWREx_ControlVoltageScaling() function to configure the main 0040 internal regulator output voltage. The voltage scaling could be one of 0041 the following scales : 0042 (+) PWR_REGULATOR_VOLTAGE_SCALE0 0043 (+) PWR_REGULATOR_VOLTAGE_SCALE1 0044 (+) PWR_REGULATOR_VOLTAGE_SCALE2 0045 (+) PWR_REGULATOR_VOLTAGE_SCALE3 0046 0047 (#) Call HAL_PWREx_GetVoltageRange() function to get the current output 0048 voltage applied to the main regulator. 0049 0050 (#) Call HAL_PWREx_ControlStopModeVoltageScaling() function to configure the 0051 main internal regulator output voltage in STOP mode. The voltage scaling 0052 in STOP mode could be one of the following scales : 0053 (+) PWR_REGULATOR_SVOS_SCALE3 0054 (+) PWR_REGULATOR_SVOS_SCALE4 0055 (+) PWR_REGULATOR_SVOS_SCALE5 0056 0057 (#) Call HAL_PWREx_GetStopModeVoltageRange() function to get the current 0058 output voltage applied to the main regulator in STOP mode. 0059 0060 (#) Call HAL_PWREx_EnterSTOP2Mode() function to enter the system in STOP mode 0061 with core domain in D2STOP mode. This API is used only for STM32H7Axxx 0062 and STM32H7Bxxx devices. 0063 Please ensure to clear all CPU pending events by calling 0064 HAL_PWREx_ClearPendingEvent() function when trying to enter the Cortex-Mx 0065 in DEEP-SLEEP mode with __WFE() entry. 0066 0067 (#) Call HAL_PWREx_EnterSTOPMode() function to enter the selected domain in 0068 DSTOP mode. Call this API with all available power domains to enter the 0069 system in STOP mode. 0070 Please ensure to clear all CPU pending events by calling 0071 HAL_PWREx_ClearPendingEvent() function when trying to enter the Cortex-Mx 0072 in DEEP-SLEEP mode with __WFE() entry. 0073 0074 (#) Call HAL_PWREx_ClearPendingEvent() function always before entring the 0075 Cortex-Mx in any low power mode (SLEEP/DEEP-SLEEP) using WFE entry. 0076 0077 (#) Call HAL_PWREx_EnterSTANDBYMode() function to enter the selected domain 0078 in DSTANDBY mode. Call this API with all available power domains to enter 0079 the system in STANDBY mode. 0080 0081 (#) Call HAL_PWREx_ConfigD3Domain() function to setup the D3/SRD domain state 0082 (RUN/STOP) when the system enter to low power mode. 0083 0084 (#) Call HAL_PWREx_ClearDomainFlags() function to clear the CPU flags for the 0085 selected power domain. This API is used only for dual core devices. 0086 0087 (#) Call HAL_PWREx_HoldCore() and HAL_PWREx_ReleaseCore() functions to hold 0088 and release the selected CPU and and their domain peripherals when 0089 exiting STOP mode. These APIs are used only for dual core devices. 0090 0091 (#) Call HAL_PWREx_EnableFlashPowerDown() and 0092 HAL_PWREx_DisableFlashPowerDown() functions to enable and disable the 0093 Flash Power Down in STOP mode. 0094 0095 (#) Call HAL_PWREx_EnableMemoryShutOff() and 0096 HAL_PWREx_DisableMemoryShutOff() functions to enable and disable the 0097 memory block shut-off in DStop or DStop2. These APIs are used only for 0098 STM32H7Axxx and STM32H7Bxxx lines. 0099 0100 (#) Call HAL_PWREx_EnableWakeUpPin() and HAL_PWREx_DisableWakeUpPin() 0101 functions to enable and disable the Wake-up pin functionality for 0102 the selected pin. 0103 0104 (#) Call HAL_PWREx_GetWakeupFlag() and HAL_PWREx_ClearWakeupFlag() 0105 functions to manage wake-up flag for the selected pin. 0106 0107 (#) Call HAL_PWREx_WAKEUP_PIN_IRQHandler() function to handle all wake-up 0108 pins interrupts. 0109 0110 (#) Call HAL_PWREx_EnableBkUpReg() and HAL_PWREx_DisableBkUpReg() functions 0111 to enable and disable the backup domain regulator. 0112 0113 (#) Call HAL_PWREx_EnableUSBReg(), HAL_PWREx_DisableUSBReg(), 0114 HAL_PWREx_EnableUSBVoltageDetector() and 0115 HAL_PWREx_DisableUSBVoltageDetector() functions to manage USB power 0116 regulation functionalities. 0117 0118 (#) Call HAL_PWREx_EnableBatteryCharging() and 0119 HAL_PWREx_DisableBatteryCharging() functions to enable and disable the 0120 battery charging feature with the selected resistor. 0121 0122 (#) Call HAL_PWREx_EnableAnalogBooster() and 0123 HAL_PWREx_DisableAnalogBooster() functions to enable and disable the 0124 AVD boost feature when the VDD supply voltage is below 2V7. 0125 0126 (#) Call HAL_PWREx_EnableMonitoring() and HAL_PWREx_DisableMonitoring() 0127 functions to enable and disable the VBAT and Temperature monitoring. 0128 When VBAT and Temperature monitoring feature is enables, use 0129 HAL_PWREx_GetTemperatureLevel() and HAL_PWREx_GetVBATLevel() to get 0130 respectively the Temperature level and VBAT level. 0131 0132 (#) Call HAL_PWREx_GetMMCVoltage() and HAL_PWREx_DisableMonitoring() 0133 function to get VDDMMC voltage level. This API is used only for 0134 STM32H7Axxx and STM32H7Bxxx lines 0135 0136 (#) Call HAL_PWREx_ConfigAVD() after setting parameter to be configured 0137 (event mode and voltage threshold) in order to set up the Analog Voltage 0138 Detector then use HAL_PWREx_EnableAVD() and HAL_PWREx_DisableAVD() 0139 functions to start and stop the AVD detection. 0140 (+) AVD level could be one of the following values : 0141 (++) 1V7 0142 (++) 2V1 0143 (++) 2V5 0144 (++) 2V8 0145 0146 (#) Call HAL_PWREx_PVD_AVD_IRQHandler() function to handle the PWR PVD and 0147 AVD interrupt request. 0148 0149 @endverbatim 0150 */ 0151 0152 /* Includes ------------------------------------------------------------------*/ 0153 #include "stm32h7xx_hal.h" 0154 0155 /** @addtogroup STM32H7xx_HAL_Driver 0156 * @{ 0157 */ 0158 0159 /** @defgroup PWREx PWREx 0160 * @ingroup RTEMSBSPsARMSTM32H7 0161 * @brief PWR Extended HAL module driver 0162 * @{ 0163 */ 0164 0165 #ifdef HAL_PWR_MODULE_ENABLED 0166 0167 /* Private typedef -----------------------------------------------------------*/ 0168 /* Private define ------------------------------------------------------------*/ 0169 0170 /** @addtogroup PWREx_Private_Constants 0171 * @{ 0172 */ 0173 0174 /** @defgroup PWREx_AVD_Mode_Mask PWR Extended AVD Mode Mask 0175 * @ingroup RTEMSBSPsARMSTM32H7 0176 * @{ 0177 */ 0178 #define AVD_MODE_IT (0x00010000U) 0179 #define AVD_MODE_EVT (0x00020000U) 0180 #define AVD_RISING_EDGE (0x00000001U) 0181 #define AVD_FALLING_EDGE (0x00000002U) 0182 #define AVD_RISING_FALLING_EDGE (0x00000003U) 0183 /** 0184 * @} 0185 */ 0186 0187 /** @defgroup PWREx_REG_SET_TIMEOUT PWR Extended Flag Setting Time Out Value 0188 * @ingroup RTEMSBSPsARMSTM32H7 0189 * @{ 0190 */ 0191 #define PWR_FLAG_SETTING_DELAY (1000U) 0192 /** 0193 * @} 0194 */ 0195 0196 /** @defgroup PWREx_WakeUp_Pins_Offsets PWREx Wake-Up Pins masks and offsets 0197 * @ingroup RTEMSBSPsARMSTM32H7 0198 * @{ 0199 */ 0200 /* Wake-Up Pins EXTI register mask */ 0201 #if defined (EXTI_IMR2_IM57) 0202 #define PWR_EXTI_WAKEUP_PINS_MASK (EXTI_IMR2_IM55 | EXTI_IMR2_IM56 |\ 0203 EXTI_IMR2_IM57 | EXTI_IMR2_IM58 |\ 0204 EXTI_IMR2_IM59 | EXTI_IMR2_IM60) 0205 #else 0206 #define PWR_EXTI_WAKEUP_PINS_MASK (EXTI_IMR2_IM55 | EXTI_IMR2_IM56 |\ 0207 EXTI_IMR2_IM58 | EXTI_IMR2_IM60) 0208 #endif /* defined (EXTI_IMR2_IM57) */ 0209 0210 /* Wake-Up Pins PWR Pin Pull shift offsets */ 0211 #define PWR_WAKEUP_PINS_PULL_SHIFT_OFFSET (2U) 0212 /** 0213 * @} 0214 */ 0215 0216 /** 0217 * @} 0218 */ 0219 0220 /* Private macro -------------------------------------------------------------*/ 0221 /* Private variables ---------------------------------------------------------*/ 0222 /* Private function prototypes -----------------------------------------------*/ 0223 /* Private functions ---------------------------------------------------------*/ 0224 /* Exported types ------------------------------------------------------------*/ 0225 /* Exported functions --------------------------------------------------------*/ 0226 0227 /** @defgroup PWREx_Exported_Functions PWREx Exported Functions 0228 * @ingroup RTEMSBSPsARMSTM32H7 0229 * @{ 0230 */ 0231 0232 /** @defgroup PWREx_Exported_Functions_Group1 Power Supply Control Functions 0233 * @ingroup RTEMSBSPsARMSTM32H7 0234 * @brief Power supply control functions 0235 * 0236 @verbatim 0237 =============================================================================== 0238 ##### Power supply control functions ##### 0239 =============================================================================== 0240 [..] 0241 (#) When the system is powered on, the POR monitors VDD supply. Once VDD is 0242 above the POR threshold level, the voltage regulator is enabled in the 0243 default supply configuration: 0244 (+) The Voltage converter output level is set at 1V0 in accordance with 0245 the VOS3 level configured in PWR (D3/SRD) domain control register 0246 (PWR_D3CR/PWR_SRDCR). 0247 (+) The system is kept in reset mode as long as VCORE is not ok. 0248 (+) Once VCORE is ok, the system is taken out of reset and the HSI 0249 oscillator is enabled. 0250 (+) Once the oscillator is stable, the system is initialized: Flash memory 0251 and option bytes are loaded and the CPU starts in Run* mode. 0252 (+) The software shall then initialize the system including supply 0253 configuration programming using the HAL_PWREx_ConfigSupply(). 0254 (+) Once the supply configuration has been configured, the 0255 HAL_PWREx_ConfigSupply() function checks the ACTVOSRDY bit in PWR 0256 control status register 1 (PWR_CSR1) to guarantee a valid voltage 0257 levels: 0258 (++) As long as ACTVOSRDY indicates that voltage levels are invalid, the 0259 system is in limited Run* mode, write accesses to the RAMs are not 0260 permitted and VOS shall not be changed. 0261 (++) Once ACTVOSRDY indicates that voltage levels are valid, the system 0262 is in normal Run mode, write accesses to RAMs are allowed and VOS 0263 can be changed. 0264 0265 @endverbatim 0266 * @{ 0267 */ 0268 0269 /** 0270 * @brief Configure the system Power Supply. 0271 * @param SupplySource : Specifies the Power Supply source to set after a 0272 * system startup. 0273 * This parameter can be one of the following values : 0274 * @arg PWR_DIRECT_SMPS_SUPPLY : The SMPS supplies the Vcore Power 0275 * Domains. The LDO is Bypassed. 0276 * @arg PWR_SMPS_1V8_SUPPLIES_LDO : The SMPS 1.8V output supplies 0277 * the LDO. The Vcore Power Domains 0278 * are supplied from the LDO. 0279 * @arg PWR_SMPS_2V5_SUPPLIES_LDO : The SMPS 2.5V output supplies 0280 * the LDO. The Vcore Power Domains 0281 * are supplied from the LDO. 0282 * @arg PWR_SMPS_1V8_SUPPLIES_EXT_AND_LDO : The SMPS 1.8V output 0283 * supplies external 0284 * circuits and the LDO. 0285 * The Vcore Power Domains 0286 * are supplied from the 0287 * LDO. 0288 * @arg PWR_SMPS_2V5_SUPPLIES_EXT_AND_LDO : The SMPS 2.5V output 0289 * supplies external 0290 * circuits and the LDO. 0291 * The Vcore Power Domains 0292 * are supplied from the 0293 * LDO. 0294 * @arg PWR_SMPS_1V8_SUPPLIES_EXT : The SMPS 1.8V output supplies 0295 * external circuits. The LDO is 0296 * Bypassed. The Vcore Power 0297 * Domains are supplied from 0298 * external source. 0299 * @arg PWR_SMPS_2V5_SUPPLIES_EXT : The SMPS 2.5V output supplies 0300 * external circuits. The LDO is 0301 * Bypassed. The Vcore Power 0302 * Domains are supplied from 0303 * external source. 0304 * @arg PWR_LDO_SUPPLY : The LDO regulator supplies the Vcore Power 0305 * Domains. The SMPS regulator is Bypassed. 0306 * @arg PWR_EXTERNAL_SOURCE_SUPPLY : The SMPS and the LDO are 0307 * Bypassed. The Vcore Power 0308 * Domains are supplied from 0309 * external source. 0310 * @note The PWR_LDO_SUPPLY and PWR_EXTERNAL_SOURCE_SUPPLY are used by all 0311 * H7 lines. 0312 * The PWR_DIRECT_SMPS_SUPPLY, PWR_SMPS_1V8_SUPPLIES_LDO, 0313 * PWR_SMPS_2V5_SUPPLIES_LDO, PWR_SMPS_1V8_SUPPLIES_EXT_AND_LDO, 0314 * PWR_SMPS_2V5_SUPPLIES_EXT_AND_LDO, PWR_SMPS_1V8_SUPPLIES_EXT and 0315 * PWR_SMPS_2V5_SUPPLIES_EXT are used only for lines that supports SMPS 0316 * regulator. 0317 * @retval HAL status. 0318 */ 0319 HAL_StatusTypeDef HAL_PWREx_ConfigSupply (uint32_t SupplySource) 0320 { 0321 uint32_t tickstart; 0322 0323 /* Check the parameters */ 0324 assert_param (IS_PWR_SUPPLY (SupplySource)); 0325 0326 /* Check if supply source was configured */ 0327 #if defined (PWR_FLAG_SCUEN) 0328 if (__HAL_PWR_GET_FLAG (PWR_FLAG_SCUEN) == 0U) 0329 #else 0330 if ((PWR->CR3 & (PWR_CR3_SMPSEN | PWR_CR3_LDOEN | PWR_CR3_BYPASS)) != (PWR_CR3_SMPSEN | PWR_CR3_LDOEN)) 0331 #endif /* defined (PWR_FLAG_SCUEN) */ 0332 { 0333 /* Check supply configuration */ 0334 if ((PWR->CR3 & PWR_SUPPLY_CONFIG_MASK) != SupplySource) 0335 { 0336 /* Supply configuration update locked, can't apply a new supply config */ 0337 return HAL_ERROR; 0338 } 0339 else 0340 { 0341 /* Supply configuration update locked, but new supply configuration 0342 matches with old supply configuration : nothing to do 0343 */ 0344 return HAL_OK; 0345 } 0346 } 0347 0348 /* Set the power supply configuration */ 0349 MODIFY_REG (PWR->CR3, PWR_SUPPLY_CONFIG_MASK, SupplySource); 0350 0351 /* Get tick */ 0352 tickstart = HAL_GetTick (); 0353 0354 /* Wait till voltage level flag is set */ 0355 while (__HAL_PWR_GET_FLAG (PWR_FLAG_ACTVOSRDY) == 0U) 0356 { 0357 if ((HAL_GetTick () - tickstart) > PWR_FLAG_SETTING_DELAY) 0358 { 0359 return HAL_ERROR; 0360 } 0361 } 0362 0363 #if defined (SMPS) 0364 /* When the SMPS supplies external circuits verify that SDEXTRDY flag is set */ 0365 if ((SupplySource == PWR_SMPS_1V8_SUPPLIES_EXT_AND_LDO) || 0366 (SupplySource == PWR_SMPS_2V5_SUPPLIES_EXT_AND_LDO) || 0367 (SupplySource == PWR_SMPS_1V8_SUPPLIES_EXT) || 0368 (SupplySource == PWR_SMPS_2V5_SUPPLIES_EXT)) 0369 { 0370 /* Get the current tick number */ 0371 tickstart = HAL_GetTick (); 0372 0373 /* Wait till SMPS external supply ready flag is set */ 0374 while (__HAL_PWR_GET_FLAG (PWR_FLAG_SMPSEXTRDY) == 0U) 0375 { 0376 if ((HAL_GetTick () - tickstart) > PWR_FLAG_SETTING_DELAY) 0377 { 0378 return HAL_ERROR; 0379 } 0380 } 0381 } 0382 #endif /* defined (SMPS) */ 0383 0384 return HAL_OK; 0385 } 0386 0387 /** 0388 * @brief Get the power supply configuration. 0389 * @retval The supply configuration. 0390 */ 0391 uint32_t HAL_PWREx_GetSupplyConfig (void) 0392 { 0393 return (PWR->CR3 & PWR_SUPPLY_CONFIG_MASK); 0394 } 0395 0396 /** 0397 * @brief Configure the main internal regulator output voltage. 0398 * @param VoltageScaling : Specifies the regulator output voltage to achieve 0399 * a tradeoff between performance and power 0400 * consumption. 0401 * This parameter can be one of the following values : 0402 * @arg PWR_REGULATOR_VOLTAGE_SCALE0 : Regulator voltage output 0403 * Scale 0 mode. 0404 * @arg PWR_REGULATOR_VOLTAGE_SCALE1 : Regulator voltage output 0405 * range 1 mode. 0406 * @arg PWR_REGULATOR_VOLTAGE_SCALE2 : Regulator voltage output 0407 * range 2 mode. 0408 * @arg PWR_REGULATOR_VOLTAGE_SCALE3 : Regulator voltage output 0409 * range 3 mode. 0410 * @note For STM32H74x and STM32H75x lines, configuring Voltage Scale 0 is 0411 * only possible when Vcore is supplied from LDO (Low DropOut). The 0412 * SYSCFG Clock must be enabled through __HAL_RCC_SYSCFG_CLK_ENABLE() 0413 * macro before configuring Voltage Scale 0. 0414 * To enter low power mode , and if current regulator voltage is 0415 * Voltage Scale 0 then first switch to Voltage Scale 1 before entering 0416 * low power mode. 0417 * @retval HAL Status 0418 */ 0419 HAL_StatusTypeDef HAL_PWREx_ControlVoltageScaling (uint32_t VoltageScaling) 0420 { 0421 uint32_t tickstart; 0422 0423 /* Check the parameters */ 0424 assert_param (IS_PWR_REGULATOR_VOLTAGE (VoltageScaling)); 0425 0426 /* Get the voltage scaling */ 0427 if ((PWR->CSR1 & PWR_CSR1_ACTVOS) == VoltageScaling) 0428 { 0429 /* Old and new voltage scaling configuration match : nothing to do */ 0430 return HAL_OK; 0431 } 0432 0433 #if defined (PWR_SRDCR_VOS) 0434 /* Set the voltage range */ 0435 MODIFY_REG (PWR->SRDCR, PWR_SRDCR_VOS, VoltageScaling); 0436 #else 0437 #if defined(SYSCFG_PWRCR_ODEN) /* STM32H74xxx and STM32H75xxx lines */ 0438 if (VoltageScaling == PWR_REGULATOR_VOLTAGE_SCALE0) 0439 { 0440 if ((PWR->CR3 & PWR_CR3_LDOEN) == PWR_CR3_LDOEN) 0441 { 0442 /* Set the voltage range */ 0443 MODIFY_REG (PWR->D3CR, PWR_D3CR_VOS, PWR_REGULATOR_VOLTAGE_SCALE1); 0444 0445 /* Get tick */ 0446 tickstart = HAL_GetTick (); 0447 0448 /* Wait till voltage level flag is set */ 0449 while (__HAL_PWR_GET_FLAG (PWR_FLAG_ACTVOSRDY) == 0U) 0450 { 0451 if ((HAL_GetTick () - tickstart) > PWR_FLAG_SETTING_DELAY) 0452 { 0453 return HAL_ERROR; 0454 } 0455 } 0456 0457 /* Enable the PWR overdrive */ 0458 SET_BIT (SYSCFG->PWRCR, SYSCFG_PWRCR_ODEN); 0459 } 0460 else 0461 { 0462 /* The voltage scale 0 is only possible when LDO regulator is enabled */ 0463 return HAL_ERROR; 0464 } 0465 } 0466 else 0467 { 0468 if ((PWR->CSR1 & PWR_CSR1_ACTVOS) == PWR_REGULATOR_VOLTAGE_SCALE1) 0469 { 0470 if ((SYSCFG->PWRCR & SYSCFG_PWRCR_ODEN) != 0U) 0471 { 0472 /* Disable the PWR overdrive */ 0473 CLEAR_BIT(SYSCFG->PWRCR, SYSCFG_PWRCR_ODEN); 0474 0475 /* Get tick */ 0476 tickstart = HAL_GetTick (); 0477 0478 /* Wait till voltage level flag is set */ 0479 while (__HAL_PWR_GET_FLAG (PWR_FLAG_ACTVOSRDY) == 0U) 0480 { 0481 if ((HAL_GetTick () - tickstart) > PWR_FLAG_SETTING_DELAY) 0482 { 0483 return HAL_ERROR; 0484 } 0485 } 0486 } 0487 } 0488 0489 /* Set the voltage range */ 0490 MODIFY_REG (PWR->D3CR, PWR_D3CR_VOS, VoltageScaling); 0491 } 0492 #else /* STM32H72xxx and STM32H73xxx lines */ 0493 /* Set the voltage range */ 0494 MODIFY_REG(PWR->D3CR, PWR_D3CR_VOS, VoltageScaling); 0495 #endif /* defined (SYSCFG_PWRCR_ODEN) */ 0496 #endif /* defined (PWR_SRDCR_VOS) */ 0497 0498 /* Get tick */ 0499 tickstart = HAL_GetTick (); 0500 0501 /* Wait till voltage level flag is set */ 0502 while (__HAL_PWR_GET_FLAG (PWR_FLAG_ACTVOSRDY) == 0U) 0503 { 0504 if ((HAL_GetTick() - tickstart) > PWR_FLAG_SETTING_DELAY) 0505 { 0506 return HAL_ERROR; 0507 } 0508 } 0509 0510 return HAL_OK; 0511 } 0512 0513 /** 0514 * @brief Get the main internal regulator output voltage. Reflecting the last 0515 * VOS value applied to the PMU. 0516 * @retval The current applied VOS selection. 0517 */ 0518 uint32_t HAL_PWREx_GetVoltageRange (void) 0519 { 0520 /* Get the active voltage scaling */ 0521 return (PWR->CSR1 & PWR_CSR1_ACTVOS); 0522 } 0523 0524 /** 0525 * @brief Configure the main internal regulator output voltage in STOP mode. 0526 * @param VoltageScaling : Specifies the regulator output voltage when the 0527 * system enters Stop mode to achieve a tradeoff between performance 0528 * and power consumption. 0529 * This parameter can be one of the following values: 0530 * @arg PWR_REGULATOR_SVOS_SCALE3 : Regulator voltage output range 0531 * 3 mode. 0532 * @arg PWR_REGULATOR_SVOS_SCALE4 : Regulator voltage output range 0533 * 4 mode. 0534 * @arg PWR_REGULATOR_SVOS_SCALE5 : Regulator voltage output range 0535 * 5 mode. 0536 * @note The Stop mode voltage scaling for SVOS4 and SVOS5 sets the voltage 0537 * regulator in Low-power (LP) mode to further reduce power consumption. 0538 * When preselecting SVOS3, the use of the voltage regulator low-power 0539 * mode (LP) can be selected by LPDS register bit. 0540 * @note The selected SVOS4 and SVOS5 levels add an additional startup delay 0541 * when exiting from system Stop mode. 0542 * @retval HAL Status. 0543 */ 0544 HAL_StatusTypeDef HAL_PWREx_ControlStopModeVoltageScaling (uint32_t VoltageScaling) 0545 { 0546 /* Check the parameters */ 0547 assert_param (IS_PWR_STOP_MODE_REGULATOR_VOLTAGE (VoltageScaling)); 0548 0549 /* Return the stop mode voltage range */ 0550 MODIFY_REG (PWR->CR1, PWR_CR1_SVOS, VoltageScaling); 0551 0552 return HAL_OK; 0553 } 0554 0555 /** 0556 * @brief Get the main internal regulator output voltage in STOP mode. 0557 * @retval The actual applied VOS selection. 0558 */ 0559 uint32_t HAL_PWREx_GetStopModeVoltageRange (void) 0560 { 0561 /* Return the stop voltage scaling */ 0562 return (PWR->CR1 & PWR_CR1_SVOS); 0563 } 0564 /** 0565 * @} 0566 */ 0567 0568 /** @defgroup PWREx_Exported_Functions_Group2 Low Power Control Functions 0569 * @ingroup RTEMSBSPsARMSTM32H7 0570 * @brief Low power control functions 0571 * 0572 @verbatim 0573 =============================================================================== 0574 ##### Low power control functions ##### 0575 =============================================================================== 0576 0577 *** Domains Low Power modes configuration *** 0578 ============================================= 0579 [..] 0580 This section provides the extended low power mode control APIs. 0581 The system presents 3 principles domains (D1, D2 and D3) that can be 0582 operated in low-power modes (DSTOP or DSTANDBY mode): 0583 0584 (+) DSTOP mode to enters a domain to STOP mode: 0585 (++) D1 domain and/or D2 domain enters DSTOP mode only when the CPU 0586 subsystem is in CSTOP mode and has allocated peripheral in the 0587 domain. 0588 In DSTOP mode the domain bus matrix clock is stopped. 0589 (++) The system enters STOP mode using one of the following scenarios: 0590 (+++) D1 domain enters DSTANDBY mode (powered off) and D2, D3 domains 0591 enter DSTOP mode. 0592 (+++) D2 domain enters DSTANDBY mode (powered off) and D1, D3 domains 0593 enter DSTOP mode. 0594 (+++) D3 domain enters DSTANDBY mode (powered off) and D1, D2 domains 0595 enter DSTOP mode. 0596 (+++) D1 and D2 domains enter DSTANDBY mode (powered off) and D3 domain 0597 enters DSTOP mode. 0598 (+++) D1 and D3 domains enter DSTANDBY mode (powered off) and D2 domain 0599 enters DSTOP mode. 0600 (+++) D2 and D3 domains enter DSTANDBY mode (powered off) and D1 domain 0601 enters DSTOP mode. 0602 (+++) D1, D2 and D3 domains enter DSTOP mode. 0603 (++) When the system enters STOP mode, the clocks are stopped and the 0604 regulator is running in main or low power mode. 0605 (++) D3 domain can be kept in Run mode regardless of the CPU status when 0606 enter STOP mode by using HAL_PWREx_ConfigD3Domain(D3State) function. 0607 0608 (+) DSTANDBY mode to enters a domain to STANDBY mode: 0609 (++) The DSTANDBY mode is entered when the PDDS_Dn bit in PWR CPU control 0610 register (PWR_CPUCR) for the Dn domain selects Standby mode. 0611 (++) The system enters STANDBY mode only when D1, D2 and D3 domains enter 0612 DSTANDBY mode. Consequently the VCORE supply regulator is powered 0613 off. 0614 0615 *** DSTOP mode *** 0616 ================== 0617 [..] 0618 In DStop mode the domain bus matrix clock is stopped. 0619 The Flash memory can enter low-power Stop mode when it is enabled through 0620 FLPS in PWR_CR1 register. This allows a trade-off between domain DStop 0621 restart time and low power consumption. 0622 [..] 0623 In DStop mode domain peripherals using the LSI or LSE clock and 0624 peripherals having a kernel clock request are still able to operate. 0625 [..] 0626 Before entering DSTOP mode it is recommended to call SCB_CleanDCache 0627 function in order to clean the D-Cache and guarantee the data integrity 0628 for the SRAM memories. 0629 0630 (+) Entry: 0631 The DSTOP mode is entered using the HAL_PWREx_EnterSTOPMode(Regulator, 0632 STOPEntry, Domain) function with: 0633 (++) Regulator: 0634 (+++) PWR_MAINREGULATOR_ON : Main regulator ON. 0635 (+++) PWR_LOWPOWERREGULATOR_ON : Low Power regulator ON. 0636 (++) STOPEntry: 0637 (+++) PWR_STOPENTRY_WFI : enter STOP mode with WFI instruction 0638 (+++) PWR_STOPENTRY_WFE : enter STOP mode with WFE instruction 0639 (++) Domain: 0640 (+++) PWR_D1_DOMAIN : Enters D1/CD domain to DSTOP mode. 0641 (+++) PWR_D2_DOMAIN : Enters D2 domain to DSTOP mode. 0642 (+++) PWR_D3_DOMAIN : Enters D3/SRD domain to DSTOP mode. 0643 0644 (+) Exit: 0645 Any EXTI Line (Internal or External) configured in Interrupt/Event mode. 0646 0647 *** DSTANDBY mode *** 0648 ===================== 0649 [..] 0650 In DStandby mode: 0651 (+) The domain bus matrix clock is stopped. 0652 (+) The domain is powered down and the domain RAM and register contents 0653 are lost. 0654 [..] 0655 Before entering DSTANDBY mode it is recommended to call SCB_CleanDCache 0656 function in order to clean the D-Cache and guarantee the data integrity 0657 for the SRAM memories. 0658 0659 (+) Entry: 0660 The DSTANDBY mode is entered using the HAL_PWREx_EnterSTANDBYMode 0661 (Domain) function with: 0662 (++) Domain: 0663 (+++) PWR_D1_DOMAIN : Enters D1/CD domain to DSTANDBY mode. 0664 (+++) PWR_D2_DOMAIN : Enters D2 domain to DSTANDBY mode. 0665 (+++) PWR_D3_DOMAIN : Enters D3/SRD domain to DSTANDBY mode. 0666 0667 (+) Exit: 0668 WKUP pin rising or falling edge, RTC alarm (Alarm A and Alarm B), RTC 0669 wakeup, tamper event, time stamp event, external reset in NRST pin, 0670 IWDG reset. 0671 0672 *** Keep D3/SRD in RUN mode *** 0673 =============================== 0674 [..] 0675 D3/SRD domain can be kept in Run mode regardless of the CPU status when 0676 entering STOP mode by using HAL_PWREx_ConfigD3Domain(D3State) function 0677 with : 0678 (+) D3State: 0679 (++) PWR_D3_DOMAIN_STOP : D3/SDR domain follows the CPU sub-system 0680 mode. 0681 (++) PWR_D3_DOMAIN_RUN : D3/SRD domain remains in Run mode regardless 0682 of CPU subsystem mode. 0683 0684 *** FLASH Power Down configuration **** 0685 ======================================= 0686 [..] 0687 By setting the FLPS bit in the PWR_CR1 register using the 0688 HAL_PWREx_EnableFlashPowerDown() function, the Flash memory also enters 0689 power down mode when the device enters STOP mode. When the Flash memory is 0690 in power down mode, an additional startup delay is incurred when waking up 0691 from STOP mode. 0692 0693 *** Wakeup Pins configuration **** 0694 =================================== 0695 [..] 0696 Wakeup pins allow the system to exit from Standby mode. The configuration 0697 of wakeup pins is done with the HAL_PWREx_EnableWakeUpPin(sPinParams) 0698 function with: 0699 (+) sPinParams: structure to enable and configure a wakeup pin: 0700 (++) WakeUpPin: Wakeup pin to be enabled. 0701 (++) PinPolarity: Wakeup pin polarity (rising or falling edge). 0702 (++) PinPull: Wakeup pin pull (no pull, pull-up or pull-down). 0703 [..] 0704 The wakeup pins are internally connected to the EXTI lines [55-60] to 0705 generate an interrupt if enabled. The EXTI lines configuration is done by 0706 the HAL_EXTI_Dx_EventInputConfig() functions defined in the stm32h7xxhal.c 0707 file. 0708 [..] 0709 When a wakeup pin event is received the HAL_PWREx_WAKEUP_PIN_IRQHandler is 0710 called and the appropriate flag is set in the PWR_WKUPFR register. Then in 0711 the HAL_PWREx_WAKEUP_PIN_IRQHandler function the wakeup pin flag will be 0712 cleared and the appropriate user callback will be called. The user can add 0713 his own code by customization of function pointer HAL_PWREx_WKUPx_Callback. 0714 0715 @endverbatim 0716 * @{ 0717 */ 0718 0719 #if defined (PWR_CPUCR_RETDS_CD) 0720 /** 0721 * @brief Enter the system to STOP mode with main domain in DSTOP2. 0722 * @note In STOP mode, the domain bus matrix clock is stalled. 0723 * @note In STOP mode, memories and registers are maintained and peripherals 0724 * in CPU domain are no longer operational. 0725 * @note All clocks in the VCORE domain are stopped, the PLL, the HSI and the 0726 * HSE oscillators are disabled. Only Peripherals that have wakeup 0727 * capability can switch on the HSI to receive a frame, and switch off 0728 * the HSI after receiving the frame if it is not a wakeup frame. In 0729 * this case the HSI clock is propagated only to the peripheral 0730 * requesting it. 0731 * @note When exiting STOP mode by issuing an interrupt or a wakeup event, 0732 * the HSI RC oscillator is selected as system clock if STOPWUCK bit in 0733 * RCC_CFGR register is set. 0734 * @param Regulator : Specifies the regulator state in STOP mode. 0735 * This parameter can be one of the following values: 0736 * @arg PWR_MAINREGULATOR_ON : STOP mode with regulator ON. 0737 * @arg PWR_LOWPOWERREGULATOR_ON : STOP mode with low power 0738 * regulator ON. 0739 * @param STOPEntry : Specifies if STOP mode in entered with WFI or WFE 0740 * intrinsic instruction. 0741 * This parameter can be one of the following values: 0742 * @arg PWR_STOPENTRY_WFI : Enter STOP mode with WFI instruction. 0743 * @arg PWR_STOPENTRY_WFE : Enter STOP mode with WFE instruction. 0744 * @retval None. 0745 */ 0746 void HAL_PWREx_EnterSTOP2Mode (uint32_t Regulator, uint8_t STOPEntry) 0747 { 0748 /* Check the parameters */ 0749 assert_param (IS_PWR_REGULATOR (Regulator)); 0750 assert_param (IS_PWR_STOP_ENTRY (STOPEntry)); 0751 0752 /* Select the regulator state in Stop mode */ 0753 MODIFY_REG (PWR->CR1, PWR_CR1_LPDS, Regulator); 0754 0755 /* Go to DStop2 mode (deep retention) when CPU domain enters Deepsleep */ 0756 SET_BIT (PWR->CPUCR, PWR_CPUCR_RETDS_CD); 0757 0758 /* Keep DSTOP mode when SmartRun domain enters Deepsleep */ 0759 CLEAR_BIT (PWR->CPUCR, PWR_CPUCR_PDDS_SRD); 0760 0761 /* Set SLEEPDEEP bit of Cortex System Control Register */ 0762 SET_BIT (SCB->SCR, SCB_SCR_SLEEPDEEP_Msk); 0763 0764 /* Ensure that all instructions are done before entering STOP mode */ 0765 __ISB (); 0766 __DSB (); 0767 0768 /* Select Stop mode entry */ 0769 if (STOPEntry == PWR_STOPENTRY_WFI) 0770 { 0771 /* Request Wait For Interrupt */ 0772 __WFI (); 0773 } 0774 else 0775 { 0776 /* Request Wait For Event */ 0777 __WFE (); 0778 } 0779 0780 /* Clear SLEEPDEEP bit of Cortex-Mx in the System Control Register */ 0781 CLEAR_BIT (SCB->SCR, SCB_SCR_SLEEPDEEP_Msk); 0782 } 0783 #endif /* defined (PWR_CPUCR_RETDS_CD) */ 0784 0785 /** 0786 * @brief Enter a Domain to DSTOP mode. 0787 * @note This API gives flexibility to manage independently each domain STOP 0788 * mode. For dual core lines, this API should be executed with the 0789 * corresponding Cortex-Mx to enter domain to DSTOP mode. When it is 0790 * executed by all available Cortex-Mx, the system enter to STOP mode. 0791 * For single core lines, calling this API with domain parameter set to 0792 * PWR_D1_DOMAIN (D1/CD), the whole system will enter in STOP mode 0793 * independently of PWR_CPUCR_PDDS_Dx bits values if RUN_D3 bit in the 0794 * CPUCR_RUN_D3 is cleared. 0795 * @note In DStop mode the domain bus matrix clock is stopped. 0796 * @note The system D3/SRD domain enter Stop mode only when the CPU subsystem 0797 * is in CStop mode, the EXTI wakeup sources are inactive and at least 0798 * one PDDS_Dn bit in PWR CPU control register (PWR_CPUCR) for 0799 * any domain request Stop. 0800 * @note Before entering DSTOP mode it is recommended to call SCB_CleanDCache 0801 * function in order to clean the D-Cache and guarantee the data 0802 * integrity for the SRAM memories. 0803 * @note In System Stop mode, the domain peripherals that use the LSI or LSE 0804 * clock, and the peripherals that have a kernel clock request to 0805 * select HSI or CSI as source, are still able to operate. 0806 * @param Regulator : Specifies the regulator state in STOP mode. 0807 * This parameter can be one of the following values: 0808 * @arg PWR_MAINREGULATOR_ON : STOP mode with regulator ON. 0809 * @arg PWR_LOWPOWERREGULATOR_ON : STOP mode with low power 0810 * regulator ON. 0811 * @param STOPEntry : Specifies if STOP mode in entered with WFI or WFE 0812 * intrinsic instruction. 0813 * This parameter can be one of the following values: 0814 * @arg PWR_STOPENTRY_WFI : Enter STOP mode with WFI instruction. 0815 * @arg PWR_STOPENTRY_WFE : Enter STOP mode with WFE instruction. 0816 * @param Domain : Specifies the Domain to enter in DSTOP mode. 0817 * This parameter can be one of the following values: 0818 * @arg PWR_D1_DOMAIN : Enter D1/CD Domain to DSTOP mode. 0819 * @arg PWR_D2_DOMAIN : Enter D2 Domain to DSTOP mode. 0820 * @arg PWR_D3_DOMAIN : Enter D3/SRD Domain to DSTOP mode. 0821 * @retval None. 0822 */ 0823 void HAL_PWREx_EnterSTOPMode (uint32_t Regulator, uint8_t STOPEntry, uint32_t Domain) 0824 { 0825 /* Check the parameters */ 0826 assert_param (IS_PWR_REGULATOR (Regulator)); 0827 assert_param (IS_PWR_STOP_ENTRY (STOPEntry)); 0828 assert_param (IS_PWR_DOMAIN (Domain)); 0829 0830 /* Select the regulator state in Stop mode */ 0831 MODIFY_REG (PWR->CR1, PWR_CR1_LPDS, Regulator); 0832 0833 /* Select the domain Power Down DeepSleep */ 0834 if (Domain == PWR_D1_DOMAIN) 0835 { 0836 #if defined (DUAL_CORE) 0837 /* Check current core */ 0838 if (HAL_GetCurrentCPUID () != CM7_CPUID) 0839 { 0840 /* 0841 When the domain selected and the cortex-mx don't match, entering stop 0842 mode will not be performed 0843 */ 0844 return; 0845 } 0846 #endif /* defined (DUAL_CORE) */ 0847 0848 /* Keep DSTOP mode when D1/CD domain enters Deepsleep */ 0849 CLEAR_BIT (PWR->CPUCR, PWR_CPUCR_PDDS_D1); 0850 0851 /* Set SLEEPDEEP bit of Cortex System Control Register */ 0852 SET_BIT (SCB->SCR, SCB_SCR_SLEEPDEEP_Msk); 0853 0854 /* Ensure that all instructions are done before entering STOP mode */ 0855 __DSB (); 0856 __ISB (); 0857 0858 /* Select Stop mode entry */ 0859 if (STOPEntry == PWR_STOPENTRY_WFI) 0860 { 0861 /* Request Wait For Interrupt */ 0862 __WFI (); 0863 } 0864 else 0865 { 0866 /* Request Wait For Event */ 0867 __WFE (); 0868 } 0869 0870 /* Clear SLEEPDEEP bit of Cortex-Mx in the System Control Register */ 0871 CLEAR_BIT (SCB->SCR, SCB_SCR_SLEEPDEEP_Msk); 0872 } 0873 #if defined (PWR_CPUCR_PDDS_D2) 0874 else if (Domain == PWR_D2_DOMAIN) 0875 { 0876 #if defined (DUAL_CORE) 0877 /* Check current core */ 0878 if (HAL_GetCurrentCPUID () != CM4_CPUID) 0879 { 0880 /* 0881 When the domain selected and the cortex-mx don't match, entering stop 0882 mode will not be performed 0883 */ 0884 return; 0885 } 0886 0887 /* Keep DSTOP mode when D2 domain enters Deepsleep */ 0888 CLEAR_BIT (PWR->CPU2CR, PWR_CPU2CR_PDDS_D2); 0889 0890 /* Set SLEEPDEEP bit of Cortex System Control Register */ 0891 SET_BIT (SCB->SCR, SCB_SCR_SLEEPDEEP_Msk); 0892 0893 /* Ensure that all instructions are done before entering STOP mode */ 0894 __DSB (); 0895 __ISB (); 0896 0897 /* Select Stop mode entry */ 0898 if (STOPEntry == PWR_STOPENTRY_WFI) 0899 { 0900 /* Request Wait For Interrupt */ 0901 __WFI (); 0902 } 0903 else 0904 { 0905 /* Request Wait For Event */ 0906 __WFE (); 0907 } 0908 0909 /* Clear SLEEPDEEP bit of Cortex-Mx in the System Control Register */ 0910 CLEAR_BIT (SCB->SCR, SCB_SCR_SLEEPDEEP_Msk); 0911 #else 0912 /* Keep DSTOP mode when D2 domain enters Deepsleep */ 0913 CLEAR_BIT (PWR->CPUCR, PWR_CPUCR_PDDS_D2); 0914 #endif /* defined (DUAL_CORE) */ 0915 } 0916 #endif /* defined (PWR_CPUCR_PDDS_D2) */ 0917 else 0918 { 0919 #if defined (DUAL_CORE) 0920 /* Check current core */ 0921 if (HAL_GetCurrentCPUID () == CM7_CPUID) 0922 { 0923 /* Keep DSTOP mode when D3 domain enters Deepsleep */ 0924 CLEAR_BIT (PWR->CPUCR, PWR_CPUCR_PDDS_D3); 0925 } 0926 else 0927 { 0928 /* Keep DSTOP mode when D3 domain enters Deepsleep */ 0929 CLEAR_BIT (PWR->CPU2CR, PWR_CPU2CR_PDDS_D3); 0930 } 0931 #else 0932 /* Keep DSTOP mode when D3/SRD domain enters Deepsleep */ 0933 CLEAR_BIT (PWR->CPUCR, PWR_CPUCR_PDDS_D3); 0934 #endif /* defined (DUAL_CORE) */ 0935 } 0936 } 0937 0938 /** 0939 * @brief Clear pending event. 0940 * @note This API clears the pending event in order to enter a given CPU 0941 * to CSLEEP or CSTOP. It should be called just before APIs performing 0942 * enter low power mode using Wait For Event request. 0943 * @note Cortex-M7 must be in CRUN mode when calling this API by Cortex-M4. 0944 * @retval None. 0945 */ 0946 void HAL_PWREx_ClearPendingEvent (void) 0947 { 0948 #if defined (DUAL_CORE) 0949 /* Check the current Core */ 0950 if (HAL_GetCurrentCPUID () == CM7_CPUID) 0951 { 0952 __WFE (); 0953 } 0954 else 0955 { 0956 __SEV (); 0957 __WFE (); 0958 } 0959 #else 0960 __WFE (); 0961 #endif /* defined (DUAL_CORE) */ 0962 } 0963 0964 /** 0965 * @brief Enter a Domain to DSTANDBY mode. 0966 * @note This API gives flexibility to manage independently each domain 0967 * STANDBY mode. For dual core lines, this API should be executed with 0968 * the corresponding Cortex-Mx to enter domain to DSTANDBY mode. When 0969 * it is executed by all available Cortex-Mx, the system enter STANDBY 0970 * mode. 0971 * For single core lines, calling this API with D1/SRD the selected 0972 * domain will enter the whole system in STOP if PWR_CPUCR_PDDS_D3 = 0 0973 * and enter the whole system in STANDBY if PWR_CPUCR_PDDS_D3 = 1. 0974 * @note The DStandby mode is entered when all PDDS_Dn bits in PWR_CPUCR for 0975 * the Dn domain select Standby mode. When the system enters Standby 0976 * mode, the voltage regulator is disabled. 0977 * @note When D2 or D3 domain is in DStandby mode and the CPU sets the 0978 * domain PDDS_Dn bit to select Stop mode, the domain remains in 0979 * DStandby mode. The domain will only exit DStandby when the CPU 0980 * allocates a peripheral in the domain. 0981 * @note The system D3/SRD domain enters Standby mode only when the D1 and D2 0982 * domain are in DStandby. 0983 * @note Before entering DSTANDBY mode it is recommended to call 0984 * SCB_CleanDCache function in order to clean the D-Cache and guarantee 0985 * the data integrity for the SRAM memories. 0986 * @param Domain : Specifies the Domain to enter to STANDBY mode. 0987 * This parameter can be one of the following values: 0988 * @arg PWR_D1_DOMAIN: Enter D1/CD Domain to DSTANDBY mode. 0989 * @arg PWR_D2_DOMAIN: Enter D2 Domain to DSTANDBY mode. 0990 * @arg PWR_D3_DOMAIN: Enter D3/SRD Domain to DSTANDBY mode. 0991 * @retval None 0992 */ 0993 void HAL_PWREx_EnterSTANDBYMode (uint32_t Domain) 0994 { 0995 /* Check the parameters */ 0996 assert_param (IS_PWR_DOMAIN (Domain)); 0997 0998 /* Select the domain Power Down DeepSleep */ 0999 if (Domain == PWR_D1_DOMAIN) 1000 { 1001 #if defined (DUAL_CORE) 1002 /* Check current core */ 1003 if (HAL_GetCurrentCPUID () != CM7_CPUID) 1004 { 1005 /* 1006 When the domain selected and the cortex-mx don't match, entering 1007 standby mode will not be performed 1008 */ 1009 return; 1010 } 1011 #endif /* defined (DUAL_CORE) */ 1012 1013 /* Allow DSTANDBY mode when D1/CD domain enters Deepsleep */ 1014 SET_BIT (PWR-> CPUCR, PWR_CPUCR_PDDS_D1); 1015 1016 #if defined (DUAL_CORE) 1017 /* Allow DSTANDBY mode when D1/CD domain enters Deepsleep */ 1018 SET_BIT (PWR-> CPU2CR, PWR_CPU2CR_PDDS_D1); 1019 #endif /*DUAL_CORE*/ 1020 1021 /* Set SLEEPDEEP bit of Cortex System Control Register */ 1022 SET_BIT (SCB->SCR, SCB_SCR_SLEEPDEEP_Msk); 1023 1024 /* This option is used to ensure that store operations are completed */ 1025 #if defined (__CC_ARM) 1026 __force_stores (); 1027 #endif /* defined (__CC_ARM) */ 1028 1029 /* Request Wait For Interrupt */ 1030 __WFI (); 1031 } 1032 #if defined (PWR_CPUCR_PDDS_D2) 1033 else if (Domain == PWR_D2_DOMAIN) 1034 { 1035 /* Allow DSTANDBY mode when D2 domain enters Deepsleep */ 1036 SET_BIT (PWR-> CPUCR, PWR_CPUCR_PDDS_D2); 1037 1038 #if defined (DUAL_CORE) 1039 /* Check current core */ 1040 if (HAL_GetCurrentCPUID () != CM4_CPUID) 1041 { 1042 /* 1043 When the domain selected and the cortex-mx don't match, entering 1044 standby mode will not be performed 1045 */ 1046 return; 1047 } 1048 1049 /* Allow DSTANDBY mode when D2 domain enters Deepsleep */ 1050 SET_BIT (PWR-> CPU2CR, PWR_CPU2CR_PDDS_D2); 1051 1052 /* Set SLEEPDEEP bit of Cortex System Control Register */ 1053 SET_BIT (SCB->SCR, SCB_SCR_SLEEPDEEP_Msk); 1054 1055 /* This option is used to ensure that store operations are completed */ 1056 #if defined (__CC_ARM) 1057 __force_stores (); 1058 #endif /* defined (__CC_ARM) */ 1059 1060 /* Request Wait For Interrupt */ 1061 __WFI (); 1062 #endif /* defined (DUAL_CORE) */ 1063 } 1064 #endif /* defined (PWR_CPUCR_PDDS_D2) */ 1065 else 1066 { 1067 /* Allow DSTANDBY mode when D3/SRD domain enters Deepsleep */ 1068 SET_BIT (PWR->CPUCR, PWR_CPUCR_PDDS_D3); 1069 1070 #if defined (DUAL_CORE) 1071 /* Allow DSTANDBY mode when D3/SRD domain enters Deepsleep */ 1072 SET_BIT (PWR->CPU2CR, PWR_CPU2CR_PDDS_D3); 1073 #endif /* defined (DUAL_CORE) */ 1074 } 1075 } 1076 1077 /** 1078 * @brief Configure the D3/SRD Domain state when the System in low power mode. 1079 * @param D3State : Specifies the D3/SRD state. 1080 * This parameter can be one of the following values : 1081 * @arg PWR_D3_DOMAIN_STOP : D3/SRD domain will follow the most deep 1082 * CPU sub-system low power mode. 1083 * @arg PWR_D3_DOMAIN_RUN : D3/SRD domain will stay in RUN mode 1084 * regardless of the CPU sub-system low 1085 * power mode. 1086 * @retval None 1087 */ 1088 void HAL_PWREx_ConfigD3Domain (uint32_t D3State) 1089 { 1090 /* Check the parameter */ 1091 assert_param (IS_D3_STATE (D3State)); 1092 1093 /* Keep D3/SRD in run mode */ 1094 MODIFY_REG (PWR->CPUCR, PWR_CPUCR_RUN_D3, D3State); 1095 } 1096 1097 #if defined (DUAL_CORE) 1098 /** 1099 * @brief Clear HOLD2F, HOLD1F, STOPF, SBF, SBF_D1, and SBF_D2 flags for a 1100 * given domain. 1101 * @param DomainFlags : Specifies the Domain flags to be cleared. 1102 * This parameter can be one of the following values: 1103 * @arg PWR_D1_DOMAIN_FLAGS : Clear D1 Domain flags. 1104 * @arg PWR_D2_DOMAIN_FLAGS : Clear D2 Domain flags. 1105 * @arg PWR_ALL_DOMAIN_FLAGS : Clear D1 and D2 Domain flags. 1106 * @retval None. 1107 */ 1108 void HAL_PWREx_ClearDomainFlags (uint32_t DomainFlags) 1109 { 1110 /* Check the parameter */ 1111 assert_param (IS_PWR_DOMAIN_FLAG (DomainFlags)); 1112 1113 /* D1 CPU flags */ 1114 if (DomainFlags == PWR_D1_DOMAIN_FLAGS) 1115 { 1116 /* Clear D1 domain flags (HOLD2F, STOPF, SBF, SBF_D1, and SBF_D2) */ 1117 SET_BIT (PWR->CPUCR, PWR_CPUCR_CSSF); 1118 } 1119 /* D2 CPU flags */ 1120 else if (DomainFlags == PWR_D2_DOMAIN_FLAGS) 1121 { 1122 /* Clear D2 domain flags (HOLD1F, STOPF, SBF, SBF_D1, and SBF_D2) */ 1123 SET_BIT (PWR->CPU2CR, PWR_CPU2CR_CSSF); 1124 } 1125 else 1126 { 1127 /* Clear D1 domain flags (HOLD2F, STOPF, SBF, SBF_D1, and SBF_D2) */ 1128 SET_BIT (PWR->CPUCR, PWR_CPUCR_CSSF); 1129 /* Clear D2 domain flags (HOLD1F, STOPF, SBF, SBF_D1, and SBF_D2) */ 1130 SET_BIT (PWR->CPU2CR, PWR_CPU2CR_CSSF); 1131 } 1132 } 1133 1134 /** 1135 * @brief Hold the CPU and their domain peripherals when exiting STOP mode. 1136 * @param CPU : Specifies the core to be held. 1137 * This parameter can be one of the following values: 1138 * @arg PWR_CORE_CPU1: Hold CPU1 and set CPU2 as master. 1139 * @arg PWR_CORE_CPU2: Hold CPU2 and set CPU1 as master. 1140 * @retval HAL status 1141 */ 1142 HAL_StatusTypeDef HAL_PWREx_HoldCore (uint32_t CPU) 1143 { 1144 HAL_StatusTypeDef status = HAL_OK; 1145 1146 /* Check the parameters */ 1147 assert_param (IS_PWR_CORE (CPU)); 1148 1149 /* Check CPU index */ 1150 if (CPU == PWR_CORE_CPU2) 1151 { 1152 /* If CPU1 is not held */ 1153 if ((PWR->CPU2CR & PWR_CPU2CR_HOLD1) != PWR_CPU2CR_HOLD1) 1154 { 1155 /* Set HOLD2 bit */ 1156 SET_BIT (PWR->CPUCR, PWR_CPUCR_HOLD2); 1157 } 1158 else 1159 { 1160 status = HAL_ERROR; 1161 } 1162 } 1163 else 1164 { 1165 /* If CPU2 is not held */ 1166 if ((PWR->CPUCR & PWR_CPUCR_HOLD2) != PWR_CPUCR_HOLD2) 1167 { 1168 /* Set HOLD1 bit */ 1169 SET_BIT (PWR->CPU2CR, PWR_CPU2CR_HOLD1); 1170 } 1171 else 1172 { 1173 status = HAL_ERROR; 1174 } 1175 } 1176 1177 return status; 1178 } 1179 1180 /** 1181 * @brief Release the CPU and their domain peripherals after a wake-up from 1182 * STOP mode. 1183 * @param CPU: Specifies the core to be released. 1184 * This parameter can be one of the following values: 1185 * @arg PWR_CORE_CPU1: Release the CPU1 and their domain 1186 * peripherals from holding. 1187 * @arg PWR_CORE_CPU2: Release the CPU2 and their domain 1188 * peripherals from holding. 1189 * @retval None 1190 */ 1191 void HAL_PWREx_ReleaseCore (uint32_t CPU) 1192 { 1193 /* Check the parameters */ 1194 assert_param (IS_PWR_CORE (CPU)); 1195 1196 /* Check CPU index */ 1197 if (CPU == PWR_CORE_CPU2) 1198 { 1199 /* Reset HOLD2 bit */ 1200 CLEAR_BIT (PWR->CPUCR, PWR_CPUCR_HOLD2); 1201 } 1202 else 1203 { 1204 /* Reset HOLD1 bit */ 1205 CLEAR_BIT (PWR->CPU2CR, PWR_CPU2CR_HOLD1); 1206 } 1207 } 1208 #endif /* defined (DUAL_CORE) */ 1209 1210 1211 /** 1212 * @brief Enable the Flash Power Down in Stop mode. 1213 * @note When Flash Power Down is enabled the Flash memory enters low-power 1214 * mode when D1/SRD domain is in DStop mode. This feature allows to 1215 * obtain the best trade-off between low-power consumption and restart 1216 * time when exiting from DStop mode. 1217 * @retval None. 1218 */ 1219 void HAL_PWREx_EnableFlashPowerDown (void) 1220 { 1221 /* Enable the Flash Power Down */ 1222 SET_BIT (PWR->CR1, PWR_CR1_FLPS); 1223 } 1224 1225 /** 1226 * @brief Disable the Flash Power Down in Stop mode. 1227 * @note When Flash Power Down is disabled the Flash memory is kept on 1228 * normal mode when D1/SRD domain is in DStop mode. This feature allows 1229 * to obtain the best trade-off between low-power consumption and 1230 * restart time when exiting from DStop mode. 1231 * @retval None. 1232 */ 1233 void HAL_PWREx_DisableFlashPowerDown (void) 1234 { 1235 /* Disable the Flash Power Down */ 1236 CLEAR_BIT (PWR->CR1, PWR_CR1_FLPS); 1237 } 1238 1239 #if defined (PWR_CR1_SRDRAMSO) 1240 /** 1241 * @brief Enable memory block shut-off in DStop or DStop2 modes 1242 * @note In DStop or DStop2 mode, the content of the memory blocks is 1243 * maintained. Further power optimization can be obtained by switching 1244 * off some memory blocks. This optimization implies loss of the memory 1245 * content. The user can select which memory is discarded during STOP 1246 * mode by means of xxSO bits. 1247 * @param MemoryBlock : Specifies the memory block to shut-off during DStop or 1248 * DStop2 mode. 1249 * This parameter can be one of the following values: 1250 * @arg PWR_SRD_AHB_MEMORY_BLOCK : SmartRun domain AHB memory. 1251 * @arg PWR_USB_FDCAN_MEMORY_BLOCK : High-speed interfaces USB and 1252 * FDCAN memories. 1253 * @arg PWR_GFXMMU_JPEG_MEMORY_BLOCK : GFXMMU and JPEG memories. 1254 * @arg PWR_TCM_ECM_MEMORY_BLOCK : Instruction TCM and ETM memories. 1255 * @arg PWR_RAM1_AHB_MEMORY_BLOCK : AHB RAM1 memory. 1256 * @arg PWR_RAM2_AHB_MEMORY_BLOCK : AHB RAM2 memory. 1257 * @arg PWR_RAM1_AXI_MEMORY_BLOCK : AXI RAM1 memory. 1258 * @arg PWR_RAM2_AXI_MEMORY_BLOCK : AXI RAM2 memory. 1259 * @arg PWR_RAM3_AXI_MEMORY_BLOCK : AXI RAM3 memory. 1260 * @retval None. 1261 */ 1262 void HAL_PWREx_EnableMemoryShutOff (uint32_t MemoryBlock) 1263 { 1264 /* Check the parameter */ 1265 assert_param (IS_PWR_MEMORY_BLOCK (MemoryBlock)); 1266 1267 /* Enable memory block shut-off */ 1268 SET_BIT (PWR->CR1, MemoryBlock); 1269 } 1270 1271 /** 1272 * @brief Disable memory block shut-off in DStop or DStop2 modes 1273 * @param MemoryBlock : Specifies the memory block to keep content during 1274 * DStop or DStop2 mode. 1275 * This parameter can be one of the following values: 1276 * @arg PWR_SRD_AHB_MEMORY_BLOCK : SmartRun domain AHB memory. 1277 * @arg PWR_USB_FDCAN_MEMORY_BLOCK : High-speed interfaces USB and 1278 * FDCAN memories. 1279 * @arg PWR_GFXMMU_JPEG_MEMORY_BLOCK : GFXMMU and JPEG memories. 1280 * @arg PWR_TCM_ECM_MEMORY_BLOCK : Instruction TCM and ETM memories. 1281 * @arg PWR_RAM1_AHB_MEMORY_BLOCK : AHB RAM1 memory. 1282 * @arg PWR_RAM2_AHB_MEMORY_BLOCK : AHB RAM2 memory. 1283 * @arg PWR_RAM1_AXI_MEMORY_BLOCK : AXI RAM1 memory. 1284 * @arg PWR_RAM2_AXI_MEMORY_BLOCK : AXI RAM2 memory. 1285 * @arg PWR_RAM3_AXI_MEMORY_BLOCK : AXI RAM3 memory. 1286 * @retval None. 1287 */ 1288 void HAL_PWREx_DisableMemoryShutOff (uint32_t MemoryBlock) 1289 { 1290 /* Check the parameter */ 1291 assert_param (IS_PWR_MEMORY_BLOCK (MemoryBlock)); 1292 1293 /* Disable memory block shut-off */ 1294 CLEAR_BIT (PWR->CR1, MemoryBlock); 1295 } 1296 #endif /* defined (PWR_CR1_SRDRAMSO) */ 1297 1298 /** 1299 * @brief Enable the Wake-up PINx functionality. 1300 * @param sPinParams : Pointer to a PWREx_WakeupPinTypeDef structure that 1301 * contains the configuration information for the wake-up 1302 * Pin. 1303 * @note For dual core devices, please ensure to configure the EXTI lines for 1304 * the different Cortex-Mx. All combination are allowed: wake up only 1305 * Cortex-M7, wake up only Cortex-M4 and wake up Cortex-M7 and 1306 * Cortex-M4. 1307 * @retval None. 1308 */ 1309 void HAL_PWREx_EnableWakeUpPin (PWREx_WakeupPinTypeDef *sPinParams) 1310 { 1311 uint32_t pinConfig; 1312 uint32_t regMask; 1313 const uint32_t pullMask = PWR_WKUPEPR_WKUPPUPD1; 1314 1315 /* Check the parameters */ 1316 assert_param (IS_PWR_WAKEUP_PIN (sPinParams->WakeUpPin)); 1317 assert_param (IS_PWR_WAKEUP_PIN_POLARITY (sPinParams->PinPolarity)); 1318 assert_param (IS_PWR_WAKEUP_PIN_PULL (sPinParams->PinPull)); 1319 1320 pinConfig = sPinParams->WakeUpPin | \ 1321 (sPinParams->PinPolarity << ((POSITION_VAL(sPinParams->WakeUpPin) + PWR_WKUPEPR_WKUPP1_Pos) & 0x1FU)) | \ 1322 (sPinParams->PinPull << (((POSITION_VAL(sPinParams->WakeUpPin) * PWR_WAKEUP_PINS_PULL_SHIFT_OFFSET) + PWR_WKUPEPR_WKUPPUPD1_Pos) & 0x1FU)); 1323 1324 regMask = sPinParams->WakeUpPin | \ 1325 (PWR_WKUPEPR_WKUPP1 << (POSITION_VAL(sPinParams->WakeUpPin) & 0x1FU)) | \ 1326 (pullMask << ((POSITION_VAL(sPinParams->WakeUpPin) * PWR_WAKEUP_PINS_PULL_SHIFT_OFFSET) & 0x1FU)); 1327 1328 /* Enable and Specify the Wake-Up pin polarity and the pull configuration 1329 for the event detection (rising or falling edge) */ 1330 MODIFY_REG (PWR->WKUPEPR, regMask, pinConfig); 1331 #ifndef DUAL_CORE 1332 /* Configure the Wakeup Pin EXTI Line */ 1333 MODIFY_REG (EXTI->IMR2, PWR_EXTI_WAKEUP_PINS_MASK, (sPinParams->WakeUpPin << EXTI_IMR2_IM55_Pos)); 1334 #endif /* !DUAL_CORE */ 1335 } 1336 1337 /** 1338 * @brief Disable the Wake-up PINx functionality. 1339 * @param WakeUpPin : Specifies the Wake-Up pin to be disabled. 1340 * This parameter can be one of the following values: 1341 * @arg PWR_WAKEUP_PIN1 : Disable PA0 wake-up PIN. 1342 * @arg PWR_WAKEUP_PIN2 : Disable PA2 wake-up PIN. 1343 * @arg PWR_WAKEUP_PIN3 : Disable PI8 wake-up PIN. 1344 * @arg PWR_WAKEUP_PIN4 : Disable PC13 wake-up PIN. 1345 * @arg PWR_WAKEUP_PIN5 : Disable PI11 wake-up PIN. 1346 * @arg PWR_WAKEUP_PIN6 : Disable PC1 wake-up PIN. 1347 * @note The PWR_WAKEUP_PIN3 and PWR_WAKEUP_PIN5 are available only for 1348 * devices that support GPIOI port. 1349 * @retval None 1350 */ 1351 void HAL_PWREx_DisableWakeUpPin (uint32_t WakeUpPin) 1352 { 1353 /* Check the parameter */ 1354 assert_param (IS_PWR_WAKEUP_PIN (WakeUpPin)); 1355 1356 /* Disable the WakeUpPin */ 1357 CLEAR_BIT (PWR->WKUPEPR, WakeUpPin); 1358 } 1359 1360 /** 1361 * @brief Get the Wake-Up Pin pending flags. 1362 * @param WakeUpFlag : Specifies the Wake-Up PIN flag to be checked. 1363 * This parameter can be one of the following values: 1364 * @arg PWR_WAKEUP_FLAG1 : Get wakeup event received from PA0. 1365 * @arg PWR_WAKEUP_FLAG2 : Get wakeup event received from PA2. 1366 * @arg PWR_WAKEUP_FLAG3 : Get wakeup event received from PI8. 1367 * @arg PWR_WAKEUP_FLAG4 : Get wakeup event received from PC13. 1368 * @arg PWR_WAKEUP_FLAG5 : Get wakeup event received from PI11. 1369 * @arg PWR_WAKEUP_FLAG6 : Get wakeup event received from PC1. 1370 * @arg PWR_WAKEUP_FLAG_ALL : Get Wakeup event received from all 1371 * wake up pins. 1372 * @note The PWR_WAKEUP_FLAG3 and PWR_WAKEUP_FLAG5 are available only for 1373 * devices that support GPIOI port. 1374 * @retval The Wake-Up pin flag. 1375 */ 1376 uint32_t HAL_PWREx_GetWakeupFlag (uint32_t WakeUpFlag) 1377 { 1378 /* Check the parameters */ 1379 assert_param (IS_PWR_WAKEUP_FLAG (WakeUpFlag)); 1380 1381 /* Return the wake up pin flag */ 1382 return (PWR->WKUPFR & WakeUpFlag); 1383 } 1384 1385 /** 1386 * @brief Clear the Wake-Up pin pending flag. 1387 * @param WakeUpFlag: Specifies the Wake-Up PIN flag to clear. 1388 * This parameter can be one of the following values: 1389 * @arg PWR_WAKEUP_FLAG1 : Clear the wakeup event received from PA0. 1390 * @arg PWR_WAKEUP_FLAG2 : Clear the wakeup event received from PA2. 1391 * @arg PWR_WAKEUP_FLAG3 : Clear the wakeup event received from PI8. 1392 * @arg PWR_WAKEUP_FLAG4 : Clear the wakeup event received from PC13. 1393 * @arg PWR_WAKEUP_FLAG5 : Clear the wakeup event received from PI11. 1394 * @arg PWR_WAKEUP_FLAG6 : Clear the wakeup event received from PC1. 1395 * @arg PWR_WAKEUP_FLAG_ALL : Clear the wakeup events received from 1396 * all wake up pins. 1397 * @note The PWR_WAKEUP_FLAG3 and PWR_WAKEUP_FLAG5 are available only for 1398 * devices that support GPIOI port. 1399 * @retval HAL status. 1400 */ 1401 HAL_StatusTypeDef HAL_PWREx_ClearWakeupFlag (uint32_t WakeUpFlag) 1402 { 1403 /* Check the parameter */ 1404 assert_param (IS_PWR_WAKEUP_FLAG (WakeUpFlag)); 1405 1406 /* Clear the wake up event received from wake up pin x */ 1407 SET_BIT (PWR->WKUPCR, WakeUpFlag); 1408 1409 /* Check if the wake up event is well cleared */ 1410 if ((PWR->WKUPFR & WakeUpFlag) != 0U) 1411 { 1412 return HAL_ERROR; 1413 } 1414 1415 return HAL_OK; 1416 } 1417 1418 /** 1419 * @brief This function handles the PWR WAKEUP PIN interrupt request. 1420 * @note This API should be called under the WAKEUP_PIN_IRQHandler(). 1421 * @retval None. 1422 */ 1423 void HAL_PWREx_WAKEUP_PIN_IRQHandler (void) 1424 { 1425 /* Wakeup pin EXTI line interrupt detected */ 1426 if (READ_BIT(PWR->WKUPFR, PWR_WKUPFR_WKUPF1) != 0U) 1427 { 1428 /* Clear PWR WKUPF1 flag */ 1429 __HAL_PWR_CLEAR_WAKEUPFLAG (PWR_FLAG_WKUP1); 1430 1431 /* PWR WKUP1 interrupt user callback */ 1432 HAL_PWREx_WKUP1_Callback (); 1433 } 1434 else if (READ_BIT (PWR->WKUPFR, PWR_WKUPFR_WKUPF2) != 0U) 1435 { 1436 /* Clear PWR WKUPF2 flag */ 1437 __HAL_PWR_CLEAR_WAKEUPFLAG (PWR_FLAG_WKUP2); 1438 1439 /* PWR WKUP2 interrupt user callback */ 1440 HAL_PWREx_WKUP2_Callback (); 1441 } 1442 #if defined (PWR_WKUPFR_WKUPF3) 1443 else if (READ_BIT (PWR->WKUPFR, PWR_WKUPFR_WKUPF3) != 0U) 1444 { 1445 /* Clear PWR WKUPF3 flag */ 1446 __HAL_PWR_CLEAR_WAKEUPFLAG (PWR_FLAG_WKUP3); 1447 1448 /* PWR WKUP3 interrupt user callback */ 1449 HAL_PWREx_WKUP3_Callback (); 1450 } 1451 #endif /* defined (PWR_WKUPFR_WKUPF3) */ 1452 else if (READ_BIT (PWR->WKUPFR, PWR_WKUPFR_WKUPF4) != 0U) 1453 { 1454 /* Clear PWR WKUPF4 flag */ 1455 __HAL_PWR_CLEAR_WAKEUPFLAG (PWR_FLAG_WKUP4); 1456 1457 /* PWR WKUP4 interrupt user callback */ 1458 HAL_PWREx_WKUP4_Callback (); 1459 } 1460 #if defined (PWR_WKUPFR_WKUPF5) 1461 else if (READ_BIT (PWR->WKUPFR, PWR_WKUPFR_WKUPF5) != 0U) 1462 { 1463 /* Clear PWR WKUPF5 flag */ 1464 __HAL_PWR_CLEAR_WAKEUPFLAG (PWR_FLAG_WKUP5); 1465 1466 /* PWR WKUP5 interrupt user callback */ 1467 HAL_PWREx_WKUP5_Callback (); 1468 } 1469 #endif /* defined (PWR_WKUPFR_WKUPF5) */ 1470 else 1471 { 1472 /* Clear PWR WKUPF6 flag */ 1473 __HAL_PWR_CLEAR_WAKEUPFLAG (PWR_FLAG_WKUP6); 1474 1475 /* PWR WKUP6 interrupt user callback */ 1476 HAL_PWREx_WKUP6_Callback (); 1477 } 1478 } 1479 1480 /** 1481 * @brief PWR WKUP1 interrupt callback. 1482 * @retval None. 1483 */ 1484 __weak void HAL_PWREx_WKUP1_Callback (void) 1485 { 1486 /* NOTE : This function should not be modified, when the callback is needed, 1487 the HAL_PWREx_WKUP1Callback can be implemented in the user file 1488 */ 1489 } 1490 1491 /** 1492 * @brief PWR WKUP2 interrupt callback. 1493 * @retval None. 1494 */ 1495 __weak void HAL_PWREx_WKUP2_Callback (void) 1496 { 1497 /* NOTE : This function should not be modified, when the callback is needed, 1498 the HAL_PWREx_WKUP2Callback can be implemented in the user file 1499 */ 1500 } 1501 1502 #if defined (PWR_WKUPFR_WKUPF3) 1503 /** 1504 * @brief PWR WKUP3 interrupt callback. 1505 * @retval None. 1506 */ 1507 __weak void HAL_PWREx_WKUP3_Callback (void) 1508 { 1509 /* NOTE : This function should not be modified, when the callback is needed, 1510 the HAL_PWREx_WKUP3Callback can be implemented in the user file 1511 */ 1512 } 1513 #endif /* defined (PWR_WKUPFR_WKUPF3) */ 1514 1515 /** 1516 * @brief PWR WKUP4 interrupt callback. 1517 * @retval None. 1518 */ 1519 __weak void HAL_PWREx_WKUP4_Callback (void) 1520 { 1521 /* NOTE : This function should not be modified, when the callback is needed, 1522 the HAL_PWREx_WKUP4Callback can be implemented in the user file 1523 */ 1524 } 1525 1526 #if defined (PWR_WKUPFR_WKUPF5) 1527 /** 1528 * @brief PWR WKUP5 interrupt callback. 1529 * @retval None. 1530 */ 1531 __weak void HAL_PWREx_WKUP5_Callback (void) 1532 { 1533 /* NOTE : This function should not be modified, when the callback is needed, 1534 the HAL_PWREx_WKUP5Callback can be implemented in the user file 1535 */ 1536 } 1537 #endif /* defined (PWR_WKUPFR_WKUPF5) */ 1538 1539 /** 1540 * @brief PWR WKUP6 interrupt callback. 1541 * @retval None. 1542 */ 1543 __weak void HAL_PWREx_WKUP6_Callback (void) 1544 { 1545 /* NOTE : This function should not be modified, when the callback is needed, 1546 the HAL_PWREx_WKUP6Callback can be implemented in the user file 1547 */ 1548 } 1549 /** 1550 * @} 1551 */ 1552 1553 /** @defgroup PWREx_Exported_Functions_Group3 Peripherals control functions 1554 * @ingroup RTEMSBSPsARMSTM32H7 1555 * @brief Peripherals control functions 1556 * 1557 @verbatim 1558 =============================================================================== 1559 ##### Peripherals control functions ##### 1560 =============================================================================== 1561 1562 *** Main and Backup Regulators configuration *** 1563 ================================================ 1564 [..] 1565 (+) The backup domain includes 4 Kbytes of backup SRAM accessible only 1566 from the CPU, and addressed in 32-bit, 16-bit or 8-bit mode. Its 1567 content is retained even in Standby or VBAT mode when the low power 1568 backup regulator is enabled. It can be considered as an internal 1569 EEPROM when VBAT is always present. You can use the 1570 HAL_PWREx_EnableBkUpReg() function to enable the low power backup 1571 regulator. 1572 (+) When the backup domain is supplied by VDD (analog switch connected to 1573 VDD) the backup SRAM is powered from VDD which replaces the VBAT power 1574 supply to save battery life. 1575 (+) The backup SRAM is not mass erased by a tamper event. It is read 1576 protected to prevent confidential data, such as cryptographic private 1577 key, from being accessed. The backup SRAM can be erased only through 1578 the Flash interface when a protection level change from level 1 to 1579 level 0 is requested. 1580 -@- Refer to the description of Read protection (RDP) in the Flash 1581 programming manual. 1582 (+) The main internal regulator can be configured to have a tradeoff 1583 between performance and power consumption when the device does not 1584 operate at the maximum frequency. This is done through 1585 HAL_PWREx_ControlVoltageScaling(VOS) function which configure the VOS 1586 bit in PWR_D3CR register. 1587 (+) The main internal regulator can be configured to operate in Low Power 1588 mode when the system enters STOP mode to further reduce power 1589 consumption. 1590 This is done through HAL_PWREx_ControlStopModeVoltageScaling(SVOS) 1591 function which configure the SVOS bit in PWR_CR1 register. 1592 The selected SVOS4 and SVOS5 levels add an additional startup delay 1593 when exiting from system Stop mode. 1594 -@- Refer to the product datasheets for more details. 1595 1596 *** USB Regulator configuration *** 1597 =================================== 1598 [..] 1599 (+) The USB transceivers are supplied from a dedicated VDD33USB supply 1600 that can be provided either by the integrated USB regulator, or by an 1601 external USB supply. 1602 (+) The USB regulator is enabled by HAL_PWREx_EnableUSBReg() function, the 1603 VDD33USB is then provided from the USB regulator. 1604 (+) When the USB regulator is enabled, the VDD33USB supply level detector 1605 shall be enabled through HAL_PWREx_EnableUSBVoltageDetector() 1606 function. 1607 (+) The USB regulator is disabled through HAL_PWREx_DisableUSBReg() 1608 function and VDD33USB can be provided from an external supply. In this 1609 case VDD33USB and VDD50USB shall be connected together. 1610 1611 *** VBAT battery charging *** 1612 ============================= 1613 [..] 1614 (+) When VDD is present, the external battery connected to VBAT can be 1615 charged through an internal resistance. VBAT charging can be performed 1616 either through a 5 KOhm resistor or through a 1.5 KOhm resistor. 1617 (+) VBAT charging is enabled by HAL_PWREx_EnableBatteryCharging 1618 (ResistorValue) function with: 1619 (++) ResistorValue: 1620 (+++) PWR_BATTERY_CHARGING_RESISTOR_5: 5 KOhm resistor. 1621 (+++) PWR_BATTERY_CHARGING_RESISTOR_1_5: 1.5 KOhm resistor. 1622 (+) VBAT charging is disabled by HAL_PWREx_DisableBatteryCharging() 1623 function. 1624 1625 @endverbatim 1626 * @{ 1627 */ 1628 1629 /** 1630 * @brief Enable the Backup Regulator. 1631 * @retval HAL status. 1632 */ 1633 HAL_StatusTypeDef HAL_PWREx_EnableBkUpReg (void) 1634 { 1635 uint32_t tickstart; 1636 1637 /* Enable the Backup regulator */ 1638 SET_BIT (PWR->CR2, PWR_CR2_BREN); 1639 1640 /* Get tick */ 1641 tickstart = HAL_GetTick (); 1642 1643 /* Wait till Backup regulator ready flag is set */ 1644 while (__HAL_PWR_GET_FLAG (PWR_FLAG_BRR) == 0U) 1645 { 1646 if ((HAL_GetTick() - tickstart ) > PWR_FLAG_SETTING_DELAY) 1647 { 1648 return HAL_ERROR; 1649 } 1650 } 1651 1652 return HAL_OK; 1653 } 1654 1655 /** 1656 * @brief Disable the Backup Regulator. 1657 * @retval HAL status. 1658 */ 1659 HAL_StatusTypeDef HAL_PWREx_DisableBkUpReg (void) 1660 { 1661 uint32_t tickstart; 1662 1663 /* Disable the Backup regulator */ 1664 CLEAR_BIT (PWR->CR2, PWR_CR2_BREN); 1665 1666 /* Get tick */ 1667 tickstart = HAL_GetTick (); 1668 1669 /* Wait till Backup regulator ready flag is reset */ 1670 while (__HAL_PWR_GET_FLAG (PWR_FLAG_BRR) != 0U) 1671 { 1672 if ((HAL_GetTick() - tickstart ) > PWR_FLAG_SETTING_DELAY) 1673 { 1674 return HAL_ERROR; 1675 } 1676 } 1677 1678 return HAL_OK; 1679 } 1680 1681 /** 1682 * @brief Enable the USB Regulator. 1683 * @retval HAL status. 1684 */ 1685 HAL_StatusTypeDef HAL_PWREx_EnableUSBReg (void) 1686 { 1687 uint32_t tickstart; 1688 1689 /* Enable the USB regulator */ 1690 SET_BIT (PWR->CR3, PWR_CR3_USBREGEN); 1691 1692 /* Get tick */ 1693 tickstart = HAL_GetTick (); 1694 1695 /* Wait till the USB regulator ready flag is set */ 1696 while (__HAL_PWR_GET_FLAG (PWR_FLAG_USB33RDY) == 0U) 1697 { 1698 if ((HAL_GetTick() - tickstart ) > PWR_FLAG_SETTING_DELAY) 1699 { 1700 return HAL_ERROR; 1701 } 1702 } 1703 1704 return HAL_OK; 1705 } 1706 1707 /** 1708 * @brief Disable the USB Regulator. 1709 * @retval HAL status. 1710 */ 1711 HAL_StatusTypeDef HAL_PWREx_DisableUSBReg (void) 1712 { 1713 uint32_t tickstart; 1714 1715 /* Disable the USB regulator */ 1716 CLEAR_BIT (PWR->CR3, PWR_CR3_USBREGEN); 1717 1718 /* Get tick */ 1719 tickstart = HAL_GetTick (); 1720 1721 /* Wait till the USB regulator ready flag is reset */ 1722 while(__HAL_PWR_GET_FLAG (PWR_FLAG_USB33RDY) != 0U) 1723 { 1724 if ((HAL_GetTick() - tickstart ) > PWR_FLAG_SETTING_DELAY) 1725 { 1726 return HAL_ERROR; 1727 } 1728 } 1729 1730 return HAL_OK; 1731 } 1732 1733 /** 1734 * @brief Enable the USB voltage level detector. 1735 * @retval None. 1736 */ 1737 void HAL_PWREx_EnableUSBVoltageDetector (void) 1738 { 1739 /* Enable the USB voltage detector */ 1740 SET_BIT (PWR->CR3, PWR_CR3_USB33DEN); 1741 } 1742 1743 /** 1744 * @brief Disable the USB voltage level detector. 1745 * @retval None. 1746 */ 1747 void HAL_PWREx_DisableUSBVoltageDetector (void) 1748 { 1749 /* Disable the USB voltage detector */ 1750 CLEAR_BIT (PWR->CR3, PWR_CR3_USB33DEN); 1751 } 1752 1753 /** 1754 * @brief Enable the Battery charging. 1755 * @note When VDD is present, charge the external battery through an internal 1756 * resistor. 1757 * @param ResistorValue : Specifies the charging resistor. 1758 * This parameter can be one of the following values : 1759 * @arg PWR_BATTERY_CHARGING_RESISTOR_5 : 5 KOhm resistor. 1760 * @arg PWR_BATTERY_CHARGING_RESISTOR_1_5 : 1.5 KOhm resistor. 1761 * @retval None. 1762 */ 1763 void HAL_PWREx_EnableBatteryCharging (uint32_t ResistorValue) 1764 { 1765 /* Check the parameter */ 1766 assert_param (IS_PWR_BATTERY_RESISTOR_SELECT (ResistorValue)); 1767 1768 /* Specify the charging resistor */ 1769 MODIFY_REG (PWR->CR3, PWR_CR3_VBRS, ResistorValue); 1770 1771 /* Enable the Battery charging */ 1772 SET_BIT (PWR->CR3, PWR_CR3_VBE); 1773 } 1774 1775 /** 1776 * @brief Disable the Battery charging. 1777 * @retval None. 1778 */ 1779 void HAL_PWREx_DisableBatteryCharging (void) 1780 { 1781 /* Disable the Battery charging */ 1782 CLEAR_BIT (PWR->CR3, PWR_CR3_VBE); 1783 } 1784 1785 #if defined (PWR_CR1_BOOSTE) 1786 /** 1787 * @brief Enable the booster to guarantee the analog switch AC performance when 1788 * the VDD supply voltage is below 2V7. 1789 * @note The VDD supply voltage can be monitored through the PVD and the PLS 1790 * field bits. 1791 * @retval None. 1792 */ 1793 void HAL_PWREx_EnableAnalogBooster (void) 1794 { 1795 /* Enable the Analog voltage */ 1796 SET_BIT (PWR->CR1, PWR_CR1_AVD_READY); 1797 1798 /* Enable VDDA booster */ 1799 SET_BIT (PWR->CR1, PWR_CR1_BOOSTE); 1800 } 1801 1802 /** 1803 * @brief Disable the analog booster. 1804 * @retval None. 1805 */ 1806 void HAL_PWREx_DisableAnalogBooster (void) 1807 { 1808 /* Disable VDDA booster */ 1809 CLEAR_BIT (PWR->CR1, PWR_CR1_BOOSTE); 1810 1811 /* Disable the Analog voltage */ 1812 CLEAR_BIT (PWR->CR1, PWR_CR1_AVD_READY); 1813 } 1814 #endif /* defined (PWR_CR1_BOOSTE) */ 1815 /** 1816 * @} 1817 */ 1818 1819 /** @defgroup PWREx_Exported_Functions_Group4 Power Monitoring functions 1820 * @ingroup RTEMSBSPsARMSTM32H7 1821 * @brief Power Monitoring functions 1822 * 1823 @verbatim 1824 =============================================================================== 1825 ##### Power Monitoring functions ##### 1826 =============================================================================== 1827 1828 *** VBAT and Temperature supervision *** 1829 ======================================== 1830 [..] 1831 (+) The VBAT battery voltage supply can be monitored by comparing it with 1832 two threshold levels: VBAThigh and VBATlow. VBATH flag and VBATL flags 1833 in the PWR control register 2 (PWR_CR2), indicate if VBAT is higher or 1834 lower than the threshold. 1835 (+) The temperature can be monitored by comparing it with two threshold 1836 levels, TEMPhigh and TEMPlow. TEMPH and TEMPL flags, in the PWR 1837 control register 2 (PWR_CR2), indicate whether the device temperature 1838 is higher or lower than the threshold. 1839 (+) The VBAT and the temperature monitoring is enabled by 1840 HAL_PWREx_EnableMonitoring() function and disabled by 1841 HAL_PWREx_DisableMonitoring() function. 1842 (+) The HAL_PWREx_GetVBATLevel() function returns the VBAT level which can 1843 be : PWR_VBAT_BELOW_LOW_THRESHOLD or PWR_VBAT_ABOVE_HIGH_THRESHOLD or 1844 PWR_VBAT_BETWEEN_HIGH_LOW_THRESHOLD. 1845 (+) The HAL_PWREx_GetTemperatureLevel() function returns the Temperature 1846 level which can be : 1847 PWR_TEMP_BELOW_LOW_THRESHOLD or PWR_TEMP_ABOVE_HIGH_THRESHOLD or 1848 PWR_TEMP_BETWEEN_HIGH_LOW_THRESHOLD. 1849 1850 *** AVD configuration *** 1851 ========================= 1852 [..] 1853 (+) The AVD is used to monitor the VDDA power supply by comparing it to a 1854 threshold selected by the AVD Level (ALS[3:0] bits in the PWR_CR1 1855 register). 1856 (+) A AVDO flag is available to indicate if VDDA is higher or lower 1857 than the AVD threshold. This event is internally connected to the EXTI 1858 line 16 to generate an interrupt if enabled. 1859 It is configurable through __HAL_PWR_AVD_EXTI_ENABLE_IT() macro. 1860 (+) The AVD is stopped in System Standby mode. 1861 1862 @endverbatim 1863 * @{ 1864 */ 1865 1866 /** 1867 * @brief Enable the VBAT and temperature monitoring. 1868 * @retval HAL status. 1869 */ 1870 void HAL_PWREx_EnableMonitoring (void) 1871 { 1872 /* Enable the VBAT and Temperature monitoring */ 1873 SET_BIT (PWR->CR2, PWR_CR2_MONEN); 1874 } 1875 1876 /** 1877 * @brief Disable the VBAT and temperature monitoring. 1878 * @retval HAL status. 1879 */ 1880 void HAL_PWREx_DisableMonitoring (void) 1881 { 1882 /* Disable the VBAT and Temperature monitoring */ 1883 CLEAR_BIT (PWR->CR2, PWR_CR2_MONEN); 1884 } 1885 1886 /** 1887 * @brief Indicate whether the junction temperature is between, above or below 1888 * the thresholds. 1889 * @retval Temperature level. 1890 */ 1891 uint32_t HAL_PWREx_GetTemperatureLevel (void) 1892 { 1893 uint32_t tempLevel, regValue; 1894 1895 /* Read the temperature flags */ 1896 regValue = READ_BIT (PWR->CR2, (PWR_CR2_TEMPH | PWR_CR2_TEMPL)); 1897 1898 /* Check if the temperature is below the threshold */ 1899 if (regValue == PWR_CR2_TEMPL) 1900 { 1901 tempLevel = PWR_TEMP_BELOW_LOW_THRESHOLD; 1902 } 1903 /* Check if the temperature is above the threshold */ 1904 else if (regValue == PWR_CR2_TEMPH) 1905 { 1906 tempLevel = PWR_TEMP_ABOVE_HIGH_THRESHOLD; 1907 } 1908 /* The temperature is between the thresholds */ 1909 else 1910 { 1911 tempLevel = PWR_TEMP_BETWEEN_HIGH_LOW_THRESHOLD; 1912 } 1913 1914 return tempLevel; 1915 } 1916 1917 /** 1918 * @brief Indicate whether the Battery voltage level is between, above or below 1919 * the thresholds. 1920 * @retval VBAT level. 1921 */ 1922 uint32_t HAL_PWREx_GetVBATLevel (void) 1923 { 1924 uint32_t VBATLevel, regValue; 1925 1926 /* Read the VBAT flags */ 1927 regValue = READ_BIT (PWR->CR2, (PWR_CR2_VBATH | PWR_CR2_VBATL)); 1928 1929 /* Check if the VBAT is below the threshold */ 1930 if (regValue == PWR_CR2_VBATL) 1931 { 1932 VBATLevel = PWR_VBAT_BELOW_LOW_THRESHOLD; 1933 } 1934 /* Check if the VBAT is above the threshold */ 1935 else if (regValue == PWR_CR2_VBATH) 1936 { 1937 VBATLevel = PWR_VBAT_ABOVE_HIGH_THRESHOLD; 1938 } 1939 /* The VBAT is between the thresholds */ 1940 else 1941 { 1942 VBATLevel = PWR_VBAT_BETWEEN_HIGH_LOW_THRESHOLD; 1943 } 1944 1945 return VBATLevel; 1946 } 1947 1948 #if defined (PWR_CSR1_MMCVDO) 1949 /** 1950 * @brief Get the VDDMMC voltage level. 1951 * @retval The VDDMMC voltage level. 1952 */ 1953 PWREx_MMC_VoltageLevel HAL_PWREx_GetMMCVoltage (void) 1954 { 1955 PWREx_MMC_VoltageLevel mmc_voltage; 1956 1957 /* Check voltage detector output on VDDMMC value */ 1958 if ((PWR->CSR1 & PWR_CSR1_MMCVDO_Msk) == 0U) 1959 { 1960 mmc_voltage = PWR_MMC_VOLTAGE_BELOW_1V2; 1961 } 1962 else 1963 { 1964 mmc_voltage = PWR_MMC_VOLTAGE_EQUAL_ABOVE_1V2; 1965 } 1966 1967 return mmc_voltage; 1968 } 1969 #endif /* defined (PWR_CSR1_MMCVDO) */ 1970 1971 /** 1972 * @brief Configure the event mode and the voltage threshold detected by the 1973 * Analog Voltage Detector (AVD). 1974 * @param sConfigAVD : Pointer to an PWREx_AVDTypeDef structure that contains 1975 * the configuration information for the AVD. 1976 * @note Refer to the electrical characteristics of your device datasheet for 1977 * more details about the voltage threshold corresponding to each 1978 * detection level. 1979 * @note For dual core devices, please ensure to configure the EXTI lines for 1980 * the different Cortex-Mx through PWR_Exported_Macro provided by this 1981 * driver. All combination are allowed: wake up only Cortex-M7, wake up 1982 * only Cortex-M4 and wake up Cortex-M7 and Cortex-M4. 1983 * @retval None. 1984 */ 1985 void HAL_PWREx_ConfigAVD (PWREx_AVDTypeDef *sConfigAVD) 1986 { 1987 /* Check the parameters */ 1988 assert_param (IS_PWR_AVD_LEVEL (sConfigAVD->AVDLevel)); 1989 assert_param (IS_PWR_AVD_MODE (sConfigAVD->Mode)); 1990 1991 /* Set the ALS[18:17] bits according to AVDLevel value */ 1992 MODIFY_REG (PWR->CR1, PWR_CR1_ALS, sConfigAVD->AVDLevel); 1993 1994 /* Clear any previous config */ 1995 #if !defined (DUAL_CORE) 1996 __HAL_PWR_AVD_EXTI_DISABLE_EVENT (); 1997 __HAL_PWR_AVD_EXTI_DISABLE_IT (); 1998 #endif /* !defined (DUAL_CORE) */ 1999 2000 __HAL_PWR_AVD_EXTI_DISABLE_RISING_EDGE (); 2001 __HAL_PWR_AVD_EXTI_DISABLE_FALLING_EDGE (); 2002 2003 #if !defined (DUAL_CORE) 2004 /* Configure the interrupt mode */ 2005 if ((sConfigAVD->Mode & AVD_MODE_IT) == AVD_MODE_IT) 2006 { 2007 __HAL_PWR_AVD_EXTI_ENABLE_IT (); 2008 } 2009 2010 /* Configure the event mode */ 2011 if ((sConfigAVD->Mode & AVD_MODE_EVT) == AVD_MODE_EVT) 2012 { 2013 __HAL_PWR_AVD_EXTI_ENABLE_EVENT (); 2014 } 2015 #endif /* !defined (DUAL_CORE) */ 2016 2017 /* Rising edge configuration */ 2018 if ((sConfigAVD->Mode & AVD_RISING_EDGE) == AVD_RISING_EDGE) 2019 { 2020 __HAL_PWR_AVD_EXTI_ENABLE_RISING_EDGE (); 2021 } 2022 2023 /* Falling edge configuration */ 2024 if ((sConfigAVD->Mode & AVD_FALLING_EDGE) == AVD_FALLING_EDGE) 2025 { 2026 __HAL_PWR_AVD_EXTI_ENABLE_FALLING_EDGE (); 2027 } 2028 } 2029 2030 /** 2031 * @brief Enable the Analog Voltage Detector (AVD). 2032 * @retval None. 2033 */ 2034 void HAL_PWREx_EnableAVD (void) 2035 { 2036 /* Enable the Analog Voltage Detector */ 2037 SET_BIT (PWR->CR1, PWR_CR1_AVDEN); 2038 } 2039 2040 /** 2041 * @brief Disable the Analog Voltage Detector(AVD). 2042 * @retval None. 2043 */ 2044 void HAL_PWREx_DisableAVD (void) 2045 { 2046 /* Disable the Analog Voltage Detector */ 2047 CLEAR_BIT (PWR->CR1, PWR_CR1_AVDEN); 2048 } 2049 2050 /** 2051 * @brief This function handles the PWR PVD/AVD interrupt request. 2052 * @note This API should be called under the PVD_AVD_IRQHandler(). 2053 * @retval None 2054 */ 2055 void HAL_PWREx_PVD_AVD_IRQHandler (void) 2056 { 2057 /* Check if the Programmable Voltage Detector is enabled (PVD) */ 2058 if (READ_BIT (PWR->CR1, PWR_CR1_PVDEN) != 0U) 2059 { 2060 #if defined (DUAL_CORE) 2061 if (HAL_GetCurrentCPUID () == CM7_CPUID) 2062 #endif /* defined (DUAL_CORE) */ 2063 { 2064 /* Check PWR D1/CD EXTI flag */ 2065 if (__HAL_PWR_PVD_EXTI_GET_FLAG () != 0U) 2066 { 2067 /* PWR PVD interrupt user callback */ 2068 HAL_PWR_PVDCallback (); 2069 2070 if(__HAL_PWR_GET_FLAG (PWR_FLAG_AVDO) == 0U) 2071 { 2072 /* Clear PWR EXTI D1/CD pending bit */ 2073 __HAL_PWR_PVD_EXTI_CLEAR_FLAG (); 2074 } 2075 } 2076 } 2077 #if defined (DUAL_CORE) 2078 else 2079 { 2080 /* Check PWR EXTI D2 flag */ 2081 if (__HAL_PWR_PVD_EXTID2_GET_FLAG () != 0U) 2082 { 2083 /* PWR PVD interrupt user callback */ 2084 HAL_PWR_PVDCallback (); 2085 2086 if(__HAL_PWR_GET_FLAG (PWR_FLAG_AVDO) == 0U) 2087 { 2088 /* Clear PWR EXTI D2 pending bit */ 2089 __HAL_PWR_PVD_EXTID2_CLEAR_FLAG (); 2090 } 2091 } 2092 } 2093 #endif /* defined (DUAL_CORE) */ 2094 } 2095 2096 /* Check if the Analog Voltage Detector is enabled (AVD) */ 2097 if (READ_BIT (PWR->CR1, PWR_CR1_AVDEN) != 0U) 2098 { 2099 #if defined (DUAL_CORE) 2100 if (HAL_GetCurrentCPUID () == CM7_CPUID) 2101 #endif /* defined (DUAL_CORE) */ 2102 { 2103 /* Check PWR EXTI D1/CD flag */ 2104 if (__HAL_PWR_AVD_EXTI_GET_FLAG () != 0U) 2105 { 2106 /* PWR AVD interrupt user callback */ 2107 HAL_PWREx_AVDCallback (); 2108 2109 if(__HAL_PWR_GET_FLAG (PWR_FLAG_PVDO) == 0U) 2110 { 2111 /* Clear PWR EXTI D1/CD pending bit */ 2112 __HAL_PWR_AVD_EXTI_CLEAR_FLAG (); 2113 } 2114 } 2115 } 2116 #if defined (DUAL_CORE) 2117 else 2118 { 2119 /* Check PWR EXTI D2 flag */ 2120 if (__HAL_PWR_AVD_EXTID2_GET_FLAG () != 0U) 2121 { 2122 /* PWR AVD interrupt user callback */ 2123 HAL_PWREx_AVDCallback (); 2124 2125 if(__HAL_PWR_GET_FLAG (PWR_FLAG_PVDO) == 0U) 2126 { 2127 /* Clear PWR EXTI D2 pending bit */ 2128 __HAL_PWR_AVD_EXTID2_CLEAR_FLAG (); 2129 } 2130 } 2131 } 2132 #endif /* defined (DUAL_CORE) */ 2133 } 2134 } 2135 2136 /** 2137 * @brief PWR AVD interrupt callback. 2138 * @retval None. 2139 */ 2140 __weak void HAL_PWREx_AVDCallback (void) 2141 { 2142 /* NOTE : This function should not be modified, when the callback is needed, 2143 the HAL_PWR_AVDCallback can be implemented in the user file 2144 */ 2145 } 2146 /** 2147 * @} 2148 */ 2149 2150 /** 2151 * @} 2152 */ 2153 2154 #endif /* HAL_PWR_MODULE_ENABLED */ 2155 2156 /** 2157 * @} 2158 */ 2159 2160 /** 2161 * @} 2162 */ 2163
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |