1 /** 2 ****************************************************************************** 3 * @file stm32f7xx_hal_pwr_ex.h 4 * @author MCD Application Team 5 * @brief Header file of PWR HAL Extension module. 6 ****************************************************************************** 7 * @attention 8 * 9 * Copyright (c) 2017 STMicroelectronics. 10 * All rights reserved. 11 * 12 * This software is licensed under terms that can be found in the LICENSE file 13 * in the root directory of this software component. 14 * If no LICENSE file comes with this software, it is provided AS-IS. 15 * 16 ****************************************************************************** 17 */ 18 19 /* Define to prevent recursive inclusion -------------------------------------*/ 20 #ifndef __STM32F7xx_HAL_PWR_EX_H 21 #define __STM32F7xx_HAL_PWR_EX_H 22 23 #ifdef __cplusplus 24 extern "C" { 25 #endif 26 27 /* Includes ------------------------------------------------------------------*/ 28 #include "stm32f7xx_hal_def.h" 29 30 /** @addtogroup STM32F7xx_HAL_Driver 31 * @{ 32 */ 33 34 /** @addtogroup PWREx 35 * @{ 36 */ 37 38 /* Exported types ------------------------------------------------------------*/ 39 /* Exported constants --------------------------------------------------------*/ 40 /** @defgroup PWREx_Exported_Constants PWREx Exported Constants 41 * @{ 42 */ 43 /** @defgroup PWREx_WakeUp_Pins PWREx Wake Up Pins 44 * @{ 45 */ 46 #define PWR_WAKEUP_PIN1 PWR_CSR2_EWUP1 47 #define PWR_WAKEUP_PIN2 PWR_CSR2_EWUP2 48 #define PWR_WAKEUP_PIN3 PWR_CSR2_EWUP3 49 #define PWR_WAKEUP_PIN4 PWR_CSR2_EWUP4 50 #define PWR_WAKEUP_PIN5 PWR_CSR2_EWUP5 51 #define PWR_WAKEUP_PIN6 PWR_CSR2_EWUP6 52 #define PWR_WAKEUP_PIN1_HIGH PWR_CSR2_EWUP1 53 #define PWR_WAKEUP_PIN2_HIGH PWR_CSR2_EWUP2 54 #define PWR_WAKEUP_PIN3_HIGH PWR_CSR2_EWUP3 55 #define PWR_WAKEUP_PIN4_HIGH PWR_CSR2_EWUP4 56 #define PWR_WAKEUP_PIN5_HIGH PWR_CSR2_EWUP5 57 #define PWR_WAKEUP_PIN6_HIGH PWR_CSR2_EWUP6 58 #define PWR_WAKEUP_PIN1_LOW (uint32_t)((PWR_CR2_WUPP1<<6) | PWR_CSR2_EWUP1) 59 #define PWR_WAKEUP_PIN2_LOW (uint32_t)((PWR_CR2_WUPP2<<6) | PWR_CSR2_EWUP2) 60 #define PWR_WAKEUP_PIN3_LOW (uint32_t)((PWR_CR2_WUPP3<<6) | PWR_CSR2_EWUP3) 61 #define PWR_WAKEUP_PIN4_LOW (uint32_t)((PWR_CR2_WUPP4<<6) | PWR_CSR2_EWUP4) 62 #define PWR_WAKEUP_PIN5_LOW (uint32_t)((PWR_CR2_WUPP5<<6) | PWR_CSR2_EWUP5) 63 #define PWR_WAKEUP_PIN6_LOW (uint32_t)((PWR_CR2_WUPP6<<6) | PWR_CSR2_EWUP6) 64 65 /** 66 * @} 67 */ 68 69 /** @defgroup PWREx_Regulator_state_in_UnderDrive_mode PWREx Regulator state in UnderDrive mode 70 * @{ 71 */ 72 #define PWR_MAINREGULATOR_UNDERDRIVE_ON PWR_CR1_MRUDS 73 #define PWR_LOWPOWERREGULATOR_UNDERDRIVE_ON ((uint32_t)(PWR_CR1_LPDS | PWR_CR1_LPUDS)) 74 /** 75 * @} 76 */ 77 78 /** @defgroup PWREx_Over_Under_Drive_Flag PWREx Over Under Drive Flag 79 * @{ 80 */ 81 #define PWR_FLAG_ODRDY PWR_CSR1_ODRDY 82 #define PWR_FLAG_ODSWRDY PWR_CSR1_ODSWRDY 83 #define PWR_FLAG_UDRDY PWR_CSR1_UDRDY 84 /** 85 * @} 86 */ 87 88 /** @defgroup PWREx_Wakeup_Pins_Flag PWREx Wake Up Pin Flags 89 * @{ 90 */ 91 #define PWR_WAKEUP_PIN_FLAG1 PWR_CSR2_WUPF1 92 #define PWR_WAKEUP_PIN_FLAG2 PWR_CSR2_WUPF2 93 #define PWR_WAKEUP_PIN_FLAG3 PWR_CSR2_WUPF3 94 #define PWR_WAKEUP_PIN_FLAG4 PWR_CSR2_WUPF4 95 #define PWR_WAKEUP_PIN_FLAG5 PWR_CSR2_WUPF5 96 #define PWR_WAKEUP_PIN_FLAG6 PWR_CSR2_WUPF6 97 /** 98 * @} 99 */ 100 101 /** 102 * @} 103 */ 104 105 /* Exported macro ------------------------------------------------------------*/ 106 /** @defgroup PWREx_Exported_Macro PWREx Exported Macro 107 * @{ 108 */ 109 /** @brief Macros to enable or disable the Over drive mode. 110 */ 111 #define __HAL_PWR_OVERDRIVE_ENABLE() (PWR->CR1 |= (uint32_t)PWR_CR1_ODEN) 112 #define __HAL_PWR_OVERDRIVE_DISABLE() (PWR->CR1 &= (uint32_t)(~PWR_CR1_ODEN)) 113 114 /** @brief Macros to enable or disable the Over drive switching. 115 */ 116 #define __HAL_PWR_OVERDRIVESWITCHING_ENABLE() (PWR->CR1 |= (uint32_t)PWR_CR1_ODSWEN) 117 #define __HAL_PWR_OVERDRIVESWITCHING_DISABLE() (PWR->CR1 &= (uint32_t)(~PWR_CR1_ODSWEN)) 118 119 /** @brief Macros to enable or disable the Under drive mode. 120 * @note This mode is enabled only with STOP low power mode. 121 * In this mode, the 1.2V domain is preserved in reduced leakage mode. This 122 * mode is only available when the main regulator or the low power regulator 123 * is in low voltage mode. 124 * @note If the Under-drive mode was enabled, it is automatically disabled after 125 * exiting Stop mode. 126 * When the voltage regulator operates in Under-drive mode, an additional 127 * startup delay is induced when waking up from Stop mode. 128 */ 129 #define __HAL_PWR_UNDERDRIVE_ENABLE() (PWR->CR1 |= (uint32_t)PWR_CR1_UDEN) 130 #define __HAL_PWR_UNDERDRIVE_DISABLE() (PWR->CR1 &= (uint32_t)(~PWR_CR1_UDEN)) 131 132 /** @brief Check PWR flag is set or not. 133 * @param __FLAG__ specifies the flag to check. 134 * This parameter can be one of the following values: 135 * @arg PWR_FLAG_ODRDY: This flag indicates that the Over-drive mode 136 * is ready 137 * @arg PWR_FLAG_ODSWRDY: This flag indicates that the Over-drive mode 138 * switching is ready 139 * @arg PWR_FLAG_UDRDY: This flag indicates that the Under-drive mode 140 * is enabled in Stop mode 141 * @retval The new state of __FLAG__ (TRUE or FALSE). 142 */ 143 #define __HAL_PWR_GET_ODRUDR_FLAG(__FLAG__) ((PWR->CSR1 & (__FLAG__)) == (__FLAG__)) 144 145 /** @brief Clear the Under-Drive Ready flag. 146 */ 147 #define __HAL_PWR_CLEAR_ODRUDR_FLAG() (PWR->CSR1 |= (PWR_FLAG_UDRDY | PWR_CSR1_EIWUP)) 148 149 /** @brief Check Wake Up flag is set or not. 150 * @param __WUFLAG__ specifies the Wake Up flag to check. 151 * This parameter can be one of the following values: 152 * @arg PWR_WAKEUP_PIN_FLAG1: Wakeup Pin Flag for PA0 153 * @arg PWR_WAKEUP_PIN_FLAG2: Wakeup Pin Flag for PA2 154 * @arg PWR_WAKEUP_PIN_FLAG3: Wakeup Pin Flag for PC1 155 * @arg PWR_WAKEUP_PIN_FLAG4: Wakeup Pin Flag for PC13 156 * @arg PWR_WAKEUP_PIN_FLAG5: Wakeup Pin Flag for PI8 157 * @arg PWR_WAKEUP_PIN_FLAG6: Wakeup Pin Flag for PI11 158 */ 159 #define __HAL_PWR_GET_WAKEUP_FLAG(__WUFLAG__) (PWR->CSR2 & (__WUFLAG__)) 160 161 /** @brief Clear the WakeUp pins flags. 162 * @param __WUFLAG__ specifies the Wake Up pin flag to clear. 163 * This parameter can be one of the following values: 164 * @arg PWR_WAKEUP_PIN_FLAG1: Wakeup Pin Flag for PA0 165 * @arg PWR_WAKEUP_PIN_FLAG2: Wakeup Pin Flag for PA2 166 * @arg PWR_WAKEUP_PIN_FLAG3: Wakeup Pin Flag for PC1 167 * @arg PWR_WAKEUP_PIN_FLAG4: Wakeup Pin Flag for PC13 168 * @arg PWR_WAKEUP_PIN_FLAG5: Wakeup Pin Flag for PI8 169 * @arg PWR_WAKEUP_PIN_FLAG6: Wakeup Pin Flag for PI11 170 */ 171 #define __HAL_PWR_CLEAR_WAKEUP_FLAG(__WUFLAG__) (PWR->CR2 |= (__WUFLAG__)) 172 /** 173 * @} 174 */ 175 /* Exported functions --------------------------------------------------------*/ 176 /** @addtogroup PWREx_Exported_Functions PWREx Exported Functions 177 * @{ 178 */ 179 180 /** @addtogroup PWREx_Exported_Functions_Group1 181 * @{ 182 */ 183 uint32_t HAL_PWREx_GetVoltageRange(void); 184 HAL_StatusTypeDef HAL_PWREx_ControlVoltageScaling(uint32_t VoltageScaling); 185 186 void HAL_PWREx_EnableFlashPowerDown(void); 187 void HAL_PWREx_DisableFlashPowerDown(void); 188 HAL_StatusTypeDef HAL_PWREx_EnableBkUpReg(void); 189 HAL_StatusTypeDef HAL_PWREx_DisableBkUpReg(void); 190 191 void HAL_PWREx_EnableMainRegulatorLowVoltage(void); 192 void HAL_PWREx_DisableMainRegulatorLowVoltage(void); 193 void HAL_PWREx_EnableLowRegulatorLowVoltage(void); 194 void HAL_PWREx_DisableLowRegulatorLowVoltage(void); 195 196 HAL_StatusTypeDef HAL_PWREx_EnableOverDrive(void); 197 HAL_StatusTypeDef HAL_PWREx_DisableOverDrive(void); 198 HAL_StatusTypeDef HAL_PWREx_EnterUnderDriveSTOPMode(uint32_t Regulator, uint8_t STOPEntry); 199 200 /** 201 * @} 202 */ 203 204 /** 205 * @} 206 */ 207 /* Private types -------------------------------------------------------------*/ 208 /* Private variables ---------------------------------------------------------*/ 209 /* Private constants ---------------------------------------------------------*/ 210 /* Private macros ------------------------------------------------------------*/ 211 /** @defgroup PWREx_Private_Macros PWREx Private Macros 212 * @{ 213 */ 214 215 /** @defgroup PWREx_IS_PWR_Definitions PWREx Private macros to check input parameters 216 * @{ 217 */ 218 #define IS_PWR_REGULATOR_UNDERDRIVE(REGULATOR) (((REGULATOR) == PWR_MAINREGULATOR_UNDERDRIVE_ON) || \ 219 ((REGULATOR) == PWR_LOWPOWERREGULATOR_UNDERDRIVE_ON)) 220 #define IS_PWR_WAKEUP_PIN(__PIN__) (((__PIN__) == PWR_WAKEUP_PIN1) || \ 221 ((__PIN__) == PWR_WAKEUP_PIN2) || \ 222 ((__PIN__) == PWR_WAKEUP_PIN3) || \ 223 ((__PIN__) == PWR_WAKEUP_PIN4) || \ 224 ((__PIN__) == PWR_WAKEUP_PIN5) || \ 225 ((__PIN__) == PWR_WAKEUP_PIN6) || \ 226 ((__PIN__) == PWR_WAKEUP_PIN1_HIGH) || \ 227 ((__PIN__) == PWR_WAKEUP_PIN2_HIGH) || \ 228 ((__PIN__) == PWR_WAKEUP_PIN3_HIGH) || \ 229 ((__PIN__) == PWR_WAKEUP_PIN4_HIGH) || \ 230 ((__PIN__) == PWR_WAKEUP_PIN5_HIGH) || \ 231 ((__PIN__) == PWR_WAKEUP_PIN6_HIGH) || \ 232 ((__PIN__) == PWR_WAKEUP_PIN1_LOW) || \ 233 ((__PIN__) == PWR_WAKEUP_PIN2_LOW) || \ 234 ((__PIN__) == PWR_WAKEUP_PIN3_LOW) || \ 235 ((__PIN__) == PWR_WAKEUP_PIN4_LOW) || \ 236 ((__PIN__) == PWR_WAKEUP_PIN5_LOW) || \ 237 ((__PIN__) == PWR_WAKEUP_PIN6_LOW)) 238 /** 239 * @} 240 */ 241 242 /** 243 * @} 244 */ 245 246 /** 247 * @} 248 */ 249 250 /** 251 * @} 252 */ 253 254 #ifdef __cplusplus 255 } 256 #endif 257 258 259 #endif /* __STM32F7xx_HAL_PWR_EX_H */ 260 261