1 /** 2 ****************************************************************************** 3 * @file stm32f3xx_hal_pwr_ex.h 4 * @author MCD Application Team 5 * @brief Header file of PWR HAL Extended module. 6 ****************************************************************************** 7 * @attention 8 * 9 * Copyright (c) 2016 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 __STM32F3xx_HAL_PWR_EX_H 21 #define __STM32F3xx_HAL_PWR_EX_H 22 23 #ifdef __cplusplus 24 extern "C" { 25 #endif 26 27 /* Includes ------------------------------------------------------------------*/ 28 #include "stm32f3xx_hal_def.h" 29 30 /** @addtogroup STM32F3xx_HAL_Driver 31 * @{ 32 */ 33 34 /** @addtogroup PWREx 35 * @{ 36 */ 37 38 /* Exported types ------------------------------------------------------------*/ 39 40 /** @defgroup PWREx_Exported_Types PWR Extended Exported Types 41 * @{ 42 */ 43 #if defined(STM32F302xE) || defined(STM32F303xE) || \ 44 defined(STM32F302xC) || defined(STM32F303xC) || \ 45 defined(STM32F303x8) || defined(STM32F334x8) || \ 46 defined(STM32F301x8) || defined(STM32F302x8) || \ 47 defined(STM32F373xC) 48 /** 49 * @brief PWR PVD configuration structure definition 50 */ 51 typedef struct 52 { 53 uint32_t PVDLevel; /*!< PVDLevel: Specifies the PVD detection level 54 This parameter can be a value of @ref PWREx_PVD_detection_level */ 55 56 uint32_t Mode; /*!< Mode: Specifies the operating mode for the selected pins. 57 This parameter can be a value of @ref PWREx_PVD_Mode */ 58 }PWR_PVDTypeDef; 59 #endif /* STM32F302xE || STM32F303xE || */ 60 /* STM32F302xC || STM32F303xC || */ 61 /* STM32F303x8 || STM32F334x8 || */ 62 /* STM32F301x8 || STM32F302x8 || */ 63 /* STM32F373xC */ 64 65 /** 66 * @} 67 */ 68 69 /* Exported constants --------------------------------------------------------*/ 70 /** @defgroup PWREx_Exported_Constants PWR Extended Exported Constants 71 * @{ 72 */ 73 74 #if defined(STM32F302xE) || defined(STM32F303xE) || \ 75 defined(STM32F302xC) || defined(STM32F303xC) || \ 76 defined(STM32F303x8) || defined(STM32F334x8) || \ 77 defined(STM32F301x8) || defined(STM32F302x8) || \ 78 defined(STM32F373xC) 79 80 /** @defgroup PWREx_PVD_detection_level PWR Extended PVD detection level 81 * @{ 82 */ 83 #define PWR_PVDLEVEL_0 PWR_CR_PLS_LEV0 /*!< PVD threshold around 2.2 V */ 84 #define PWR_PVDLEVEL_1 PWR_CR_PLS_LEV1 /*!< PVD threshold around 2.3 V */ 85 #define PWR_PVDLEVEL_2 PWR_CR_PLS_LEV2 /*!< PVD threshold around 2.4 V */ 86 #define PWR_PVDLEVEL_3 PWR_CR_PLS_LEV3 /*!< PVD threshold around 2.5 V */ 87 #define PWR_PVDLEVEL_4 PWR_CR_PLS_LEV4 /*!< PVD threshold around 2.6 V */ 88 #define PWR_PVDLEVEL_5 PWR_CR_PLS_LEV5 /*!< PVD threshold around 2.7 V */ 89 #define PWR_PVDLEVEL_6 PWR_CR_PLS_LEV6 /*!< PVD threshold around 2.8 V */ 90 #define PWR_PVDLEVEL_7 PWR_CR_PLS_LEV7 /*!< PVD threshold around 2.9 V */ 91 /** 92 * @} 93 */ 94 95 /** @defgroup PWREx_PVD_Mode PWR Extended PVD Mode 96 * @{ 97 */ 98 #define PWR_PVD_MODE_NORMAL (0x00000000U) /*!< Basic mode is used */ 99 #define PWR_PVD_MODE_IT_RISING (0x00010001U) /*!< External Interrupt Mode with Rising edge trigger detection */ 100 #define PWR_PVD_MODE_IT_FALLING (0x00010002U) /*!< External Interrupt Mode with Falling edge trigger detection */ 101 #define PWR_PVD_MODE_IT_RISING_FALLING (0x00010003U) /*!< External Interrupt Mode with Rising/Falling edge trigger detection */ 102 #define PWR_PVD_MODE_EVENT_RISING (0x00020001U) /*!< Event Mode with Rising edge trigger detection */ 103 #define PWR_PVD_MODE_EVENT_FALLING (0x00020002U) /*!< Event Mode with Falling edge trigger detection */ 104 #define PWR_PVD_MODE_EVENT_RISING_FALLING (0x00020003U) /*!< Event Mode with Rising/Falling edge trigger detection */ 105 /** 106 * @} 107 */ 108 109 #define PWR_EXTI_LINE_PVD EXTI_IMR_MR16 /*!< External interrupt line 16 Connected to the PVD EXTI Line */ 110 111 #endif /* STM32F302xE || STM32F303xE || */ 112 /* STM32F302xC || STM32F303xC || */ 113 /* STM32F303x8 || STM32F334x8 || */ 114 /* STM32F301x8 || STM32F302x8 || */ 115 /* STM32F373xC */ 116 117 #if defined(STM32F373xC) || defined(STM32F378xx) 118 /** @defgroup PWREx_SDADC_ANALOGx PWR Extended SDADC ANALOGx 119 * @{ 120 */ 121 #define PWR_SDADC_ANALOG1 ((uint32_t)PWR_CR_ENSD1) /*!< Enable SDADC1 */ 122 #define PWR_SDADC_ANALOG2 ((uint32_t)PWR_CR_ENSD2) /*!< Enable SDADC2 */ 123 #define PWR_SDADC_ANALOG3 ((uint32_t)PWR_CR_ENSD3) /*!< Enable SDADC3 */ 124 /** 125 * @} 126 */ 127 #endif /* STM32F373xC || STM32F378xx */ 128 129 /** 130 * @} 131 */ 132 133 /* Exported macro ------------------------------------------------------------*/ 134 /** @defgroup PWREx_Exported_Macros PWR Extended Exported Macros 135 * @{ 136 */ 137 138 #if defined(STM32F302xE) || defined(STM32F303xE) || \ 139 defined(STM32F302xC) || defined(STM32F303xC) || \ 140 defined(STM32F303x8) || defined(STM32F334x8) || \ 141 defined(STM32F301x8) || defined(STM32F302x8) || \ 142 defined(STM32F373xC) 143 144 /** 145 * @brief Enable interrupt on PVD Exti Line 16. 146 * @retval None. 147 */ 148 #define __HAL_PWR_PVD_EXTI_ENABLE_IT() (EXTI->IMR |= (PWR_EXTI_LINE_PVD)) 149 150 /** 151 * @brief Disable interrupt on PVD Exti Line 16. 152 * @retval None. 153 */ 154 #define __HAL_PWR_PVD_EXTI_DISABLE_IT() (EXTI->IMR &= ~(PWR_EXTI_LINE_PVD)) 155 156 /** 157 * @brief Generate a Software interrupt on selected EXTI line. 158 * @retval None. 159 */ 160 #define __HAL_PWR_PVD_EXTI_GENERATE_SWIT() (EXTI->SWIER |= (PWR_EXTI_LINE_PVD)) 161 162 /** 163 * @brief Enable event on PVD Exti Line 16. 164 * @retval None. 165 */ 166 #define __HAL_PWR_PVD_EXTI_ENABLE_EVENT() (EXTI->EMR |= (PWR_EXTI_LINE_PVD)) 167 168 /** 169 * @brief Disable event on PVD Exti Line 16. 170 * @retval None. 171 */ 172 #define __HAL_PWR_PVD_EXTI_DISABLE_EVENT() (EXTI->EMR &= ~(PWR_EXTI_LINE_PVD)) 173 174 /** 175 * @brief Disable the PVD Extended Interrupt Rising Trigger. 176 * @retval None. 177 */ 178 #define __HAL_PWR_PVD_EXTI_DISABLE_RISING_EDGE() CLEAR_BIT(EXTI->RTSR, PWR_EXTI_LINE_PVD) 179 180 /** 181 * @brief Disable the PVD Extended Interrupt Falling Trigger. 182 * @retval None. 183 */ 184 #define __HAL_PWR_PVD_EXTI_DISABLE_FALLING_EDGE() CLEAR_BIT(EXTI->FTSR, PWR_EXTI_LINE_PVD) 185 186 /** 187 * @brief Disable the PVD Extended Interrupt Rising & Falling Trigger. 188 * @retval None 189 */ 190 #define __HAL_PWR_PVD_EXTI_DISABLE_RISING_FALLING_EDGE() __HAL_PWR_PVD_EXTI_DISABLE_RISING_EDGE();__HAL_PWR_PVD_EXTI_DISABLE_FALLING_EDGE(); 191 192 /** 193 * @brief PVD EXTI line configuration: set falling edge trigger. 194 * @retval None. 195 */ 196 #define __HAL_PWR_PVD_EXTI_ENABLE_FALLING_EDGE() EXTI->FTSR |= (PWR_EXTI_LINE_PVD) 197 198 /** 199 * @brief PVD EXTI line configuration: set rising edge trigger. 200 * @retval None. 201 */ 202 #define __HAL_PWR_PVD_EXTI_ENABLE_RISING_EDGE() EXTI->RTSR |= (PWR_EXTI_LINE_PVD) 203 204 /** 205 * @brief Enable the PVD Extended Interrupt Rising & Falling Trigger. 206 * @retval None 207 */ 208 #define __HAL_PWR_PVD_EXTI_ENABLE_RISING_FALLING_EDGE() __HAL_PWR_PVD_EXTI_ENABLE_RISING_EDGE();__HAL_PWR_PVD_EXTI_ENABLE_FALLING_EDGE(); 209 210 /** 211 * @brief Check whether the specified PVD EXTI interrupt flag is set or not. 212 * @retval EXTI PVD Line Status. 213 */ 214 #define __HAL_PWR_PVD_EXTI_GET_FLAG() (EXTI->PR & (PWR_EXTI_LINE_PVD)) 215 216 /** 217 * @brief Clear the PVD EXTI flag. 218 * @retval None. 219 */ 220 #define __HAL_PWR_PVD_EXTI_CLEAR_FLAG() (EXTI->PR = (PWR_EXTI_LINE_PVD)) 221 222 #endif /* STM32F302xE || STM32F303xE || */ 223 /* STM32F302xC || STM32F303xC || */ 224 /* STM32F303x8 || STM32F334x8 || */ 225 /* STM32F301x8 || STM32F302x8 || */ 226 /* STM32F373xC */ 227 228 /** 229 * @} 230 */ 231 232 /* Private macros --------------------------------------------------------*/ 233 /** @addtogroup PWREx_Private_Macros PWR Extended Private Macros 234 * @{ 235 */ 236 237 #if defined(STM32F302xE) || defined(STM32F303xE) || \ 238 defined(STM32F302xC) || defined(STM32F303xC) || \ 239 defined(STM32F303x8) || defined(STM32F334x8) || \ 240 defined(STM32F301x8) || defined(STM32F302x8) || \ 241 defined(STM32F373xC) 242 #define IS_PWR_PVD_LEVEL(LEVEL) (((LEVEL) == PWR_PVDLEVEL_0) || ((LEVEL) == PWR_PVDLEVEL_1)|| \ 243 ((LEVEL) == PWR_PVDLEVEL_2) || ((LEVEL) == PWR_PVDLEVEL_3)|| \ 244 ((LEVEL) == PWR_PVDLEVEL_4) || ((LEVEL) == PWR_PVDLEVEL_5)|| \ 245 ((LEVEL) == PWR_PVDLEVEL_6) || ((LEVEL) == PWR_PVDLEVEL_7)) 246 247 #define IS_PWR_PVD_MODE(MODE) (((MODE) == PWR_PVD_MODE_IT_RISING)|| ((MODE) == PWR_PVD_MODE_IT_FALLING) || \ 248 ((MODE) == PWR_PVD_MODE_IT_RISING_FALLING) || ((MODE) == PWR_PVD_MODE_EVENT_RISING) || \ 249 ((MODE) == PWR_PVD_MODE_EVENT_FALLING) || ((MODE) == PWR_PVD_MODE_EVENT_RISING_FALLING) || \ 250 ((MODE) == PWR_PVD_MODE_NORMAL)) 251 #endif /* STM32F302xE || STM32F303xE || */ 252 /* STM32F302xC || STM32F303xC || */ 253 /* STM32F303x8 || STM32F334x8 || */ 254 /* STM32F301x8 || STM32F302x8 || */ 255 /* STM32F373xC */ 256 257 #if defined(STM32F373xC) || defined(STM32F378xx) 258 #define IS_PWR_SDADC_ANALOG(SDADC) (((SDADC) == PWR_SDADC_ANALOG1) || \ 259 ((SDADC) == PWR_SDADC_ANALOG2) || \ 260 ((SDADC) == PWR_SDADC_ANALOG3)) 261 #endif /* STM32F373xC || STM32F378xx */ 262 263 264 /** 265 * @} 266 */ 267 268 /* Exported functions --------------------------------------------------------*/ 269 270 /** @addtogroup PWREx_Exported_Functions PWR Extended Exported Functions 271 * @{ 272 */ 273 274 /** @addtogroup PWREx_Exported_Functions_Group1 Peripheral Extended Control Functions 275 * @{ 276 */ 277 /* Peripheral Extended control functions **************************************/ 278 #if defined(STM32F302xE) || defined(STM32F303xE) || \ 279 defined(STM32F302xC) || defined(STM32F303xC) || \ 280 defined(STM32F303x8) || defined(STM32F334x8) || \ 281 defined(STM32F301x8) || defined(STM32F302x8) || \ 282 defined(STM32F373xC) 283 void HAL_PWR_ConfigPVD(PWR_PVDTypeDef *sConfigPVD); 284 void HAL_PWR_EnablePVD(void); 285 void HAL_PWR_DisablePVD(void); 286 void HAL_PWR_PVD_IRQHandler(void); 287 void HAL_PWR_PVDCallback(void); 288 #endif /* STM32F302xE || STM32F303xE || */ 289 /* STM32F302xC || STM32F303xC || */ 290 /* STM32F303x8 || STM32F334x8 || */ 291 /* STM32F301x8 || STM32F302x8 || */ 292 /* STM32F373xC */ 293 294 #if defined(STM32F373xC) || defined(STM32F378xx) 295 void HAL_PWREx_EnableSDADC(uint32_t Analogx); 296 void HAL_PWREx_DisableSDADC(uint32_t Analogx); 297 #endif /* STM32F373xC || STM32F378xx */ 298 299 /** 300 * @} 301 */ 302 303 /** 304 * @} 305 */ 306 307 /** 308 * @} 309 */ 310 311 /** 312 * @} 313 */ 314 315 #ifdef __cplusplus 316 } 317 #endif 318 319 #endif /* __STM32F3xx_HAL_PWR_EX_H */ 320