STM32H735xx HAL User Manual
|
00001 /** 00002 ****************************************************************************** 00003 * @file stm32h7xx_hal_pwr_ex.c 00004 * @author MCD Application Team 00005 * @brief Extended PWR HAL module driver. 00006 * This file provides firmware functions to manage the following 00007 * functionalities of PWR extension peripheral: 00008 * + Peripheral Extended features functions 00009 ****************************************************************************** 00010 * @attention 00011 * 00012 * Copyright (c) 2017 STMicroelectronics. 00013 * All rights reserved. 00014 * 00015 * This software is licensed under terms that can be found in the LICENSE file 00016 * in the root directory of this software component. 00017 * If no LICENSE file comes with this software, it is provided AS-IS. 00018 * 00019 ****************************************************************************** 00020 @verbatim 00021 ============================================================================== 00022 ##### How to use this driver ##### 00023 ============================================================================== 00024 [..] 00025 (#) Call HAL_PWREx_ConfigSupply() function to configure the regulator supply 00026 with the following different setups according to hardware (support SMPS): 00027 (+) PWR_DIRECT_SMPS_SUPPLY 00028 (+) PWR_SMPS_1V8_SUPPLIES_LDO 00029 (+) PWR_SMPS_2V5_SUPPLIES_LDO 00030 (+) PWR_SMPS_1V8_SUPPLIES_EXT_AND_LDO 00031 (+) PWR_SMPS_2V5_SUPPLIES_EXT_AND_LDO 00032 (+) PWR_SMPS_1V8_SUPPLIES_EXT 00033 (+) PWR_SMPS_2V5_SUPPLIES_EXT 00034 (+) PWR_LDO_SUPPLY 00035 (+) PWR_EXTERNAL_SOURCE_SUPPLY 00036 00037 (#) Call HAL_PWREx_GetSupplyConfig() function to get the current supply setup. 00038 00039 (#) Call HAL_PWREx_ControlVoltageScaling() function to configure the main 00040 internal regulator output voltage. The voltage scaling could be one of 00041 the following scales : 00042 (+) PWR_REGULATOR_VOLTAGE_SCALE0 00043 (+) PWR_REGULATOR_VOLTAGE_SCALE1 00044 (+) PWR_REGULATOR_VOLTAGE_SCALE2 00045 (+) PWR_REGULATOR_VOLTAGE_SCALE3 00046 00047 (#) Call HAL_PWREx_GetVoltageRange() function to get the current output 00048 voltage applied to the main regulator. 00049 00050 (#) Call HAL_PWREx_ControlStopModeVoltageScaling() function to configure the 00051 main internal regulator output voltage in STOP mode. The voltage scaling 00052 in STOP mode could be one of the following scales : 00053 (+) PWR_REGULATOR_SVOS_SCALE3 00054 (+) PWR_REGULATOR_SVOS_SCALE4 00055 (+) PWR_REGULATOR_SVOS_SCALE5 00056 00057 (#) Call HAL_PWREx_GetStopModeVoltageRange() function to get the current 00058 output voltage applied to the main regulator in STOP mode. 00059 00060 (#) Call HAL_PWREx_EnterSTOP2Mode() function to enter the system in STOP mode 00061 with core domain in D2STOP mode. This API is used only for STM32H7Axxx 00062 and STM32H7Bxxx devices. 00063 Please ensure to clear all CPU pending events by calling 00064 HAL_PWREx_ClearPendingEvent() function when trying to enter the Cortex-Mx 00065 in DEEP-SLEEP mode with __WFE() entry. 00066 00067 (#) Call HAL_PWREx_EnterSTOPMode() function to enter the selected domain in 00068 DSTOP mode. Call this API with all available power domains to enter the 00069 system in STOP mode. 00070 Please ensure to clear all CPU pending events by calling 00071 HAL_PWREx_ClearPendingEvent() function when trying to enter the Cortex-Mx 00072 in DEEP-SLEEP mode with __WFE() entry. 00073 00074 (#) Call HAL_PWREx_ClearPendingEvent() function always before entring the 00075 Cortex-Mx in any low power mode (SLEEP/DEEP-SLEEP) using WFE entry. 00076 00077 (#) Call HAL_PWREx_EnterSTANDBYMode() function to enter the selected domain 00078 in DSTANDBY mode. Call this API with all available power domains to enter 00079 the system in STANDBY mode. 00080 00081 (#) Call HAL_PWREx_ConfigD3Domain() function to setup the D3/SRD domain state 00082 (RUN/STOP) when the system enter to low power mode. 00083 00084 (#) Call HAL_PWREx_ClearDomainFlags() function to clear the CPU flags for the 00085 selected power domain. This API is used only for dual core devices. 00086 00087 (#) Call HAL_PWREx_HoldCore() and HAL_PWREx_ReleaseCore() functions to hold 00088 and release the selected CPU and and their domain peripherals when 00089 exiting STOP mode. These APIs are used only for dual core devices. 00090 00091 (#) Call HAL_PWREx_EnableFlashPowerDown() and 00092 HAL_PWREx_DisableFlashPowerDown() functions to enable and disable the 00093 Flash Power Down in STOP mode. 00094 00095 (#) Call HAL_PWREx_EnableMemoryShutOff() and 00096 HAL_PWREx_DisableMemoryShutOff() functions to enable and disable the 00097 memory block shut-off in DStop or DStop2. These APIs are used only for 00098 STM32H7Axxx and STM32H7Bxxx lines. 00099 00100 (#) Call HAL_PWREx_EnableWakeUpPin() and HAL_PWREx_DisableWakeUpPin() 00101 functions to enable and disable the Wake-up pin functionality for 00102 the selected pin. 00103 00104 (#) Call HAL_PWREx_GetWakeupFlag() and HAL_PWREx_ClearWakeupFlag() 00105 functions to manage wake-up flag for the selected pin. 00106 00107 (#) Call HAL_PWREx_WAKEUP_PIN_IRQHandler() function to handle all wake-up 00108 pins interrupts. 00109 00110 (#) Call HAL_PWREx_EnableBkUpReg() and HAL_PWREx_DisableBkUpReg() functions 00111 to enable and disable the backup domain regulator. 00112 00113 (#) Call HAL_PWREx_EnableUSBReg(), HAL_PWREx_DisableUSBReg(), 00114 HAL_PWREx_EnableUSBVoltageDetector() and 00115 HAL_PWREx_DisableUSBVoltageDetector() functions to manage USB power 00116 regulation functionalities. 00117 00118 (#) Call HAL_PWREx_EnableBatteryCharging() and 00119 HAL_PWREx_DisableBatteryCharging() functions to enable and disable the 00120 battery charging feature with the selected resistor. 00121 00122 (#) Call HAL_PWREx_EnableAnalogBooster() and 00123 HAL_PWREx_DisableAnalogBooster() functions to enable and disable the 00124 AVD boost feature when the VDD supply voltage is below 2V7. 00125 00126 (#) Call HAL_PWREx_EnableMonitoring() and HAL_PWREx_DisableMonitoring() 00127 functions to enable and disable the VBAT and Temperature monitoring. 00128 When VBAT and Temperature monitoring feature is enables, use 00129 HAL_PWREx_GetTemperatureLevel() and HAL_PWREx_GetVBATLevel() to get 00130 respectively the Temperature level and VBAT level. 00131 00132 (#) Call HAL_PWREx_GetMMCVoltage() and HAL_PWREx_DisableMonitoring() 00133 function to get VDDMMC voltage level. This API is used only for 00134 STM32H7Axxx and STM32H7Bxxx lines 00135 00136 (#) Call HAL_PWREx_ConfigAVD() after setting parameter to be configured 00137 (event mode and voltage threshold) in order to set up the Analog Voltage 00138 Detector then use HAL_PWREx_EnableAVD() and HAL_PWREx_DisableAVD() 00139 functions to start and stop the AVD detection. 00140 (+) AVD level could be one of the following values : 00141 (++) 1V7 00142 (++) 2V1 00143 (++) 2V5 00144 (++) 2V8 00145 00146 (#) Call HAL_PWREx_PVD_AVD_IRQHandler() function to handle the PWR PVD and 00147 AVD interrupt request. 00148 00149 @endverbatim 00150 */ 00151 00152 /* Includes ------------------------------------------------------------------*/ 00153 #include "stm32h7xx_hal.h" 00154 00155 /** @addtogroup STM32H7xx_HAL_Driver 00156 * @{ 00157 */ 00158 00159 /** @defgroup PWREx PWREx 00160 * @brief PWR Extended HAL module driver 00161 * @{ 00162 */ 00163 00164 #ifdef HAL_PWR_MODULE_ENABLED 00165 00166 /* Private typedef -----------------------------------------------------------*/ 00167 /* Private define ------------------------------------------------------------*/ 00168 00169 /** @addtogroup PWREx_Private_Constants 00170 * @{ 00171 */ 00172 00173 /** @defgroup PWREx_AVD_Mode_Mask PWR Extended AVD Mode Mask 00174 * @{ 00175 */ 00176 #define AVD_MODE_IT (0x00010000U) 00177 #define AVD_MODE_EVT (0x00020000U) 00178 #define AVD_RISING_EDGE (0x00000001U) 00179 #define AVD_FALLING_EDGE (0x00000002U) 00180 #define AVD_RISING_FALLING_EDGE (0x00000003U) 00181 /** 00182 * @} 00183 */ 00184 00185 /** @defgroup PWREx_REG_SET_TIMEOUT PWR Extended Flag Setting Time Out Value 00186 * @{ 00187 */ 00188 #define PWR_FLAG_SETTING_DELAY (1000U) 00189 /** 00190 * @} 00191 */ 00192 00193 /** @defgroup PWREx_WakeUp_Pins_Offsets PWREx Wake-Up Pins masks and offsets 00194 * @{ 00195 */ 00196 /* Wake-Up Pins EXTI register mask */ 00197 #if defined (EXTI_IMR2_IM57) 00198 #define PWR_EXTI_WAKEUP_PINS_MASK (EXTI_IMR2_IM55 | EXTI_IMR2_IM56 |\ 00199 EXTI_IMR2_IM57 | EXTI_IMR2_IM58 |\ 00200 EXTI_IMR2_IM59 | EXTI_IMR2_IM60) 00201 #else 00202 #define PWR_EXTI_WAKEUP_PINS_MASK (EXTI_IMR2_IM55 | EXTI_IMR2_IM56 |\ 00203 EXTI_IMR2_IM58 | EXTI_IMR2_IM60) 00204 #endif /* defined (EXTI_IMR2_IM57) */ 00205 00206 /* Wake-Up Pins PWR Pin Pull shift offsets */ 00207 #define PWR_WAKEUP_PINS_PULL_SHIFT_OFFSET (2U) 00208 /** 00209 * @} 00210 */ 00211 00212 /** 00213 * @} 00214 */ 00215 00216 /* Private macro -------------------------------------------------------------*/ 00217 /* Private variables ---------------------------------------------------------*/ 00218 /* Private function prototypes -----------------------------------------------*/ 00219 /* Private functions ---------------------------------------------------------*/ 00220 /* Exported types ------------------------------------------------------------*/ 00221 /* Exported functions --------------------------------------------------------*/ 00222 00223 /** @defgroup PWREx_Exported_Functions PWREx Exported Functions 00224 * @{ 00225 */ 00226 00227 /** @defgroup PWREx_Exported_Functions_Group1 Power Supply Control Functions 00228 * @brief Power supply control functions 00229 * 00230 @verbatim 00231 =============================================================================== 00232 ##### Power supply control functions ##### 00233 =============================================================================== 00234 [..] 00235 (#) When the system is powered on, the POR monitors VDD supply. Once VDD is 00236 above the POR threshold level, the voltage regulator is enabled in the 00237 default supply configuration: 00238 (+) The Voltage converter output level is set at 1V0 in accordance with 00239 the VOS3 level configured in PWR (D3/SRD) domain control register 00240 (PWR_D3CR/PWR_SRDCR). 00241 (+) The system is kept in reset mode as long as VCORE is not ok. 00242 (+) Once VCORE is ok, the system is taken out of reset and the HSI 00243 oscillator is enabled. 00244 (+) Once the oscillator is stable, the system is initialized: Flash memory 00245 and option bytes are loaded and the CPU starts in Run* mode. 00246 (+) The software shall then initialize the system including supply 00247 configuration programming using the HAL_PWREx_ConfigSupply(). 00248 (+) Once the supply configuration has been configured, the 00249 HAL_PWREx_ConfigSupply() function checks the ACTVOSRDY bit in PWR 00250 control status register 1 (PWR_CSR1) to guarantee a valid voltage 00251 levels: 00252 (++) As long as ACTVOSRDY indicates that voltage levels are invalid, the 00253 system is in limited Run* mode, write accesses to the RAMs are not 00254 permitted and VOS shall not be changed. 00255 (++) Once ACTVOSRDY indicates that voltage levels are valid, the system 00256 is in normal Run mode, write accesses to RAMs are allowed and VOS 00257 can be changed. 00258 00259 @endverbatim 00260 * @{ 00261 */ 00262 00263 /** 00264 * @brief Configure the system Power Supply. 00265 * @param SupplySource : Specifies the Power Supply source to set after a 00266 * system startup. 00267 * This parameter can be one of the following values : 00268 * @arg PWR_DIRECT_SMPS_SUPPLY : The SMPS supplies the Vcore Power 00269 * Domains. The LDO is Bypassed. 00270 * @arg PWR_SMPS_1V8_SUPPLIES_LDO : The SMPS 1.8V output supplies 00271 * the LDO. The Vcore Power Domains 00272 * are supplied from the LDO. 00273 * @arg PWR_SMPS_2V5_SUPPLIES_LDO : The SMPS 2.5V output supplies 00274 * the LDO. The Vcore Power Domains 00275 * are supplied from the LDO. 00276 * @arg PWR_SMPS_1V8_SUPPLIES_EXT_AND_LDO : The SMPS 1.8V output 00277 * supplies external 00278 * circuits and the LDO. 00279 * The Vcore Power Domains 00280 * are supplied from the 00281 * LDO. 00282 * @arg PWR_SMPS_2V5_SUPPLIES_EXT_AND_LDO : The SMPS 2.5V output 00283 * supplies external 00284 * circuits and the LDO. 00285 * The Vcore Power Domains 00286 * are supplied from the 00287 * LDO. 00288 * @arg PWR_SMPS_1V8_SUPPLIES_EXT : The SMPS 1.8V output supplies 00289 * external circuits. The LDO is 00290 * Bypassed. The Vcore Power 00291 * Domains are supplied from 00292 * external source. 00293 * @arg PWR_SMPS_2V5_SUPPLIES_EXT : The SMPS 2.5V output supplies 00294 * external circuits. The LDO is 00295 * Bypassed. The Vcore Power 00296 * Domains are supplied from 00297 * external source. 00298 * @arg PWR_LDO_SUPPLY : The LDO regulator supplies the Vcore Power 00299 * Domains. The SMPS regulator is Bypassed. 00300 * @arg PWR_EXTERNAL_SOURCE_SUPPLY : The SMPS and the LDO are 00301 * Bypassed. The Vcore Power 00302 * Domains are supplied from 00303 * external source. 00304 * @note The PWR_LDO_SUPPLY and PWR_EXTERNAL_SOURCE_SUPPLY are used by all 00305 * H7 lines. 00306 * The PWR_DIRECT_SMPS_SUPPLY, PWR_SMPS_1V8_SUPPLIES_LDO, 00307 * PWR_SMPS_2V5_SUPPLIES_LDO, PWR_SMPS_1V8_SUPPLIES_EXT_AND_LDO, 00308 * PWR_SMPS_2V5_SUPPLIES_EXT_AND_LDO, PWR_SMPS_1V8_SUPPLIES_EXT and 00309 * PWR_SMPS_2V5_SUPPLIES_EXT are used only for lines that supports SMPS 00310 * regulator. 00311 * @retval HAL status. 00312 */ 00313 HAL_StatusTypeDef HAL_PWREx_ConfigSupply (uint32_t SupplySource) 00314 { 00315 uint32_t tickstart; 00316 00317 /* Check the parameters */ 00318 assert_param (IS_PWR_SUPPLY (SupplySource)); 00319 00320 /* Check if supply source was configured */ 00321 #if defined (PWR_FLAG_SCUEN) 00322 if (__HAL_PWR_GET_FLAG (PWR_FLAG_SCUEN) == 0U) 00323 #else 00324 if ((PWR->CR3 & (PWR_CR3_SMPSEN | PWR_CR3_LDOEN | PWR_CR3_BYPASS)) != (PWR_CR3_SMPSEN | PWR_CR3_LDOEN)) 00325 #endif /* defined (PWR_FLAG_SCUEN) */ 00326 { 00327 /* Check supply configuration */ 00328 if ((PWR->CR3 & PWR_SUPPLY_CONFIG_MASK) != SupplySource) 00329 { 00330 /* Supply configuration update locked, can't apply a new supply config */ 00331 return HAL_ERROR; 00332 } 00333 else 00334 { 00335 /* Supply configuration update locked, but new supply configuration 00336 matches with old supply configuration : nothing to do 00337 */ 00338 return HAL_OK; 00339 } 00340 } 00341 00342 /* Set the power supply configuration */ 00343 MODIFY_REG (PWR->CR3, PWR_SUPPLY_CONFIG_MASK, SupplySource); 00344 00345 /* Get tick */ 00346 tickstart = HAL_GetTick (); 00347 00348 /* Wait till voltage level flag is set */ 00349 while (__HAL_PWR_GET_FLAG (PWR_FLAG_ACTVOSRDY) == 0U) 00350 { 00351 if ((HAL_GetTick () - tickstart) > PWR_FLAG_SETTING_DELAY) 00352 { 00353 return HAL_ERROR; 00354 } 00355 } 00356 00357 #if defined (SMPS) 00358 /* When the SMPS supplies external circuits verify that SDEXTRDY flag is set */ 00359 if ((SupplySource == PWR_SMPS_1V8_SUPPLIES_EXT_AND_LDO) || 00360 (SupplySource == PWR_SMPS_2V5_SUPPLIES_EXT_AND_LDO) || 00361 (SupplySource == PWR_SMPS_1V8_SUPPLIES_EXT) || 00362 (SupplySource == PWR_SMPS_2V5_SUPPLIES_EXT)) 00363 { 00364 /* Get the current tick number */ 00365 tickstart = HAL_GetTick (); 00366 00367 /* Wait till SMPS external supply ready flag is set */ 00368 while (__HAL_PWR_GET_FLAG (PWR_FLAG_SMPSEXTRDY) == 0U) 00369 { 00370 if ((HAL_GetTick () - tickstart) > PWR_FLAG_SETTING_DELAY) 00371 { 00372 return HAL_ERROR; 00373 } 00374 } 00375 } 00376 #endif /* defined (SMPS) */ 00377 00378 return HAL_OK; 00379 } 00380 00381 /** 00382 * @brief Get the power supply configuration. 00383 * @retval The supply configuration. 00384 */ 00385 uint32_t HAL_PWREx_GetSupplyConfig (void) 00386 { 00387 return (PWR->CR3 & PWR_SUPPLY_CONFIG_MASK); 00388 } 00389 00390 /** 00391 * @brief Configure the main internal regulator output voltage. 00392 * @param VoltageScaling : Specifies the regulator output voltage to achieve 00393 * a tradeoff between performance and power 00394 * consumption. 00395 * This parameter can be one of the following values : 00396 * @arg PWR_REGULATOR_VOLTAGE_SCALE0 : Regulator voltage output 00397 * Scale 0 mode. 00398 * @arg PWR_REGULATOR_VOLTAGE_SCALE1 : Regulator voltage output 00399 * range 1 mode. 00400 * @arg PWR_REGULATOR_VOLTAGE_SCALE2 : Regulator voltage output 00401 * range 2 mode. 00402 * @arg PWR_REGULATOR_VOLTAGE_SCALE3 : Regulator voltage output 00403 * range 3 mode. 00404 * @note For STM32H74x and STM32H75x lines, configuring Voltage Scale 0 is 00405 * only possible when Vcore is supplied from LDO (Low DropOut). The 00406 * SYSCFG Clock must be enabled through __HAL_RCC_SYSCFG_CLK_ENABLE() 00407 * macro before configuring Voltage Scale 0. 00408 * To enter low power mode , and if current regulator voltage is 00409 * Voltage Scale 0 then first switch to Voltage Scale 1 before entering 00410 * low power mode. 00411 * @retval HAL Status 00412 */ 00413 HAL_StatusTypeDef HAL_PWREx_ControlVoltageScaling (uint32_t VoltageScaling) 00414 { 00415 uint32_t tickstart; 00416 00417 /* Check the parameters */ 00418 assert_param (IS_PWR_REGULATOR_VOLTAGE (VoltageScaling)); 00419 00420 /* Get the voltage scaling */ 00421 if ((PWR->CSR1 & PWR_CSR1_ACTVOS) == VoltageScaling) 00422 { 00423 /* Old and new voltage scaling configuration match : nothing to do */ 00424 return HAL_OK; 00425 } 00426 00427 #if defined (PWR_SRDCR_VOS) 00428 /* Set the voltage range */ 00429 MODIFY_REG (PWR->SRDCR, PWR_SRDCR_VOS, VoltageScaling); 00430 #else 00431 #if defined(SYSCFG_PWRCR_ODEN) /* STM32H74xxx and STM32H75xxx lines */ 00432 if (VoltageScaling == PWR_REGULATOR_VOLTAGE_SCALE0) 00433 { 00434 if ((PWR->CR3 & PWR_CR3_LDOEN) == PWR_CR3_LDOEN) 00435 { 00436 /* Set the voltage range */ 00437 MODIFY_REG (PWR->D3CR, PWR_D3CR_VOS, PWR_REGULATOR_VOLTAGE_SCALE1); 00438 00439 /* Get tick */ 00440 tickstart = HAL_GetTick (); 00441 00442 /* Wait till voltage level flag is set */ 00443 while (__HAL_PWR_GET_FLAG (PWR_FLAG_ACTVOSRDY) == 0U) 00444 { 00445 if ((HAL_GetTick () - tickstart) > PWR_FLAG_SETTING_DELAY) 00446 { 00447 return HAL_ERROR; 00448 } 00449 } 00450 00451 /* Enable the PWR overdrive */ 00452 SET_BIT (SYSCFG->PWRCR, SYSCFG_PWRCR_ODEN); 00453 } 00454 else 00455 { 00456 /* The voltage scale 0 is only possible when LDO regulator is enabled */ 00457 return HAL_ERROR; 00458 } 00459 } 00460 else 00461 { 00462 if ((PWR->CSR1 & PWR_CSR1_ACTVOS) == PWR_REGULATOR_VOLTAGE_SCALE1) 00463 { 00464 if ((SYSCFG->PWRCR & SYSCFG_PWRCR_ODEN) != 0U) 00465 { 00466 /* Disable the PWR overdrive */ 00467 CLEAR_BIT(SYSCFG->PWRCR, SYSCFG_PWRCR_ODEN); 00468 00469 /* Get tick */ 00470 tickstart = HAL_GetTick (); 00471 00472 /* Wait till voltage level flag is set */ 00473 while (__HAL_PWR_GET_FLAG (PWR_FLAG_ACTVOSRDY) == 0U) 00474 { 00475 if ((HAL_GetTick () - tickstart) > PWR_FLAG_SETTING_DELAY) 00476 { 00477 return HAL_ERROR; 00478 } 00479 } 00480 } 00481 } 00482 00483 /* Set the voltage range */ 00484 MODIFY_REG (PWR->D3CR, PWR_D3CR_VOS, VoltageScaling); 00485 } 00486 #else /* STM32H72xxx and STM32H73xxx lines */ 00487 /* Set the voltage range */ 00488 MODIFY_REG(PWR->D3CR, PWR_D3CR_VOS, VoltageScaling); 00489 #endif /* defined (SYSCFG_PWRCR_ODEN) */ 00490 #endif /* defined (PWR_SRDCR_VOS) */ 00491 00492 /* Get tick */ 00493 tickstart = HAL_GetTick (); 00494 00495 /* Wait till voltage level flag is set */ 00496 while (__HAL_PWR_GET_FLAG (PWR_FLAG_ACTVOSRDY) == 0U) 00497 { 00498 if ((HAL_GetTick() - tickstart) > PWR_FLAG_SETTING_DELAY) 00499 { 00500 return HAL_ERROR; 00501 } 00502 } 00503 00504 return HAL_OK; 00505 } 00506 00507 /** 00508 * @brief Get the main internal regulator output voltage. Reflecting the last 00509 * VOS value applied to the PMU. 00510 * @retval The current applied VOS selection. 00511 */ 00512 uint32_t HAL_PWREx_GetVoltageRange (void) 00513 { 00514 /* Get the active voltage scaling */ 00515 return (PWR->CSR1 & PWR_CSR1_ACTVOS); 00516 } 00517 00518 /** 00519 * @brief Configure the main internal regulator output voltage in STOP mode. 00520 * @param VoltageScaling : Specifies the regulator output voltage when the 00521 * system enters Stop mode to achieve a tradeoff between performance 00522 * and power consumption. 00523 * This parameter can be one of the following values: 00524 * @arg PWR_REGULATOR_SVOS_SCALE3 : Regulator voltage output range 00525 * 3 mode. 00526 * @arg PWR_REGULATOR_SVOS_SCALE4 : Regulator voltage output range 00527 * 4 mode. 00528 * @arg PWR_REGULATOR_SVOS_SCALE5 : Regulator voltage output range 00529 * 5 mode. 00530 * @note The Stop mode voltage scaling for SVOS4 and SVOS5 sets the voltage 00531 * regulator in Low-power (LP) mode to further reduce power consumption. 00532 * When preselecting SVOS3, the use of the voltage regulator low-power 00533 * mode (LP) can be selected by LPDS register bit. 00534 * @note The selected SVOS4 and SVOS5 levels add an additional startup delay 00535 * when exiting from system Stop mode. 00536 * @retval HAL Status. 00537 */ 00538 HAL_StatusTypeDef HAL_PWREx_ControlStopModeVoltageScaling (uint32_t VoltageScaling) 00539 { 00540 /* Check the parameters */ 00541 assert_param (IS_PWR_STOP_MODE_REGULATOR_VOLTAGE (VoltageScaling)); 00542 00543 /* Return the stop mode voltage range */ 00544 MODIFY_REG (PWR->CR1, PWR_CR1_SVOS, VoltageScaling); 00545 00546 return HAL_OK; 00547 } 00548 00549 /** 00550 * @brief Get the main internal regulator output voltage in STOP mode. 00551 * @retval The actual applied VOS selection. 00552 */ 00553 uint32_t HAL_PWREx_GetStopModeVoltageRange (void) 00554 { 00555 /* Return the stop voltage scaling */ 00556 return (PWR->CR1 & PWR_CR1_SVOS); 00557 } 00558 /** 00559 * @} 00560 */ 00561 00562 /** @defgroup PWREx_Exported_Functions_Group2 Low Power Control Functions 00563 * @brief Low power control functions 00564 * 00565 @verbatim 00566 =============================================================================== 00567 ##### Low power control functions ##### 00568 =============================================================================== 00569 00570 *** Domains Low Power modes configuration *** 00571 ============================================= 00572 [..] 00573 This section provides the extended low power mode control APIs. 00574 The system presents 3 principles domains (D1, D2 and D3) that can be 00575 operated in low-power modes (DSTOP or DSTANDBY mode): 00576 00577 (+) DSTOP mode to enters a domain to STOP mode: 00578 (++) D1 domain and/or D2 domain enters DSTOP mode only when the CPU 00579 subsystem is in CSTOP mode and has allocated peripheral in the 00580 domain. 00581 In DSTOP mode the domain bus matrix clock is stopped. 00582 (++) The system enters STOP mode using one of the following scenarios: 00583 (+++) D1 domain enters DSTANDBY mode (powered off) and D2, D3 domains 00584 enter DSTOP mode. 00585 (+++) D2 domain enters DSTANDBY mode (powered off) and D1, D3 domains 00586 enter DSTOP mode. 00587 (+++) D3 domain enters DSTANDBY mode (powered off) and D1, D2 domains 00588 enter DSTOP mode. 00589 (+++) D1 and D2 domains enter DSTANDBY mode (powered off) and D3 domain 00590 enters DSTOP mode. 00591 (+++) D1 and D3 domains enter DSTANDBY mode (powered off) and D2 domain 00592 enters DSTOP mode. 00593 (+++) D2 and D3 domains enter DSTANDBY mode (powered off) and D1 domain 00594 enters DSTOP mode. 00595 (+++) D1, D2 and D3 domains enter DSTOP mode. 00596 (++) When the system enters STOP mode, the clocks are stopped and the 00597 regulator is running in main or low power mode. 00598 (++) D3 domain can be kept in Run mode regardless of the CPU status when 00599 enter STOP mode by using HAL_PWREx_ConfigD3Domain(D3State) function. 00600 00601 (+) DSTANDBY mode to enters a domain to STANDBY mode: 00602 (++) The DSTANDBY mode is entered when the PDDS_Dn bit in PWR CPU control 00603 register (PWR_CPUCR) for the Dn domain selects Standby mode. 00604 (++) The system enters STANDBY mode only when D1, D2 and D3 domains enter 00605 DSTANDBY mode. Consequently the VCORE supply regulator is powered 00606 off. 00607 00608 *** DSTOP mode *** 00609 ================== 00610 [..] 00611 In DStop mode the domain bus matrix clock is stopped. 00612 The Flash memory can enter low-power Stop mode when it is enabled through 00613 FLPS in PWR_CR1 register. This allows a trade-off between domain DStop 00614 restart time and low power consumption. 00615 [..] 00616 In DStop mode domain peripherals using the LSI or LSE clock and 00617 peripherals having a kernel clock request are still able to operate. 00618 [..] 00619 Before entering DSTOP mode it is recommended to call SCB_CleanDCache 00620 function in order to clean the D-Cache and guarantee the data integrity 00621 for the SRAM memories. 00622 00623 (+) Entry: 00624 The DSTOP mode is entered using the HAL_PWREx_EnterSTOPMode(Regulator, 00625 STOPEntry, Domain) function with: 00626 (++) Regulator: 00627 (+++) PWR_MAINREGULATOR_ON : Main regulator ON. 00628 (+++) PWR_LOWPOWERREGULATOR_ON : Low Power regulator ON. 00629 (++) STOPEntry: 00630 (+++) PWR_STOPENTRY_WFI : enter STOP mode with WFI instruction 00631 (+++) PWR_STOPENTRY_WFE : enter STOP mode with WFE instruction 00632 (++) Domain: 00633 (+++) PWR_D1_DOMAIN : Enters D1/CD domain to DSTOP mode. 00634 (+++) PWR_D2_DOMAIN : Enters D2 domain to DSTOP mode. 00635 (+++) PWR_D3_DOMAIN : Enters D3/SRD domain to DSTOP mode. 00636 00637 (+) Exit: 00638 Any EXTI Line (Internal or External) configured in Interrupt/Event mode. 00639 00640 *** DSTANDBY mode *** 00641 ===================== 00642 [..] 00643 In DStandby mode: 00644 (+) The domain bus matrix clock is stopped. 00645 (+) The domain is powered down and the domain RAM and register contents 00646 are lost. 00647 [..] 00648 Before entering DSTANDBY mode it is recommended to call SCB_CleanDCache 00649 function in order to clean the D-Cache and guarantee the data integrity 00650 for the SRAM memories. 00651 00652 (+) Entry: 00653 The DSTANDBY mode is entered using the HAL_PWREx_EnterSTANDBYMode 00654 (Domain) function with: 00655 (++) Domain: 00656 (+++) PWR_D1_DOMAIN : Enters D1/CD domain to DSTANDBY mode. 00657 (+++) PWR_D2_DOMAIN : Enters D2 domain to DSTANDBY mode. 00658 (+++) PWR_D3_DOMAIN : Enters D3/SRD domain to DSTANDBY mode. 00659 00660 (+) Exit: 00661 WKUP pin rising or falling edge, RTC alarm (Alarm A and Alarm B), RTC 00662 wakeup, tamper event, time stamp event, external reset in NRST pin, 00663 IWDG reset. 00664 00665 *** Keep D3/SRD in RUN mode *** 00666 =============================== 00667 [..] 00668 D3/SRD domain can be kept in Run mode regardless of the CPU status when 00669 entering STOP mode by using HAL_PWREx_ConfigD3Domain(D3State) function 00670 with : 00671 (+) D3State: 00672 (++) PWR_D3_DOMAIN_STOP : D3/SDR domain follows the CPU sub-system 00673 mode. 00674 (++) PWR_D3_DOMAIN_RUN : D3/SRD domain remains in Run mode regardless 00675 of CPU subsystem mode. 00676 00677 *** FLASH Power Down configuration **** 00678 ======================================= 00679 [..] 00680 By setting the FLPS bit in the PWR_CR1 register using the 00681 HAL_PWREx_EnableFlashPowerDown() function, the Flash memory also enters 00682 power down mode when the device enters STOP mode. When the Flash memory is 00683 in power down mode, an additional startup delay is incurred when waking up 00684 from STOP mode. 00685 00686 *** Wakeup Pins configuration **** 00687 =================================== 00688 [..] 00689 Wakeup pins allow the system to exit from Standby mode. The configuration 00690 of wakeup pins is done with the HAL_PWREx_EnableWakeUpPin(sPinParams) 00691 function with: 00692 (+) sPinParams: structure to enable and configure a wakeup pin: 00693 (++) WakeUpPin: Wakeup pin to be enabled. 00694 (++) PinPolarity: Wakeup pin polarity (rising or falling edge). 00695 (++) PinPull: Wakeup pin pull (no pull, pull-up or pull-down). 00696 [..] 00697 The wakeup pins are internally connected to the EXTI lines [55-60] to 00698 generate an interrupt if enabled. The EXTI lines configuration is done by 00699 the HAL_EXTI_Dx_EventInputConfig() functions defined in the stm32h7xxhal.c 00700 file. 00701 [..] 00702 When a wakeup pin event is received the HAL_PWREx_WAKEUP_PIN_IRQHandler is 00703 called and the appropriate flag is set in the PWR_WKUPFR register. Then in 00704 the HAL_PWREx_WAKEUP_PIN_IRQHandler function the wakeup pin flag will be 00705 cleared and the appropriate user callback will be called. The user can add 00706 his own code by customization of function pointer HAL_PWREx_WKUPx_Callback. 00707 00708 @endverbatim 00709 * @{ 00710 */ 00711 00712 #if defined (PWR_CPUCR_RETDS_CD) 00713 /** 00714 * @brief Enter the system to STOP mode with main domain in DSTOP2. 00715 * @note In STOP mode, the domain bus matrix clock is stalled. 00716 * @note In STOP mode, memories and registers are maintained and peripherals 00717 * in CPU domain are no longer operational. 00718 * @note All clocks in the VCORE domain are stopped, the PLL, the HSI and the 00719 * HSE oscillators are disabled. Only Peripherals that have wakeup 00720 * capability can switch on the HSI to receive a frame, and switch off 00721 * the HSI after receiving the frame if it is not a wakeup frame. In 00722 * this case the HSI clock is propagated only to the peripheral 00723 * requesting it. 00724 * @note When exiting STOP mode by issuing an interrupt or a wakeup event, 00725 * the HSI RC oscillator is selected as system clock if STOPWUCK bit in 00726 * RCC_CFGR register is set. 00727 * @param Regulator : Specifies the regulator state in STOP mode. 00728 * This parameter can be one of the following values: 00729 * @arg PWR_MAINREGULATOR_ON : STOP mode with regulator ON. 00730 * @arg PWR_LOWPOWERREGULATOR_ON : STOP mode with low power 00731 * regulator ON. 00732 * @param STOPEntry : Specifies if STOP mode in entered with WFI or WFE 00733 * intrinsic instruction. 00734 * This parameter can be one of the following values: 00735 * @arg PWR_STOPENTRY_WFI : Enter STOP mode with WFI instruction. 00736 * @arg PWR_STOPENTRY_WFE : Enter STOP mode with WFE instruction. 00737 * @retval None. 00738 */ 00739 void HAL_PWREx_EnterSTOP2Mode (uint32_t Regulator, uint8_t STOPEntry) 00740 { 00741 /* Check the parameters */ 00742 assert_param (IS_PWR_REGULATOR (Regulator)); 00743 assert_param (IS_PWR_STOP_ENTRY (STOPEntry)); 00744 00745 /* Select the regulator state in Stop mode */ 00746 MODIFY_REG (PWR->CR1, PWR_CR1_LPDS, Regulator); 00747 00748 /* Go to DStop2 mode (deep retention) when CPU domain enters Deepsleep */ 00749 SET_BIT (PWR->CPUCR, PWR_CPUCR_RETDS_CD); 00750 00751 /* Keep DSTOP mode when SmartRun domain enters Deepsleep */ 00752 CLEAR_BIT (PWR->CPUCR, PWR_CPUCR_PDDS_SRD); 00753 00754 /* Set SLEEPDEEP bit of Cortex System Control Register */ 00755 SET_BIT (SCB->SCR, SCB_SCR_SLEEPDEEP_Msk); 00756 00757 /* Ensure that all instructions are done before entering STOP mode */ 00758 __ISB (); 00759 __DSB (); 00760 00761 /* Select Stop mode entry */ 00762 if (STOPEntry == PWR_STOPENTRY_WFI) 00763 { 00764 /* Request Wait For Interrupt */ 00765 __WFI (); 00766 } 00767 else 00768 { 00769 /* Request Wait For Event */ 00770 __WFE (); 00771 } 00772 00773 /* Clear SLEEPDEEP bit of Cortex-Mx in the System Control Register */ 00774 CLEAR_BIT (SCB->SCR, SCB_SCR_SLEEPDEEP_Msk); 00775 } 00776 #endif /* defined (PWR_CPUCR_RETDS_CD) */ 00777 00778 /** 00779 * @brief Enter a Domain to DSTOP mode. 00780 * @note This API gives flexibility to manage independently each domain STOP 00781 * mode. For dual core lines, this API should be executed with the 00782 * corresponding Cortex-Mx to enter domain to DSTOP mode. When it is 00783 * executed by all available Cortex-Mx, the system enter to STOP mode. 00784 * For single core lines, calling this API with domain parameter set to 00785 * PWR_D1_DOMAIN (D1/CD), the whole system will enter in STOP mode 00786 * independently of PWR_CPUCR_PDDS_Dx bits values if RUN_D3 bit in the 00787 * CPUCR_RUN_D3 is cleared. 00788 * @note In DStop mode the domain bus matrix clock is stopped. 00789 * @note The system D3/SRD domain enter Stop mode only when the CPU subsystem 00790 * is in CStop mode, the EXTI wakeup sources are inactive and at least 00791 * one PDDS_Dn bit in PWR CPU control register (PWR_CPUCR) for 00792 * any domain request Stop. 00793 * @note Before entering DSTOP mode it is recommended to call SCB_CleanDCache 00794 * function in order to clean the D-Cache and guarantee the data 00795 * integrity for the SRAM memories. 00796 * @note In System Stop mode, the domain peripherals that use the LSI or LSE 00797 * clock, and the peripherals that have a kernel clock request to 00798 * select HSI or CSI as source, are still able to operate. 00799 * @param Regulator : Specifies the regulator state in STOP mode. 00800 * This parameter can be one of the following values: 00801 * @arg PWR_MAINREGULATOR_ON : STOP mode with regulator ON. 00802 * @arg PWR_LOWPOWERREGULATOR_ON : STOP mode with low power 00803 * regulator ON. 00804 * @param STOPEntry : Specifies if STOP mode in entered with WFI or WFE 00805 * intrinsic instruction. 00806 * This parameter can be one of the following values: 00807 * @arg PWR_STOPENTRY_WFI : Enter STOP mode with WFI instruction. 00808 * @arg PWR_STOPENTRY_WFE : Enter STOP mode with WFE instruction. 00809 * @param Domain : Specifies the Domain to enter in DSTOP mode. 00810 * This parameter can be one of the following values: 00811 * @arg PWR_D1_DOMAIN : Enter D1/CD Domain to DSTOP mode. 00812 * @arg PWR_D2_DOMAIN : Enter D2 Domain to DSTOP mode. 00813 * @arg PWR_D3_DOMAIN : Enter D3/SRD Domain to DSTOP mode. 00814 * @retval None. 00815 */ 00816 void HAL_PWREx_EnterSTOPMode (uint32_t Regulator, uint8_t STOPEntry, uint32_t Domain) 00817 { 00818 /* Check the parameters */ 00819 assert_param (IS_PWR_REGULATOR (Regulator)); 00820 assert_param (IS_PWR_STOP_ENTRY (STOPEntry)); 00821 assert_param (IS_PWR_DOMAIN (Domain)); 00822 00823 /* Select the regulator state in Stop mode */ 00824 MODIFY_REG (PWR->CR1, PWR_CR1_LPDS, Regulator); 00825 00826 /* Select the domain Power Down DeepSleep */ 00827 if (Domain == PWR_D1_DOMAIN) 00828 { 00829 #if defined (DUAL_CORE) 00830 /* Check current core */ 00831 if (HAL_GetCurrentCPUID () != CM7_CPUID) 00832 { 00833 /* 00834 When the domain selected and the cortex-mx don't match, entering stop 00835 mode will not be performed 00836 */ 00837 return; 00838 } 00839 #endif /* defined (DUAL_CORE) */ 00840 00841 /* Keep DSTOP mode when D1/CD domain enters Deepsleep */ 00842 CLEAR_BIT (PWR->CPUCR, PWR_CPUCR_PDDS_D1); 00843 00844 /* Set SLEEPDEEP bit of Cortex System Control Register */ 00845 SET_BIT (SCB->SCR, SCB_SCR_SLEEPDEEP_Msk); 00846 00847 /* Ensure that all instructions are done before entering STOP mode */ 00848 __DSB (); 00849 __ISB (); 00850 00851 /* Select Stop mode entry */ 00852 if (STOPEntry == PWR_STOPENTRY_WFI) 00853 { 00854 /* Request Wait For Interrupt */ 00855 __WFI (); 00856 } 00857 else 00858 { 00859 /* Request Wait For Event */ 00860 __WFE (); 00861 } 00862 00863 /* Clear SLEEPDEEP bit of Cortex-Mx in the System Control Register */ 00864 CLEAR_BIT (SCB->SCR, SCB_SCR_SLEEPDEEP_Msk); 00865 } 00866 #if defined (PWR_CPUCR_PDDS_D2) 00867 else if (Domain == PWR_D2_DOMAIN) 00868 { 00869 #if defined (DUAL_CORE) 00870 /* Check current core */ 00871 if (HAL_GetCurrentCPUID () != CM4_CPUID) 00872 { 00873 /* 00874 When the domain selected and the cortex-mx don't match, entering stop 00875 mode will not be performed 00876 */ 00877 return; 00878 } 00879 00880 /* Keep DSTOP mode when D2 domain enters Deepsleep */ 00881 CLEAR_BIT (PWR->CPU2CR, PWR_CPU2CR_PDDS_D2); 00882 00883 /* Set SLEEPDEEP bit of Cortex System Control Register */ 00884 SET_BIT (SCB->SCR, SCB_SCR_SLEEPDEEP_Msk); 00885 00886 /* Ensure that all instructions are done before entering STOP mode */ 00887 __DSB (); 00888 __ISB (); 00889 00890 /* Select Stop mode entry */ 00891 if (STOPEntry == PWR_STOPENTRY_WFI) 00892 { 00893 /* Request Wait For Interrupt */ 00894 __WFI (); 00895 } 00896 else 00897 { 00898 /* Request Wait For Event */ 00899 __WFE (); 00900 } 00901 00902 /* Clear SLEEPDEEP bit of Cortex-Mx in the System Control Register */ 00903 CLEAR_BIT (SCB->SCR, SCB_SCR_SLEEPDEEP_Msk); 00904 #else 00905 /* Keep DSTOP mode when D2 domain enters Deepsleep */ 00906 CLEAR_BIT (PWR->CPUCR, PWR_CPUCR_PDDS_D2); 00907 #endif /* defined (DUAL_CORE) */ 00908 } 00909 #endif /* defined (PWR_CPUCR_PDDS_D2) */ 00910 else 00911 { 00912 #if defined (DUAL_CORE) 00913 /* Check current core */ 00914 if (HAL_GetCurrentCPUID () == CM7_CPUID) 00915 { 00916 /* Keep DSTOP mode when D3 domain enters Deepsleep */ 00917 CLEAR_BIT (PWR->CPUCR, PWR_CPUCR_PDDS_D3); 00918 } 00919 else 00920 { 00921 /* Keep DSTOP mode when D3 domain enters Deepsleep */ 00922 CLEAR_BIT (PWR->CPU2CR, PWR_CPU2CR_PDDS_D3); 00923 } 00924 #else 00925 /* Keep DSTOP mode when D3/SRD domain enters Deepsleep */ 00926 CLEAR_BIT (PWR->CPUCR, PWR_CPUCR_PDDS_D3); 00927 #endif /* defined (DUAL_CORE) */ 00928 } 00929 } 00930 00931 /** 00932 * @brief Clear pending event. 00933 * @note This API clears the pending event in order to enter a given CPU 00934 * to CSLEEP or CSTOP. It should be called just before APIs performing 00935 * enter low power mode using Wait For Event request. 00936 * @note Cortex-M7 must be in CRUN mode when calling this API by Cortex-M4. 00937 * @retval None. 00938 */ 00939 void HAL_PWREx_ClearPendingEvent (void) 00940 { 00941 #if defined (DUAL_CORE) 00942 /* Check the current Core */ 00943 if (HAL_GetCurrentCPUID () == CM7_CPUID) 00944 { 00945 __WFE (); 00946 } 00947 else 00948 { 00949 __SEV (); 00950 __WFE (); 00951 } 00952 #else 00953 __WFE (); 00954 #endif /* defined (DUAL_CORE) */ 00955 } 00956 00957 /** 00958 * @brief Enter a Domain to DSTANDBY mode. 00959 * @note This API gives flexibility to manage independently each domain 00960 * STANDBY mode. For dual core lines, this API should be executed with 00961 * the corresponding Cortex-Mx to enter domain to DSTANDBY mode. When 00962 * it is executed by all available Cortex-Mx, the system enter STANDBY 00963 * mode. 00964 * For single core lines, calling this API with D1/SRD the selected 00965 * domain will enter the whole system in STOP if PWR_CPUCR_PDDS_D3 = 0 00966 * and enter the whole system in STANDBY if PWR_CPUCR_PDDS_D3 = 1. 00967 * @note The DStandby mode is entered when all PDDS_Dn bits in PWR_CPUCR for 00968 * the Dn domain select Standby mode. When the system enters Standby 00969 * mode, the voltage regulator is disabled. 00970 * @note When D2 or D3 domain is in DStandby mode and the CPU sets the 00971 * domain PDDS_Dn bit to select Stop mode, the domain remains in 00972 * DStandby mode. The domain will only exit DStandby when the CPU 00973 * allocates a peripheral in the domain. 00974 * @note The system D3/SRD domain enters Standby mode only when the D1 and D2 00975 * domain are in DStandby. 00976 * @note Before entering DSTANDBY mode it is recommended to call 00977 * SCB_CleanDCache function in order to clean the D-Cache and guarantee 00978 * the data integrity for the SRAM memories. 00979 * @param Domain : Specifies the Domain to enter to STANDBY mode. 00980 * This parameter can be one of the following values: 00981 * @arg PWR_D1_DOMAIN: Enter D1/CD Domain to DSTANDBY mode. 00982 * @arg PWR_D2_DOMAIN: Enter D2 Domain to DSTANDBY mode. 00983 * @arg PWR_D3_DOMAIN: Enter D3/SRD Domain to DSTANDBY mode. 00984 * @retval None 00985 */ 00986 void HAL_PWREx_EnterSTANDBYMode (uint32_t Domain) 00987 { 00988 /* Check the parameters */ 00989 assert_param (IS_PWR_DOMAIN (Domain)); 00990 00991 /* Select the domain Power Down DeepSleep */ 00992 if (Domain == PWR_D1_DOMAIN) 00993 { 00994 #if defined (DUAL_CORE) 00995 /* Check current core */ 00996 if (HAL_GetCurrentCPUID () != CM7_CPUID) 00997 { 00998 /* 00999 When the domain selected and the cortex-mx don't match, entering 01000 standby mode will not be performed 01001 */ 01002 return; 01003 } 01004 #endif /* defined (DUAL_CORE) */ 01005 01006 /* Allow DSTANDBY mode when D1/CD domain enters Deepsleep */ 01007 SET_BIT (PWR-> CPUCR, PWR_CPUCR_PDDS_D1); 01008 01009 #if defined (DUAL_CORE) 01010 /* Allow DSTANDBY mode when D1/CD domain enters Deepsleep */ 01011 SET_BIT (PWR-> CPU2CR, PWR_CPU2CR_PDDS_D1); 01012 #endif /*DUAL_CORE*/ 01013 01014 /* Set SLEEPDEEP bit of Cortex System Control Register */ 01015 SET_BIT (SCB->SCR, SCB_SCR_SLEEPDEEP_Msk); 01016 01017 /* This option is used to ensure that store operations are completed */ 01018 #if defined (__CC_ARM) 01019 __force_stores (); 01020 #endif /* defined (__CC_ARM) */ 01021 01022 /* Request Wait For Interrupt */ 01023 __WFI (); 01024 } 01025 #if defined (PWR_CPUCR_PDDS_D2) 01026 else if (Domain == PWR_D2_DOMAIN) 01027 { 01028 /* Allow DSTANDBY mode when D2 domain enters Deepsleep */ 01029 SET_BIT (PWR-> CPUCR, PWR_CPUCR_PDDS_D2); 01030 01031 #if defined (DUAL_CORE) 01032 /* Check current core */ 01033 if (HAL_GetCurrentCPUID () != CM4_CPUID) 01034 { 01035 /* 01036 When the domain selected and the cortex-mx don't match, entering 01037 standby mode will not be performed 01038 */ 01039 return; 01040 } 01041 01042 /* Allow DSTANDBY mode when D2 domain enters Deepsleep */ 01043 SET_BIT (PWR-> CPU2CR, PWR_CPU2CR_PDDS_D2); 01044 01045 /* Set SLEEPDEEP bit of Cortex System Control Register */ 01046 SET_BIT (SCB->SCR, SCB_SCR_SLEEPDEEP_Msk); 01047 01048 /* This option is used to ensure that store operations are completed */ 01049 #if defined (__CC_ARM) 01050 __force_stores (); 01051 #endif /* defined (__CC_ARM) */ 01052 01053 /* Request Wait For Interrupt */ 01054 __WFI (); 01055 #endif /* defined (DUAL_CORE) */ 01056 } 01057 #endif /* defined (PWR_CPUCR_PDDS_D2) */ 01058 else 01059 { 01060 /* Allow DSTANDBY mode when D3/SRD domain enters Deepsleep */ 01061 SET_BIT (PWR->CPUCR, PWR_CPUCR_PDDS_D3); 01062 01063 #if defined (DUAL_CORE) 01064 /* Allow DSTANDBY mode when D3/SRD domain enters Deepsleep */ 01065 SET_BIT (PWR->CPU2CR, PWR_CPU2CR_PDDS_D3); 01066 #endif /* defined (DUAL_CORE) */ 01067 } 01068 } 01069 01070 /** 01071 * @brief Configure the D3/SRD Domain state when the System in low power mode. 01072 * @param D3State : Specifies the D3/SRD state. 01073 * This parameter can be one of the following values : 01074 * @arg PWR_D3_DOMAIN_STOP : D3/SRD domain will follow the most deep 01075 * CPU sub-system low power mode. 01076 * @arg PWR_D3_DOMAIN_RUN : D3/SRD domain will stay in RUN mode 01077 * regardless of the CPU sub-system low 01078 * power mode. 01079 * @retval None 01080 */ 01081 void HAL_PWREx_ConfigD3Domain (uint32_t D3State) 01082 { 01083 /* Check the parameter */ 01084 assert_param (IS_D3_STATE (D3State)); 01085 01086 /* Keep D3/SRD in run mode */ 01087 MODIFY_REG (PWR->CPUCR, PWR_CPUCR_RUN_D3, D3State); 01088 } 01089 01090 #if defined (DUAL_CORE) 01091 /** 01092 * @brief Clear HOLD2F, HOLD1F, STOPF, SBF, SBF_D1, and SBF_D2 flags for a 01093 * given domain. 01094 * @param DomainFlags : Specifies the Domain flags to be cleared. 01095 * This parameter can be one of the following values: 01096 * @arg PWR_D1_DOMAIN_FLAGS : Clear D1 Domain flags. 01097 * @arg PWR_D2_DOMAIN_FLAGS : Clear D2 Domain flags. 01098 * @arg PWR_ALL_DOMAIN_FLAGS : Clear D1 and D2 Domain flags. 01099 * @retval None. 01100 */ 01101 void HAL_PWREx_ClearDomainFlags (uint32_t DomainFlags) 01102 { 01103 /* Check the parameter */ 01104 assert_param (IS_PWR_DOMAIN_FLAG (DomainFlags)); 01105 01106 /* D1 CPU flags */ 01107 if (DomainFlags == PWR_D1_DOMAIN_FLAGS) 01108 { 01109 /* Clear D1 domain flags (HOLD2F, STOPF, SBF, SBF_D1, and SBF_D2) */ 01110 SET_BIT (PWR->CPUCR, PWR_CPUCR_CSSF); 01111 } 01112 /* D2 CPU flags */ 01113 else if (DomainFlags == PWR_D2_DOMAIN_FLAGS) 01114 { 01115 /* Clear D2 domain flags (HOLD1F, STOPF, SBF, SBF_D1, and SBF_D2) */ 01116 SET_BIT (PWR->CPU2CR, PWR_CPU2CR_CSSF); 01117 } 01118 else 01119 { 01120 /* Clear D1 domain flags (HOLD2F, STOPF, SBF, SBF_D1, and SBF_D2) */ 01121 SET_BIT (PWR->CPUCR, PWR_CPUCR_CSSF); 01122 /* Clear D2 domain flags (HOLD1F, STOPF, SBF, SBF_D1, and SBF_D2) */ 01123 SET_BIT (PWR->CPU2CR, PWR_CPU2CR_CSSF); 01124 } 01125 } 01126 01127 /** 01128 * @brief Hold the CPU and their domain peripherals when exiting STOP mode. 01129 * @param CPU : Specifies the core to be held. 01130 * This parameter can be one of the following values: 01131 * @arg PWR_CORE_CPU1: Hold CPU1 and set CPU2 as master. 01132 * @arg PWR_CORE_CPU2: Hold CPU2 and set CPU1 as master. 01133 * @retval HAL status 01134 */ 01135 HAL_StatusTypeDef HAL_PWREx_HoldCore (uint32_t CPU) 01136 { 01137 HAL_StatusTypeDef status = HAL_OK; 01138 01139 /* Check the parameters */ 01140 assert_param (IS_PWR_CORE (CPU)); 01141 01142 /* Check CPU index */ 01143 if (CPU == PWR_CORE_CPU2) 01144 { 01145 /* If CPU1 is not held */ 01146 if ((PWR->CPU2CR & PWR_CPU2CR_HOLD1) != PWR_CPU2CR_HOLD1) 01147 { 01148 /* Set HOLD2 bit */ 01149 SET_BIT (PWR->CPUCR, PWR_CPUCR_HOLD2); 01150 } 01151 else 01152 { 01153 status = HAL_ERROR; 01154 } 01155 } 01156 else 01157 { 01158 /* If CPU2 is not held */ 01159 if ((PWR->CPUCR & PWR_CPUCR_HOLD2) != PWR_CPUCR_HOLD2) 01160 { 01161 /* Set HOLD1 bit */ 01162 SET_BIT (PWR->CPU2CR, PWR_CPU2CR_HOLD1); 01163 } 01164 else 01165 { 01166 status = HAL_ERROR; 01167 } 01168 } 01169 01170 return status; 01171 } 01172 01173 /** 01174 * @brief Release the CPU and their domain peripherals after a wake-up from 01175 * STOP mode. 01176 * @param CPU: Specifies the core to be released. 01177 * This parameter can be one of the following values: 01178 * @arg PWR_CORE_CPU1: Release the CPU1 and their domain 01179 * peripherals from holding. 01180 * @arg PWR_CORE_CPU2: Release the CPU2 and their domain 01181 * peripherals from holding. 01182 * @retval None 01183 */ 01184 void HAL_PWREx_ReleaseCore (uint32_t CPU) 01185 { 01186 /* Check the parameters */ 01187 assert_param (IS_PWR_CORE (CPU)); 01188 01189 /* Check CPU index */ 01190 if (CPU == PWR_CORE_CPU2) 01191 { 01192 /* Reset HOLD2 bit */ 01193 CLEAR_BIT (PWR->CPUCR, PWR_CPUCR_HOLD2); 01194 } 01195 else 01196 { 01197 /* Reset HOLD1 bit */ 01198 CLEAR_BIT (PWR->CPU2CR, PWR_CPU2CR_HOLD1); 01199 } 01200 } 01201 #endif /* defined (DUAL_CORE) */ 01202 01203 01204 /** 01205 * @brief Enable the Flash Power Down in Stop mode. 01206 * @note When Flash Power Down is enabled the Flash memory enters low-power 01207 * mode when D1/SRD domain is in DStop mode. This feature allows to 01208 * obtain the best trade-off between low-power consumption and restart 01209 * time when exiting from DStop mode. 01210 * @retval None. 01211 */ 01212 void HAL_PWREx_EnableFlashPowerDown (void) 01213 { 01214 /* Enable the Flash Power Down */ 01215 SET_BIT (PWR->CR1, PWR_CR1_FLPS); 01216 } 01217 01218 /** 01219 * @brief Disable the Flash Power Down in Stop mode. 01220 * @note When Flash Power Down is disabled the Flash memory is kept on 01221 * normal mode when D1/SRD domain is in DStop mode. This feature allows 01222 * to obtain the best trade-off between low-power consumption and 01223 * restart time when exiting from DStop mode. 01224 * @retval None. 01225 */ 01226 void HAL_PWREx_DisableFlashPowerDown (void) 01227 { 01228 /* Disable the Flash Power Down */ 01229 CLEAR_BIT (PWR->CR1, PWR_CR1_FLPS); 01230 } 01231 01232 #if defined (PWR_CR1_SRDRAMSO) 01233 /** 01234 * @brief Enable memory block shut-off in DStop or DStop2 modes 01235 * @note In DStop or DStop2 mode, the content of the memory blocks is 01236 * maintained. Further power optimization can be obtained by switching 01237 * off some memory blocks. This optimization implies loss of the memory 01238 * content. The user can select which memory is discarded during STOP 01239 * mode by means of xxSO bits. 01240 * @param MemoryBlock : Specifies the memory block to shut-off during DStop or 01241 * DStop2 mode. 01242 * This parameter can be one of the following values: 01243 * @arg PWR_SRD_AHB_MEMORY_BLOCK : SmartRun domain AHB memory. 01244 * @arg PWR_USB_FDCAN_MEMORY_BLOCK : High-speed interfaces USB and 01245 * FDCAN memories. 01246 * @arg PWR_GFXMMU_JPEG_MEMORY_BLOCK : GFXMMU and JPEG memories. 01247 * @arg PWR_TCM_ECM_MEMORY_BLOCK : Instruction TCM and ETM memories. 01248 * @arg PWR_RAM1_AHB_MEMORY_BLOCK : AHB RAM1 memory. 01249 * @arg PWR_RAM2_AHB_MEMORY_BLOCK : AHB RAM2 memory. 01250 * @arg PWR_RAM1_AXI_MEMORY_BLOCK : AXI RAM1 memory. 01251 * @arg PWR_RAM2_AXI_MEMORY_BLOCK : AXI RAM2 memory. 01252 * @arg PWR_RAM3_AXI_MEMORY_BLOCK : AXI RAM3 memory. 01253 * @retval None. 01254 */ 01255 void HAL_PWREx_EnableMemoryShutOff (uint32_t MemoryBlock) 01256 { 01257 /* Check the parameter */ 01258 assert_param (IS_PWR_MEMORY_BLOCK (MemoryBlock)); 01259 01260 /* Enable memory block shut-off */ 01261 SET_BIT (PWR->CR1, MemoryBlock); 01262 } 01263 01264 /** 01265 * @brief Disable memory block shut-off in DStop or DStop2 modes 01266 * @param MemoryBlock : Specifies the memory block to keep content during 01267 * DStop or DStop2 mode. 01268 * This parameter can be one of the following values: 01269 * @arg PWR_SRD_AHB_MEMORY_BLOCK : SmartRun domain AHB memory. 01270 * @arg PWR_USB_FDCAN_MEMORY_BLOCK : High-speed interfaces USB and 01271 * FDCAN memories. 01272 * @arg PWR_GFXMMU_JPEG_MEMORY_BLOCK : GFXMMU and JPEG memories. 01273 * @arg PWR_TCM_ECM_MEMORY_BLOCK : Instruction TCM and ETM memories. 01274 * @arg PWR_RAM1_AHB_MEMORY_BLOCK : AHB RAM1 memory. 01275 * @arg PWR_RAM2_AHB_MEMORY_BLOCK : AHB RAM2 memory. 01276 * @arg PWR_RAM1_AXI_MEMORY_BLOCK : AXI RAM1 memory. 01277 * @arg PWR_RAM2_AXI_MEMORY_BLOCK : AXI RAM2 memory. 01278 * @arg PWR_RAM3_AXI_MEMORY_BLOCK : AXI RAM3 memory. 01279 * @retval None. 01280 */ 01281 void HAL_PWREx_DisableMemoryShutOff (uint32_t MemoryBlock) 01282 { 01283 /* Check the parameter */ 01284 assert_param (IS_PWR_MEMORY_BLOCK (MemoryBlock)); 01285 01286 /* Disable memory block shut-off */ 01287 CLEAR_BIT (PWR->CR1, MemoryBlock); 01288 } 01289 #endif /* defined (PWR_CR1_SRDRAMSO) */ 01290 01291 /** 01292 * @brief Enable the Wake-up PINx functionality. 01293 * @param sPinParams : Pointer to a PWREx_WakeupPinTypeDef structure that 01294 * contains the configuration information for the wake-up 01295 * Pin. 01296 * @note For dual core devices, please ensure to configure the EXTI lines for 01297 * the different Cortex-Mx. All combination are allowed: wake up only 01298 * Cortex-M7, wake up only Cortex-M4 and wake up Cortex-M7 and 01299 * Cortex-M4. 01300 * @retval None. 01301 */ 01302 void HAL_PWREx_EnableWakeUpPin (PWREx_WakeupPinTypeDef *sPinParams) 01303 { 01304 uint32_t pinConfig; 01305 uint32_t regMask; 01306 const uint32_t pullMask = PWR_WKUPEPR_WKUPPUPD1; 01307 01308 /* Check the parameters */ 01309 assert_param (IS_PWR_WAKEUP_PIN (sPinParams->WakeUpPin)); 01310 assert_param (IS_PWR_WAKEUP_PIN_POLARITY (sPinParams->PinPolarity)); 01311 assert_param (IS_PWR_WAKEUP_PIN_PULL (sPinParams->PinPull)); 01312 01313 pinConfig = sPinParams->WakeUpPin | \ 01314 (sPinParams->PinPolarity << ((POSITION_VAL(sPinParams->WakeUpPin) + PWR_WKUPEPR_WKUPP1_Pos) & 0x1FU)) | \ 01315 (sPinParams->PinPull << (((POSITION_VAL(sPinParams->WakeUpPin) * PWR_WAKEUP_PINS_PULL_SHIFT_OFFSET) + PWR_WKUPEPR_WKUPPUPD1_Pos) & 0x1FU)); 01316 01317 regMask = sPinParams->WakeUpPin | \ 01318 (PWR_WKUPEPR_WKUPP1 << (POSITION_VAL(sPinParams->WakeUpPin) & 0x1FU)) | \ 01319 (pullMask << ((POSITION_VAL(sPinParams->WakeUpPin) * PWR_WAKEUP_PINS_PULL_SHIFT_OFFSET) & 0x1FU)); 01320 01321 /* Enable and Specify the Wake-Up pin polarity and the pull configuration 01322 for the event detection (rising or falling edge) */ 01323 MODIFY_REG (PWR->WKUPEPR, regMask, pinConfig); 01324 #ifndef DUAL_CORE 01325 /* Configure the Wakeup Pin EXTI Line */ 01326 MODIFY_REG (EXTI->IMR2, PWR_EXTI_WAKEUP_PINS_MASK, (sPinParams->WakeUpPin << EXTI_IMR2_IM55_Pos)); 01327 #endif /* !DUAL_CORE */ 01328 } 01329 01330 /** 01331 * @brief Disable the Wake-up PINx functionality. 01332 * @param WakeUpPin : Specifies the Wake-Up pin to be disabled. 01333 * This parameter can be one of the following values: 01334 * @arg PWR_WAKEUP_PIN1 : Disable PA0 wake-up PIN. 01335 * @arg PWR_WAKEUP_PIN2 : Disable PA2 wake-up PIN. 01336 * @arg PWR_WAKEUP_PIN3 : Disable PI8 wake-up PIN. 01337 * @arg PWR_WAKEUP_PIN4 : Disable PC13 wake-up PIN. 01338 * @arg PWR_WAKEUP_PIN5 : Disable PI11 wake-up PIN. 01339 * @arg PWR_WAKEUP_PIN6 : Disable PC1 wake-up PIN. 01340 * @note The PWR_WAKEUP_PIN3 and PWR_WAKEUP_PIN5 are available only for 01341 * devices that support GPIOI port. 01342 * @retval None 01343 */ 01344 void HAL_PWREx_DisableWakeUpPin (uint32_t WakeUpPin) 01345 { 01346 /* Check the parameter */ 01347 assert_param (IS_PWR_WAKEUP_PIN (WakeUpPin)); 01348 01349 /* Disable the WakeUpPin */ 01350 CLEAR_BIT (PWR->WKUPEPR, WakeUpPin); 01351 } 01352 01353 /** 01354 * @brief Get the Wake-Up Pin pending flags. 01355 * @param WakeUpFlag : Specifies the Wake-Up PIN flag to be checked. 01356 * This parameter can be one of the following values: 01357 * @arg PWR_WAKEUP_FLAG1 : Get wakeup event received from PA0. 01358 * @arg PWR_WAKEUP_FLAG2 : Get wakeup event received from PA2. 01359 * @arg PWR_WAKEUP_FLAG3 : Get wakeup event received from PI8. 01360 * @arg PWR_WAKEUP_FLAG4 : Get wakeup event received from PC13. 01361 * @arg PWR_WAKEUP_FLAG5 : Get wakeup event received from PI11. 01362 * @arg PWR_WAKEUP_FLAG6 : Get wakeup event received from PC1. 01363 * @arg PWR_WAKEUP_FLAG_ALL : Get Wakeup event received from all 01364 * wake up pins. 01365 * @note The PWR_WAKEUP_FLAG3 and PWR_WAKEUP_FLAG5 are available only for 01366 * devices that support GPIOI port. 01367 * @retval The Wake-Up pin flag. 01368 */ 01369 uint32_t HAL_PWREx_GetWakeupFlag (uint32_t WakeUpFlag) 01370 { 01371 /* Check the parameters */ 01372 assert_param (IS_PWR_WAKEUP_FLAG (WakeUpFlag)); 01373 01374 /* Return the wake up pin flag */ 01375 return (PWR->WKUPFR & WakeUpFlag); 01376 } 01377 01378 /** 01379 * @brief Clear the Wake-Up pin pending flag. 01380 * @param WakeUpFlag: Specifies the Wake-Up PIN flag to clear. 01381 * This parameter can be one of the following values: 01382 * @arg PWR_WAKEUP_FLAG1 : Clear the wakeup event received from PA0. 01383 * @arg PWR_WAKEUP_FLAG2 : Clear the wakeup event received from PA2. 01384 * @arg PWR_WAKEUP_FLAG3 : Clear the wakeup event received from PI8. 01385 * @arg PWR_WAKEUP_FLAG4 : Clear the wakeup event received from PC13. 01386 * @arg PWR_WAKEUP_FLAG5 : Clear the wakeup event received from PI11. 01387 * @arg PWR_WAKEUP_FLAG6 : Clear the wakeup event received from PC1. 01388 * @arg PWR_WAKEUP_FLAG_ALL : Clear the wakeup events received from 01389 * all wake up pins. 01390 * @note The PWR_WAKEUP_FLAG3 and PWR_WAKEUP_FLAG5 are available only for 01391 * devices that support GPIOI port. 01392 * @retval HAL status. 01393 */ 01394 HAL_StatusTypeDef HAL_PWREx_ClearWakeupFlag (uint32_t WakeUpFlag) 01395 { 01396 /* Check the parameter */ 01397 assert_param (IS_PWR_WAKEUP_FLAG (WakeUpFlag)); 01398 01399 /* Clear the wake up event received from wake up pin x */ 01400 SET_BIT (PWR->WKUPCR, WakeUpFlag); 01401 01402 /* Check if the wake up event is well cleared */ 01403 if ((PWR->WKUPFR & WakeUpFlag) != 0U) 01404 { 01405 return HAL_ERROR; 01406 } 01407 01408 return HAL_OK; 01409 } 01410 01411 /** 01412 * @brief This function handles the PWR WAKEUP PIN interrupt request. 01413 * @note This API should be called under the WAKEUP_PIN_IRQHandler(). 01414 * @retval None. 01415 */ 01416 void HAL_PWREx_WAKEUP_PIN_IRQHandler (void) 01417 { 01418 /* Wakeup pin EXTI line interrupt detected */ 01419 if (READ_BIT(PWR->WKUPFR, PWR_WKUPFR_WKUPF1) != 0U) 01420 { 01421 /* Clear PWR WKUPF1 flag */ 01422 __HAL_PWR_CLEAR_WAKEUPFLAG (PWR_FLAG_WKUP1); 01423 01424 /* PWR WKUP1 interrupt user callback */ 01425 HAL_PWREx_WKUP1_Callback (); 01426 } 01427 else if (READ_BIT (PWR->WKUPFR, PWR_WKUPFR_WKUPF2) != 0U) 01428 { 01429 /* Clear PWR WKUPF2 flag */ 01430 __HAL_PWR_CLEAR_WAKEUPFLAG (PWR_FLAG_WKUP2); 01431 01432 /* PWR WKUP2 interrupt user callback */ 01433 HAL_PWREx_WKUP2_Callback (); 01434 } 01435 #if defined (PWR_WKUPFR_WKUPF3) 01436 else if (READ_BIT (PWR->WKUPFR, PWR_WKUPFR_WKUPF3) != 0U) 01437 { 01438 /* Clear PWR WKUPF3 flag */ 01439 __HAL_PWR_CLEAR_WAKEUPFLAG (PWR_FLAG_WKUP3); 01440 01441 /* PWR WKUP3 interrupt user callback */ 01442 HAL_PWREx_WKUP3_Callback (); 01443 } 01444 #endif /* defined (PWR_WKUPFR_WKUPF3) */ 01445 else if (READ_BIT (PWR->WKUPFR, PWR_WKUPFR_WKUPF4) != 0U) 01446 { 01447 /* Clear PWR WKUPF4 flag */ 01448 __HAL_PWR_CLEAR_WAKEUPFLAG (PWR_FLAG_WKUP4); 01449 01450 /* PWR WKUP4 interrupt user callback */ 01451 HAL_PWREx_WKUP4_Callback (); 01452 } 01453 #if defined (PWR_WKUPFR_WKUPF5) 01454 else if (READ_BIT (PWR->WKUPFR, PWR_WKUPFR_WKUPF5) != 0U) 01455 { 01456 /* Clear PWR WKUPF5 flag */ 01457 __HAL_PWR_CLEAR_WAKEUPFLAG (PWR_FLAG_WKUP5); 01458 01459 /* PWR WKUP5 interrupt user callback */ 01460 HAL_PWREx_WKUP5_Callback (); 01461 } 01462 #endif /* defined (PWR_WKUPFR_WKUPF5) */ 01463 else 01464 { 01465 /* Clear PWR WKUPF6 flag */ 01466 __HAL_PWR_CLEAR_WAKEUPFLAG (PWR_FLAG_WKUP6); 01467 01468 /* PWR WKUP6 interrupt user callback */ 01469 HAL_PWREx_WKUP6_Callback (); 01470 } 01471 } 01472 01473 /** 01474 * @brief PWR WKUP1 interrupt callback. 01475 * @retval None. 01476 */ 01477 __weak void HAL_PWREx_WKUP1_Callback (void) 01478 { 01479 /* NOTE : This function should not be modified, when the callback is needed, 01480 the HAL_PWREx_WKUP1Callback can be implemented in the user file 01481 */ 01482 } 01483 01484 /** 01485 * @brief PWR WKUP2 interrupt callback. 01486 * @retval None. 01487 */ 01488 __weak void HAL_PWREx_WKUP2_Callback (void) 01489 { 01490 /* NOTE : This function should not be modified, when the callback is needed, 01491 the HAL_PWREx_WKUP2Callback can be implemented in the user file 01492 */ 01493 } 01494 01495 #if defined (PWR_WKUPFR_WKUPF3) 01496 /** 01497 * @brief PWR WKUP3 interrupt callback. 01498 * @retval None. 01499 */ 01500 __weak void HAL_PWREx_WKUP3_Callback (void) 01501 { 01502 /* NOTE : This function should not be modified, when the callback is needed, 01503 the HAL_PWREx_WKUP3Callback can be implemented in the user file 01504 */ 01505 } 01506 #endif /* defined (PWR_WKUPFR_WKUPF3) */ 01507 01508 /** 01509 * @brief PWR WKUP4 interrupt callback. 01510 * @retval None. 01511 */ 01512 __weak void HAL_PWREx_WKUP4_Callback (void) 01513 { 01514 /* NOTE : This function should not be modified, when the callback is needed, 01515 the HAL_PWREx_WKUP4Callback can be implemented in the user file 01516 */ 01517 } 01518 01519 #if defined (PWR_WKUPFR_WKUPF5) 01520 /** 01521 * @brief PWR WKUP5 interrupt callback. 01522 * @retval None. 01523 */ 01524 __weak void HAL_PWREx_WKUP5_Callback (void) 01525 { 01526 /* NOTE : This function should not be modified, when the callback is needed, 01527 the HAL_PWREx_WKUP5Callback can be implemented in the user file 01528 */ 01529 } 01530 #endif /* defined (PWR_WKUPFR_WKUPF5) */ 01531 01532 /** 01533 * @brief PWR WKUP6 interrupt callback. 01534 * @retval None. 01535 */ 01536 __weak void HAL_PWREx_WKUP6_Callback (void) 01537 { 01538 /* NOTE : This function should not be modified, when the callback is needed, 01539 the HAL_PWREx_WKUP6Callback can be implemented in the user file 01540 */ 01541 } 01542 /** 01543 * @} 01544 */ 01545 01546 /** @defgroup PWREx_Exported_Functions_Group3 Peripherals control functions 01547 * @brief Peripherals control functions 01548 * 01549 @verbatim 01550 =============================================================================== 01551 ##### Peripherals control functions ##### 01552 =============================================================================== 01553 01554 *** Main and Backup Regulators configuration *** 01555 ================================================ 01556 [..] 01557 (+) The backup domain includes 4 Kbytes of backup SRAM accessible only 01558 from the CPU, and addressed in 32-bit, 16-bit or 8-bit mode. Its 01559 content is retained even in Standby or VBAT mode when the low power 01560 backup regulator is enabled. It can be considered as an internal 01561 EEPROM when VBAT is always present. You can use the 01562 HAL_PWREx_EnableBkUpReg() function to enable the low power backup 01563 regulator. 01564 (+) When the backup domain is supplied by VDD (analog switch connected to 01565 VDD) the backup SRAM is powered from VDD which replaces the VBAT power 01566 supply to save battery life. 01567 (+) The backup SRAM is not mass erased by a tamper event. It is read 01568 protected to prevent confidential data, such as cryptographic private 01569 key, from being accessed. The backup SRAM can be erased only through 01570 the Flash interface when a protection level change from level 1 to 01571 level 0 is requested. 01572 -@- Refer to the description of Read protection (RDP) in the Flash 01573 programming manual. 01574 (+) The main internal regulator can be configured to have a tradeoff 01575 between performance and power consumption when the device does not 01576 operate at the maximum frequency. This is done through 01577 HAL_PWREx_ControlVoltageScaling(VOS) function which configure the VOS 01578 bit in PWR_D3CR register. 01579 (+) The main internal regulator can be configured to operate in Low Power 01580 mode when the system enters STOP mode to further reduce power 01581 consumption. 01582 This is done through HAL_PWREx_ControlStopModeVoltageScaling(SVOS) 01583 function which configure the SVOS bit in PWR_CR1 register. 01584 The selected SVOS4 and SVOS5 levels add an additional startup delay 01585 when exiting from system Stop mode. 01586 -@- Refer to the product datasheets for more details. 01587 01588 *** USB Regulator configuration *** 01589 =================================== 01590 [..] 01591 (+) The USB transceivers are supplied from a dedicated VDD33USB supply 01592 that can be provided either by the integrated USB regulator, or by an 01593 external USB supply. 01594 (+) The USB regulator is enabled by HAL_PWREx_EnableUSBReg() function, the 01595 VDD33USB is then provided from the USB regulator. 01596 (+) When the USB regulator is enabled, the VDD33USB supply level detector 01597 shall be enabled through HAL_PWREx_EnableUSBVoltageDetector() 01598 function. 01599 (+) The USB regulator is disabled through HAL_PWREx_DisableUSBReg() 01600 function and VDD33USB can be provided from an external supply. In this 01601 case VDD33USB and VDD50USB shall be connected together. 01602 01603 *** VBAT battery charging *** 01604 ============================= 01605 [..] 01606 (+) When VDD is present, the external battery connected to VBAT can be 01607 charged through an internal resistance. VBAT charging can be performed 01608 either through a 5 KOhm resistor or through a 1.5 KOhm resistor. 01609 (+) VBAT charging is enabled by HAL_PWREx_EnableBatteryCharging 01610 (ResistorValue) function with: 01611 (++) ResistorValue: 01612 (+++) PWR_BATTERY_CHARGING_RESISTOR_5: 5 KOhm resistor. 01613 (+++) PWR_BATTERY_CHARGING_RESISTOR_1_5: 1.5 KOhm resistor. 01614 (+) VBAT charging is disabled by HAL_PWREx_DisableBatteryCharging() 01615 function. 01616 01617 @endverbatim 01618 * @{ 01619 */ 01620 01621 /** 01622 * @brief Enable the Backup Regulator. 01623 * @retval HAL status. 01624 */ 01625 HAL_StatusTypeDef HAL_PWREx_EnableBkUpReg (void) 01626 { 01627 uint32_t tickstart; 01628 01629 /* Enable the Backup regulator */ 01630 SET_BIT (PWR->CR2, PWR_CR2_BREN); 01631 01632 /* Get tick */ 01633 tickstart = HAL_GetTick (); 01634 01635 /* Wait till Backup regulator ready flag is set */ 01636 while (__HAL_PWR_GET_FLAG (PWR_FLAG_BRR) == 0U) 01637 { 01638 if ((HAL_GetTick() - tickstart ) > PWR_FLAG_SETTING_DELAY) 01639 { 01640 return HAL_ERROR; 01641 } 01642 } 01643 01644 return HAL_OK; 01645 } 01646 01647 /** 01648 * @brief Disable the Backup Regulator. 01649 * @retval HAL status. 01650 */ 01651 HAL_StatusTypeDef HAL_PWREx_DisableBkUpReg (void) 01652 { 01653 uint32_t tickstart; 01654 01655 /* Disable the Backup regulator */ 01656 CLEAR_BIT (PWR->CR2, PWR_CR2_BREN); 01657 01658 /* Get tick */ 01659 tickstart = HAL_GetTick (); 01660 01661 /* Wait till Backup regulator ready flag is reset */ 01662 while (__HAL_PWR_GET_FLAG (PWR_FLAG_BRR) != 0U) 01663 { 01664 if ((HAL_GetTick() - tickstart ) > PWR_FLAG_SETTING_DELAY) 01665 { 01666 return HAL_ERROR; 01667 } 01668 } 01669 01670 return HAL_OK; 01671 } 01672 01673 /** 01674 * @brief Enable the USB Regulator. 01675 * @retval HAL status. 01676 */ 01677 HAL_StatusTypeDef HAL_PWREx_EnableUSBReg (void) 01678 { 01679 uint32_t tickstart; 01680 01681 /* Enable the USB regulator */ 01682 SET_BIT (PWR->CR3, PWR_CR3_USBREGEN); 01683 01684 /* Get tick */ 01685 tickstart = HAL_GetTick (); 01686 01687 /* Wait till the USB regulator ready flag is set */ 01688 while (__HAL_PWR_GET_FLAG (PWR_FLAG_USB33RDY) == 0U) 01689 { 01690 if ((HAL_GetTick() - tickstart ) > PWR_FLAG_SETTING_DELAY) 01691 { 01692 return HAL_ERROR; 01693 } 01694 } 01695 01696 return HAL_OK; 01697 } 01698 01699 /** 01700 * @brief Disable the USB Regulator. 01701 * @retval HAL status. 01702 */ 01703 HAL_StatusTypeDef HAL_PWREx_DisableUSBReg (void) 01704 { 01705 uint32_t tickstart; 01706 01707 /* Disable the USB regulator */ 01708 CLEAR_BIT (PWR->CR3, PWR_CR3_USBREGEN); 01709 01710 /* Get tick */ 01711 tickstart = HAL_GetTick (); 01712 01713 /* Wait till the USB regulator ready flag is reset */ 01714 while(__HAL_PWR_GET_FLAG (PWR_FLAG_USB33RDY) != 0U) 01715 { 01716 if ((HAL_GetTick() - tickstart ) > PWR_FLAG_SETTING_DELAY) 01717 { 01718 return HAL_ERROR; 01719 } 01720 } 01721 01722 return HAL_OK; 01723 } 01724 01725 /** 01726 * @brief Enable the USB voltage level detector. 01727 * @retval None. 01728 */ 01729 void HAL_PWREx_EnableUSBVoltageDetector (void) 01730 { 01731 /* Enable the USB voltage detector */ 01732 SET_BIT (PWR->CR3, PWR_CR3_USB33DEN); 01733 } 01734 01735 /** 01736 * @brief Disable the USB voltage level detector. 01737 * @retval None. 01738 */ 01739 void HAL_PWREx_DisableUSBVoltageDetector (void) 01740 { 01741 /* Disable the USB voltage detector */ 01742 CLEAR_BIT (PWR->CR3, PWR_CR3_USB33DEN); 01743 } 01744 01745 /** 01746 * @brief Enable the Battery charging. 01747 * @note When VDD is present, charge the external battery through an internal 01748 * resistor. 01749 * @param ResistorValue : Specifies the charging resistor. 01750 * This parameter can be one of the following values : 01751 * @arg PWR_BATTERY_CHARGING_RESISTOR_5 : 5 KOhm resistor. 01752 * @arg PWR_BATTERY_CHARGING_RESISTOR_1_5 : 1.5 KOhm resistor. 01753 * @retval None. 01754 */ 01755 void HAL_PWREx_EnableBatteryCharging (uint32_t ResistorValue) 01756 { 01757 /* Check the parameter */ 01758 assert_param (IS_PWR_BATTERY_RESISTOR_SELECT (ResistorValue)); 01759 01760 /* Specify the charging resistor */ 01761 MODIFY_REG (PWR->CR3, PWR_CR3_VBRS, ResistorValue); 01762 01763 /* Enable the Battery charging */ 01764 SET_BIT (PWR->CR3, PWR_CR3_VBE); 01765 } 01766 01767 /** 01768 * @brief Disable the Battery charging. 01769 * @retval None. 01770 */ 01771 void HAL_PWREx_DisableBatteryCharging (void) 01772 { 01773 /* Disable the Battery charging */ 01774 CLEAR_BIT (PWR->CR3, PWR_CR3_VBE); 01775 } 01776 01777 #if defined (PWR_CR1_BOOSTE) 01778 /** 01779 * @brief Enable the booster to guarantee the analog switch AC performance when 01780 * the VDD supply voltage is below 2V7. 01781 * @note The VDD supply voltage can be monitored through the PVD and the PLS 01782 * field bits. 01783 * @retval None. 01784 */ 01785 void HAL_PWREx_EnableAnalogBooster (void) 01786 { 01787 /* Enable the Analog voltage */ 01788 SET_BIT (PWR->CR1, PWR_CR1_AVD_READY); 01789 01790 /* Enable VDDA booster */ 01791 SET_BIT (PWR->CR1, PWR_CR1_BOOSTE); 01792 } 01793 01794 /** 01795 * @brief Disable the analog booster. 01796 * @retval None. 01797 */ 01798 void HAL_PWREx_DisableAnalogBooster (void) 01799 { 01800 /* Disable VDDA booster */ 01801 CLEAR_BIT (PWR->CR1, PWR_CR1_BOOSTE); 01802 01803 /* Disable the Analog voltage */ 01804 CLEAR_BIT (PWR->CR1, PWR_CR1_AVD_READY); 01805 } 01806 #endif /* defined (PWR_CR1_BOOSTE) */ 01807 /** 01808 * @} 01809 */ 01810 01811 /** @defgroup PWREx_Exported_Functions_Group4 Power Monitoring functions 01812 * @brief Power Monitoring functions 01813 * 01814 @verbatim 01815 =============================================================================== 01816 ##### Power Monitoring functions ##### 01817 =============================================================================== 01818 01819 *** VBAT and Temperature supervision *** 01820 ======================================== 01821 [..] 01822 (+) The VBAT battery voltage supply can be monitored by comparing it with 01823 two threshold levels: VBAThigh and VBATlow. VBATH flag and VBATL flags 01824 in the PWR control register 2 (PWR_CR2), indicate if VBAT is higher or 01825 lower than the threshold. 01826 (+) The temperature can be monitored by comparing it with two threshold 01827 levels, TEMPhigh and TEMPlow. TEMPH and TEMPL flags, in the PWR 01828 control register 2 (PWR_CR2), indicate whether the device temperature 01829 is higher or lower than the threshold. 01830 (+) The VBAT and the temperature monitoring is enabled by 01831 HAL_PWREx_EnableMonitoring() function and disabled by 01832 HAL_PWREx_DisableMonitoring() function. 01833 (+) The HAL_PWREx_GetVBATLevel() function returns the VBAT level which can 01834 be : PWR_VBAT_BELOW_LOW_THRESHOLD or PWR_VBAT_ABOVE_HIGH_THRESHOLD or 01835 PWR_VBAT_BETWEEN_HIGH_LOW_THRESHOLD. 01836 (+) The HAL_PWREx_GetTemperatureLevel() function returns the Temperature 01837 level which can be : 01838 PWR_TEMP_BELOW_LOW_THRESHOLD or PWR_TEMP_ABOVE_HIGH_THRESHOLD or 01839 PWR_TEMP_BETWEEN_HIGH_LOW_THRESHOLD. 01840 01841 *** AVD configuration *** 01842 ========================= 01843 [..] 01844 (+) The AVD is used to monitor the VDDA power supply by comparing it to a 01845 threshold selected by the AVD Level (ALS[3:0] bits in the PWR_CR1 01846 register). 01847 (+) A AVDO flag is available to indicate if VDDA is higher or lower 01848 than the AVD threshold. This event is internally connected to the EXTI 01849 line 16 to generate an interrupt if enabled. 01850 It is configurable through __HAL_PWR_AVD_EXTI_ENABLE_IT() macro. 01851 (+) The AVD is stopped in System Standby mode. 01852 01853 @endverbatim 01854 * @{ 01855 */ 01856 01857 /** 01858 * @brief Enable the VBAT and temperature monitoring. 01859 * @retval HAL status. 01860 */ 01861 void HAL_PWREx_EnableMonitoring (void) 01862 { 01863 /* Enable the VBAT and Temperature monitoring */ 01864 SET_BIT (PWR->CR2, PWR_CR2_MONEN); 01865 } 01866 01867 /** 01868 * @brief Disable the VBAT and temperature monitoring. 01869 * @retval HAL status. 01870 */ 01871 void HAL_PWREx_DisableMonitoring (void) 01872 { 01873 /* Disable the VBAT and Temperature monitoring */ 01874 CLEAR_BIT (PWR->CR2, PWR_CR2_MONEN); 01875 } 01876 01877 /** 01878 * @brief Indicate whether the junction temperature is between, above or below 01879 * the thresholds. 01880 * @retval Temperature level. 01881 */ 01882 uint32_t HAL_PWREx_GetTemperatureLevel (void) 01883 { 01884 uint32_t tempLevel, regValue; 01885 01886 /* Read the temperature flags */ 01887 regValue = READ_BIT (PWR->CR2, (PWR_CR2_TEMPH | PWR_CR2_TEMPL)); 01888 01889 /* Check if the temperature is below the threshold */ 01890 if (regValue == PWR_CR2_TEMPL) 01891 { 01892 tempLevel = PWR_TEMP_BELOW_LOW_THRESHOLD; 01893 } 01894 /* Check if the temperature is above the threshold */ 01895 else if (regValue == PWR_CR2_TEMPH) 01896 { 01897 tempLevel = PWR_TEMP_ABOVE_HIGH_THRESHOLD; 01898 } 01899 /* The temperature is between the thresholds */ 01900 else 01901 { 01902 tempLevel = PWR_TEMP_BETWEEN_HIGH_LOW_THRESHOLD; 01903 } 01904 01905 return tempLevel; 01906 } 01907 01908 /** 01909 * @brief Indicate whether the Battery voltage level is between, above or below 01910 * the thresholds. 01911 * @retval VBAT level. 01912 */ 01913 uint32_t HAL_PWREx_GetVBATLevel (void) 01914 { 01915 uint32_t VBATLevel, regValue; 01916 01917 /* Read the VBAT flags */ 01918 regValue = READ_BIT (PWR->CR2, (PWR_CR2_VBATH | PWR_CR2_VBATL)); 01919 01920 /* Check if the VBAT is below the threshold */ 01921 if (regValue == PWR_CR2_VBATL) 01922 { 01923 VBATLevel = PWR_VBAT_BELOW_LOW_THRESHOLD; 01924 } 01925 /* Check if the VBAT is above the threshold */ 01926 else if (regValue == PWR_CR2_VBATH) 01927 { 01928 VBATLevel = PWR_VBAT_ABOVE_HIGH_THRESHOLD; 01929 } 01930 /* The VBAT is between the thresholds */ 01931 else 01932 { 01933 VBATLevel = PWR_VBAT_BETWEEN_HIGH_LOW_THRESHOLD; 01934 } 01935 01936 return VBATLevel; 01937 } 01938 01939 #if defined (PWR_CSR1_MMCVDO) 01940 /** 01941 * @brief Get the VDDMMC voltage level. 01942 * @retval The VDDMMC voltage level. 01943 */ 01944 PWREx_MMC_VoltageLevel HAL_PWREx_GetMMCVoltage (void) 01945 { 01946 PWREx_MMC_VoltageLevel mmc_voltage; 01947 01948 /* Check voltage detector output on VDDMMC value */ 01949 if ((PWR->CSR1 & PWR_CSR1_MMCVDO_Msk) == 0U) 01950 { 01951 mmc_voltage = PWR_MMC_VOLTAGE_BELOW_1V2; 01952 } 01953 else 01954 { 01955 mmc_voltage = PWR_MMC_VOLTAGE_EQUAL_ABOVE_1V2; 01956 } 01957 01958 return mmc_voltage; 01959 } 01960 #endif /* defined (PWR_CSR1_MMCVDO) */ 01961 01962 /** 01963 * @brief Configure the event mode and the voltage threshold detected by the 01964 * Analog Voltage Detector (AVD). 01965 * @param sConfigAVD : Pointer to an PWREx_AVDTypeDef structure that contains 01966 * the configuration information for the AVD. 01967 * @note Refer to the electrical characteristics of your device datasheet for 01968 * more details about the voltage threshold corresponding to each 01969 * detection level. 01970 * @note For dual core devices, please ensure to configure the EXTI lines for 01971 * the different Cortex-Mx through PWR_Exported_Macro provided by this 01972 * driver. All combination are allowed: wake up only Cortex-M7, wake up 01973 * only Cortex-M4 and wake up Cortex-M7 and Cortex-M4. 01974 * @retval None. 01975 */ 01976 void HAL_PWREx_ConfigAVD (PWREx_AVDTypeDef *sConfigAVD) 01977 { 01978 /* Check the parameters */ 01979 assert_param (IS_PWR_AVD_LEVEL (sConfigAVD->AVDLevel)); 01980 assert_param (IS_PWR_AVD_MODE (sConfigAVD->Mode)); 01981 01982 /* Set the ALS[18:17] bits according to AVDLevel value */ 01983 MODIFY_REG (PWR->CR1, PWR_CR1_ALS, sConfigAVD->AVDLevel); 01984 01985 /* Clear any previous config */ 01986 #if !defined (DUAL_CORE) 01987 __HAL_PWR_AVD_EXTI_DISABLE_EVENT (); 01988 __HAL_PWR_AVD_EXTI_DISABLE_IT (); 01989 #endif /* !defined (DUAL_CORE) */ 01990 01991 __HAL_PWR_AVD_EXTI_DISABLE_RISING_EDGE (); 01992 __HAL_PWR_AVD_EXTI_DISABLE_FALLING_EDGE (); 01993 01994 #if !defined (DUAL_CORE) 01995 /* Configure the interrupt mode */ 01996 if ((sConfigAVD->Mode & AVD_MODE_IT) == AVD_MODE_IT) 01997 { 01998 __HAL_PWR_AVD_EXTI_ENABLE_IT (); 01999 } 02000 02001 /* Configure the event mode */ 02002 if ((sConfigAVD->Mode & AVD_MODE_EVT) == AVD_MODE_EVT) 02003 { 02004 __HAL_PWR_AVD_EXTI_ENABLE_EVENT (); 02005 } 02006 #endif /* !defined (DUAL_CORE) */ 02007 02008 /* Rising edge configuration */ 02009 if ((sConfigAVD->Mode & AVD_RISING_EDGE) == AVD_RISING_EDGE) 02010 { 02011 __HAL_PWR_AVD_EXTI_ENABLE_RISING_EDGE (); 02012 } 02013 02014 /* Falling edge configuration */ 02015 if ((sConfigAVD->Mode & AVD_FALLING_EDGE) == AVD_FALLING_EDGE) 02016 { 02017 __HAL_PWR_AVD_EXTI_ENABLE_FALLING_EDGE (); 02018 } 02019 } 02020 02021 /** 02022 * @brief Enable the Analog Voltage Detector (AVD). 02023 * @retval None. 02024 */ 02025 void HAL_PWREx_EnableAVD (void) 02026 { 02027 /* Enable the Analog Voltage Detector */ 02028 SET_BIT (PWR->CR1, PWR_CR1_AVDEN); 02029 } 02030 02031 /** 02032 * @brief Disable the Analog Voltage Detector(AVD). 02033 * @retval None. 02034 */ 02035 void HAL_PWREx_DisableAVD (void) 02036 { 02037 /* Disable the Analog Voltage Detector */ 02038 CLEAR_BIT (PWR->CR1, PWR_CR1_AVDEN); 02039 } 02040 02041 /** 02042 * @brief This function handles the PWR PVD/AVD interrupt request. 02043 * @note This API should be called under the PVD_AVD_IRQHandler(). 02044 * @retval None 02045 */ 02046 void HAL_PWREx_PVD_AVD_IRQHandler (void) 02047 { 02048 /* Check if the Programmable Voltage Detector is enabled (PVD) */ 02049 if (READ_BIT (PWR->CR1, PWR_CR1_PVDEN) != 0U) 02050 { 02051 #if defined (DUAL_CORE) 02052 if (HAL_GetCurrentCPUID () == CM7_CPUID) 02053 #endif /* defined (DUAL_CORE) */ 02054 { 02055 /* Check PWR D1/CD EXTI flag */ 02056 if (__HAL_PWR_PVD_EXTI_GET_FLAG () != 0U) 02057 { 02058 /* PWR PVD interrupt user callback */ 02059 HAL_PWR_PVDCallback (); 02060 02061 /* Clear PWR EXTI D1/CD pending bit */ 02062 __HAL_PWR_PVD_EXTI_CLEAR_FLAG (); 02063 } 02064 } 02065 #if defined (DUAL_CORE) 02066 else 02067 { 02068 /* Check PWR EXTI D2 flag */ 02069 if (__HAL_PWR_PVD_EXTID2_GET_FLAG () != 0U) 02070 { 02071 /* PWR PVD interrupt user callback */ 02072 HAL_PWR_PVDCallback (); 02073 02074 /* Clear PWR EXTI D2 pending bit */ 02075 __HAL_PWR_PVD_EXTID2_CLEAR_FLAG(); 02076 } 02077 } 02078 #endif /* defined (DUAL_CORE) */ 02079 } 02080 02081 /* Check if the Analog Voltage Detector is enabled (AVD) */ 02082 if (READ_BIT (PWR->CR1, PWR_CR1_AVDEN) != 0U) 02083 { 02084 #if defined (DUAL_CORE) 02085 if (HAL_GetCurrentCPUID () == CM7_CPUID) 02086 #endif /* defined (DUAL_CORE) */ 02087 { 02088 /* Check PWR EXTI D1/CD flag */ 02089 if (__HAL_PWR_AVD_EXTI_GET_FLAG () != 0U) 02090 { 02091 /* PWR AVD interrupt user callback */ 02092 HAL_PWREx_AVDCallback (); 02093 02094 /* Clear PWR EXTI D1/CD pending bit */ 02095 __HAL_PWR_AVD_EXTI_CLEAR_FLAG (); 02096 } 02097 } 02098 #if defined (DUAL_CORE) 02099 else 02100 { 02101 /* Check PWR EXTI D2 flag */ 02102 if (__HAL_PWR_AVD_EXTID2_GET_FLAG () != 0U) 02103 { 02104 /* PWR AVD interrupt user callback */ 02105 HAL_PWREx_AVDCallback (); 02106 02107 /* Clear PWR EXTI D2 pending bit */ 02108 __HAL_PWR_AVD_EXTID2_CLEAR_FLAG (); 02109 } 02110 } 02111 #endif /* defined (DUAL_CORE) */ 02112 } 02113 } 02114 02115 /** 02116 * @brief PWR AVD interrupt callback. 02117 * @retval None. 02118 */ 02119 __weak void HAL_PWREx_AVDCallback (void) 02120 { 02121 /* NOTE : This function should not be modified, when the callback is needed, 02122 the HAL_PWR_AVDCallback can be implemented in the user file 02123 */ 02124 } 02125 /** 02126 * @} 02127 */ 02128 02129 /** 02130 * @} 02131 */ 02132 02133 #endif /* HAL_PWR_MODULE_ENABLED */ 02134 02135 /** 02136 * @} 02137 */ 02138 02139 /** 02140 * @} 02141 */ 02142