Hal Drivers for L4
Dependents: BSP OneHopeOnePrayer FINAL_AUDIO_RECORD AudioDemo
Fork of STM32L4xx_HAL_Driver by
stm32l4xx_hal_pwr.h
00001 /** 00002 ****************************************************************************** 00003 * @file stm32l4xx_hal_pwr.h 00004 * @author MCD Application Team 00005 * @version V1.1.0 00006 * @date 16-September-2015 00007 * @brief Header file of PWR HAL module. 00008 ****************************************************************************** 00009 * @attention 00010 * 00011 * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2> 00012 * 00013 * Redistribution and use in source and binary forms, with or without modification, 00014 * are permitted provided that the following conditions are met: 00015 * 1. Redistributions of source code must retain the above copyright notice, 00016 * this list of conditions and the following disclaimer. 00017 * 2. Redistributions in binary form must reproduce the above copyright notice, 00018 * this list of conditions and the following disclaimer in the documentation 00019 * and/or other materials provided with the distribution. 00020 * 3. Neither the name of STMicroelectronics nor the names of its contributors 00021 * may be used to endorse or promote products derived from this software 00022 * without specific prior written permission. 00023 * 00024 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00025 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00026 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00027 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 00028 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00029 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 00030 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00031 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00032 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00033 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00034 * 00035 ****************************************************************************** 00036 */ 00037 00038 /* Define to prevent recursive inclusion -------------------------------------*/ 00039 #ifndef __STM32L4xx_HAL_PWR_H 00040 #define __STM32L4xx_HAL_PWR_H 00041 00042 #ifdef __cplusplus 00043 extern "C" { 00044 #endif 00045 00046 /* Includes ------------------------------------------------------------------*/ 00047 #include "stm32l4xx_hal_def.h" 00048 00049 /** @addtogroup STM32L4xx_HAL_Driver 00050 * @{ 00051 */ 00052 00053 /** @addtogroup PWR 00054 * @{ 00055 */ 00056 00057 /* Exported types ------------------------------------------------------------*/ 00058 00059 /** @defgroup PWR_Exported_Types PWR Exported Types 00060 * @{ 00061 */ 00062 00063 /** 00064 * @brief PWR PVD configuration structure definition 00065 */ 00066 typedef struct 00067 { 00068 uint32_t PVDLevel; /*!< PVDLevel: Specifies the PVD detection level. 00069 This parameter can be a value of @ref PWR_PVD_detection_level. */ 00070 00071 uint32_t Mode; /*!< Mode: Specifies the operating mode for the selected pins. 00072 This parameter can be a value of @ref PWR_PVD_Mode. */ 00073 }PWR_PVDTypeDef; 00074 00075 00076 /** 00077 * @} 00078 */ 00079 00080 /* Exported constants --------------------------------------------------------*/ 00081 00082 /** @defgroup PWR_Exported_Constants PWR Exported Constants 00083 * @{ 00084 */ 00085 00086 00087 /** @defgroup PWR_PVD_detection_level Programmable Voltage Detection levels 00088 * @{ 00089 */ 00090 #define PWR_PVDLEVEL_0 PWR_CR2_PLS_LEV0 /*!< PVD threshold around 2.0 V */ 00091 #define PWR_PVDLEVEL_1 PWR_CR2_PLS_LEV1 /*!< PVD threshold around 2.2 V */ 00092 #define PWR_PVDLEVEL_2 PWR_CR2_PLS_LEV2 /*!< PVD threshold around 2.4 V */ 00093 #define PWR_PVDLEVEL_3 PWR_CR2_PLS_LEV3 /*!< PVD threshold around 2.5 V */ 00094 #define PWR_PVDLEVEL_4 PWR_CR2_PLS_LEV4 /*!< PVD threshold around 2.6 V */ 00095 #define PWR_PVDLEVEL_5 PWR_CR2_PLS_LEV5 /*!< PVD threshold around 2.8 V */ 00096 #define PWR_PVDLEVEL_6 PWR_CR2_PLS_LEV6 /*!< PVD threshold around 2.9 V */ 00097 #define PWR_PVDLEVEL_7 PWR_CR2_PLS_LEV7 /*!< External input analog voltage (compared internally to VREFINT) */ 00098 /** 00099 * @} 00100 */ 00101 00102 /** @defgroup PWR_PVD_Mode PWR PVD interrupt and event mode 00103 * @{ 00104 */ 00105 #define PWR_PVD_MODE_NORMAL ((uint32_t)0x00000000) /*!< Basic mode is used */ 00106 #define PWR_PVD_MODE_IT_RISING ((uint32_t)0x00010001) /*!< External Interrupt Mode with Rising edge trigger detection */ 00107 #define PWR_PVD_MODE_IT_FALLING ((uint32_t)0x00010002) /*!< External Interrupt Mode with Falling edge trigger detection */ 00108 #define PWR_PVD_MODE_IT_RISING_FALLING ((uint32_t)0x00010003) /*!< External Interrupt Mode with Rising/Falling edge trigger detection */ 00109 #define PWR_PVD_MODE_EVENT_RISING ((uint32_t)0x00020001) /*!< Event Mode with Rising edge trigger detection */ 00110 #define PWR_PVD_MODE_EVENT_FALLING ((uint32_t)0x00020002) /*!< Event Mode with Falling edge trigger detection */ 00111 #define PWR_PVD_MODE_EVENT_RISING_FALLING ((uint32_t)0x00020003) /*!< Event Mode with Rising/Falling edge trigger detection */ 00112 /** 00113 * @} 00114 */ 00115 00116 00117 00118 00119 /** @defgroup PWR_Regulator_state_in_SLEEP_STOP_mode PWR regulator mode 00120 * @{ 00121 */ 00122 #define PWR_MAINREGULATOR_ON ((uint32_t)0x00000000) /*!< Regulator in main mode */ 00123 #define PWR_LOWPOWERREGULATOR_ON PWR_CR1_LPR /*!< Regulator in low-power mode */ 00124 /** 00125 * @} 00126 */ 00127 00128 /** @defgroup PWR_SLEEP_mode_entry PWR SLEEP mode entry 00129 * @{ 00130 */ 00131 #define PWR_SLEEPENTRY_WFI ((uint8_t)0x01) /*!< Wait For Interruption instruction to enter Sleep mode */ 00132 #define PWR_SLEEPENTRY_WFE ((uint8_t)0x02) /*!< Wait For Event instruction to enter Sleep mode */ 00133 /** 00134 * @} 00135 */ 00136 00137 /** @defgroup PWR_STOP_mode_entry PWR STOP mode entry 00138 * @{ 00139 */ 00140 #define PWR_STOPENTRY_WFI ((uint8_t)0x01) /*!< Wait For Interruption instruction to enter Stop mode */ 00141 #define PWR_STOPENTRY_WFE ((uint8_t)0x02) /*!< Wait For Event instruction to enter Stop mode */ 00142 /** 00143 * @} 00144 */ 00145 00146 00147 /** @defgroup PWR_PVD_EXTI_LINE PWR PVD external interrupt line 00148 * @{ 00149 */ 00150 #define PWR_EXTI_LINE_PVD ((uint32_t)0x00010000) /*!< External interrupt line 16 Connected to the PVD EXTI Line */ 00151 /** 00152 * @} 00153 */ 00154 00155 /** @defgroup PWR_PVD_EVENT_LINE PWR PVD event line 00156 * @{ 00157 */ 00158 #define PWR_EVENT_LINE_PVD ((uint32_t)0x00010000) /*!< Event line 16 Connected to the PVD Event Line */ 00159 /** 00160 * @} 00161 */ 00162 00163 /** 00164 * @} 00165 */ 00166 00167 /* Exported macros -----------------------------------------------------------*/ 00168 /** @defgroup PWR_Exported_Macros PWR Exported Macros 00169 * @{ 00170 */ 00171 00172 /** @brief Check whether or not a specific PWR flag is set. 00173 * @param __FLAG__: specifies the flag to check. 00174 * This parameter can be one of the following values: 00175 * @arg PWR_FLAG_WUF1: Wake Up Flag 1. Indicates that a wakeup event 00176 * was received from the WKUP pin 1. 00177 * @arg PWR_FLAG_WUF2: Wake Up Flag 2. Indicates that a wakeup event 00178 * was received from the WKUP pin 2. 00179 * @arg PWR_FLAG_WUF3: Wake Up Flag 3. Indicates that a wakeup event 00180 * was received from the WKUP pin 3. 00181 * @arg PWR_FLAG_WUF4: Wake Up Flag 4. Indicates that a wakeup event 00182 * was received from the WKUP pin 4. 00183 * @arg PWR_FLAG_WUF5: Wake Up Flag 5. Indicates that a wakeup event 00184 * was received from the WKUP pin 5. 00185 * @arg PWR_FLAG_SB: StandBy Flag. Indicates that the system 00186 * entered StandBy mode. 00187 * @arg PWR_FLAG_WUFI: Wake-Up Flag Internal. Set when a wakeup is detected on 00188 * the internal wakeup line. 00189 * @arg PWR_FLAG_REGLPS: Low Power Regulator Started. Indicates whether or not the 00190 * low-power regulator is ready. 00191 * @arg PWR_FLAG_REGLPF: Low Power Regulator Flag. Indicates whether the 00192 * regulator is ready in main mode or is in low-power mode. 00193 * @arg PWR_FLAG_VOSF: Voltage Scaling Flag. Indicates whether the regulator is ready 00194 * in the selected voltage range or is still changing to the required voltage level. 00195 * @arg PWR_FLAG_PVDO: Power Voltage Detector Output. Indicates whether VDD voltage is 00196 * below or above the selected PVD threshold. 00197 * @arg PWR_FLAG_PVMO1: Peripheral Voltage Monitoring Output 1. Indicates whether VDDUSB voltage is 00198 * is below or above PVM1 threshold (applicable when USB feature is supported). 00199 * @arg PWR_FLAG_PVMO2: Peripheral Voltage Monitoring Output 2. Indicates whether VDDIO2 voltage is 00200 * is below or above PVM2 threshold (applicable when VDDIO2 is present on device). 00201 * @arg PWR_FLAG_PVMO3: Peripheral Voltage Monitoring Output 3. Indicates whether VDDA voltage is 00202 * is below or above PVM3 threshold. 00203 * @arg PWR_FLAG_PVMO4: Peripheral Voltage Monitoring Output 4. Indicates whether VDDA voltage is 00204 * is below or above PVM4 threshold. 00205 * 00206 * @retval The new state of __FLAG__ (TRUE or FALSE). 00207 */ 00208 #define __HAL_PWR_GET_FLAG(__FLAG__) ( ((((uint8_t)(__FLAG__)) >> 5U) == 1) ?\ 00209 (PWR->SR1 & (1U << ((__FLAG__) & 31U))) :\ 00210 (PWR->SR2 & (1U << ((__FLAG__) & 31U))) ) 00211 00212 /** @brief Clear a specific PWR flag. 00213 * @param __FLAG__: specifies the flag to clear. 00214 * This parameter can be one of the following values: 00215 * @arg PWR_FLAG_WUF1: Wake Up Flag 1. Indicates that a wakeup event 00216 * was received from the WKUP pin 1. 00217 * @arg PWR_FLAG_WUF2: Wake Up Flag 2. Indicates that a wakeup event 00218 * was received from the WKUP pin 2. 00219 * @arg PWR_FLAG_WUF3: Wake Up Flag 3. Indicates that a wakeup event 00220 * was received from the WKUP pin 3. 00221 * @arg PWR_FLAG_WUF4: Wake Up Flag 4. Indicates that a wakeup event 00222 * was received from the WKUP pin 4. 00223 * @arg PWR_FLAG_WUF5: Wake Up Flag 5. Indicates that a wakeup event 00224 * was received from the WKUP pin 5. 00225 * @arg PWR_FLAG_WU: Encompasses all five Wake Up Flags. 00226 * @arg PWR_FLAG_SB: Standby Flag. Indicates that the system 00227 * entered Standby mode. 00228 * @retval None 00229 */ 00230 #define __HAL_PWR_CLEAR_FLAG(__FLAG__) ( (((uint8_t)(__FLAG__)) == PWR_FLAG_WU) ?\ 00231 (PWR->SCR = (__FLAG__)) :\ 00232 (PWR->SCR = (1U << ((__FLAG__) & 31U))) ) 00233 /** 00234 * @brief Enable the PVD Extended Interrupt Line. 00235 * @retval None 00236 */ 00237 #define __HAL_PWR_PVD_EXTI_ENABLE_IT() SET_BIT(EXTI->IMR1, PWR_EXTI_LINE_PVD) 00238 00239 /** 00240 * @brief Disable the PVD Extended Interrupt Line. 00241 * @retval None 00242 */ 00243 #define __HAL_PWR_PVD_EXTI_DISABLE_IT() CLEAR_BIT(EXTI->IMR1, PWR_EXTI_LINE_PVD) 00244 00245 /** 00246 * @brief Enable the PVD Event Line. 00247 * @retval None 00248 */ 00249 #define __HAL_PWR_PVD_EXTI_ENABLE_EVENT() SET_BIT(EXTI->EMR1, PWR_EVENT_LINE_PVD) 00250 00251 /** 00252 * @brief Disable the PVD Event Line. 00253 * @retval None 00254 */ 00255 #define __HAL_PWR_PVD_EXTI_DISABLE_EVENT() CLEAR_BIT(EXTI->EMR1, PWR_EVENT_LINE_PVD) 00256 00257 /** 00258 * @brief Enable the PVD Extended Interrupt Rising Trigger. 00259 * @retval None 00260 */ 00261 #define __HAL_PWR_PVD_EXTI_ENABLE_RISING_EDGE() SET_BIT(EXTI->RTSR1, PWR_EXTI_LINE_PVD) 00262 00263 /** 00264 * @brief Disable the PVD Extended Interrupt Rising Trigger. 00265 * @retval None 00266 */ 00267 #define __HAL_PWR_PVD_EXTI_DISABLE_RISING_EDGE() CLEAR_BIT(EXTI->RTSR1, PWR_EXTI_LINE_PVD) 00268 00269 /** 00270 * @brief Enable the PVD Extended Interrupt Falling Trigger. 00271 * @retval None 00272 */ 00273 #define __HAL_PWR_PVD_EXTI_ENABLE_FALLING_EDGE() SET_BIT(EXTI->FTSR1, PWR_EXTI_LINE_PVD) 00274 00275 00276 /** 00277 * @brief Disable the PVD Extended Interrupt Falling Trigger. 00278 * @retval None 00279 */ 00280 #define __HAL_PWR_PVD_EXTI_DISABLE_FALLING_EDGE() CLEAR_BIT(EXTI->FTSR1, PWR_EXTI_LINE_PVD) 00281 00282 00283 /** 00284 * @brief Enable the PVD Extended Interrupt Rising & Falling Trigger. 00285 * @retval None 00286 */ 00287 #define __HAL_PWR_PVD_EXTI_ENABLE_RISING_FALLING_EDGE() \ 00288 do { \ 00289 __HAL_PWR_PVD_EXTI_ENABLE_RISING_EDGE(); \ 00290 __HAL_PWR_PVD_EXTI_ENABLE_FALLING_EDGE(); \ 00291 } while(0) 00292 00293 /** 00294 * @brief Disable the PVD Extended Interrupt Rising & Falling Trigger. 00295 * @retval None 00296 */ 00297 #define __HAL_PWR_PVD_EXTI_DISABLE_RISING_FALLING_EDGE() \ 00298 do { \ 00299 __HAL_PWR_PVD_EXTI_DISABLE_RISING_EDGE(); \ 00300 __HAL_PWR_PVD_EXTI_DISABLE_FALLING_EDGE(); \ 00301 } while(0) 00302 00303 /** 00304 * @brief Generate a Software interrupt on selected EXTI line. 00305 * @retval None 00306 */ 00307 #define __HAL_PWR_PVD_EXTI_GENERATE_SWIT() SET_BIT(EXTI->SWIER1, PWR_EXTI_LINE_PVD) 00308 00309 /** 00310 * @brief Check whether or not the PVD EXTI interrupt flag is set. 00311 * @retval EXTI PVD Line Status. 00312 */ 00313 #define __HAL_PWR_PVD_EXTI_GET_FLAG() (EXTI->PR1 & PWR_EXTI_LINE_PVD) 00314 00315 /** 00316 * @brief Clear the PVD EXTI interrupt flag. 00317 * @retval None 00318 */ 00319 #define __HAL_PWR_PVD_EXTI_CLEAR_FLAG() WRITE_REG(EXTI->PR1, PWR_EXTI_LINE_PVD) 00320 00321 /** 00322 * @} 00323 */ 00324 00325 00326 /* Private macros --------------------------------------------------------*/ 00327 /** @addtogroup PWR_Private_Macros PWR Private Macros 00328 * @{ 00329 */ 00330 00331 #define IS_PWR_PVD_LEVEL(LEVEL) (((LEVEL) == PWR_PVDLEVEL_0) || ((LEVEL) == PWR_PVDLEVEL_1)|| \ 00332 ((LEVEL) == PWR_PVDLEVEL_2) || ((LEVEL) == PWR_PVDLEVEL_3)|| \ 00333 ((LEVEL) == PWR_PVDLEVEL_4) || ((LEVEL) == PWR_PVDLEVEL_5)|| \ 00334 ((LEVEL) == PWR_PVDLEVEL_6) || ((LEVEL) == PWR_PVDLEVEL_7)) 00335 00336 #define IS_PWR_PVD_MODE(MODE) (((MODE) == PWR_PVD_MODE_NORMAL) ||\ 00337 ((MODE) == PWR_PVD_MODE_IT_RISING) ||\ 00338 ((MODE) == PWR_PVD_MODE_IT_FALLING) ||\ 00339 ((MODE) == PWR_PVD_MODE_IT_RISING_FALLING) ||\ 00340 ((MODE) == PWR_PVD_MODE_EVENT_RISING) ||\ 00341 ((MODE) == PWR_PVD_MODE_EVENT_FALLING) ||\ 00342 ((MODE) == PWR_PVD_MODE_EVENT_RISING_FALLING)) 00343 00344 #define IS_PWR_REGULATOR(REGULATOR) (((REGULATOR) == PWR_MAINREGULATOR_ON) || \ 00345 ((REGULATOR) == PWR_LOWPOWERREGULATOR_ON)) 00346 00347 #define IS_PWR_SLEEP_ENTRY(ENTRY) (((ENTRY) == PWR_SLEEPENTRY_WFI) || ((ENTRY) == PWR_SLEEPENTRY_WFE)) 00348 00349 #define IS_PWR_STOP_ENTRY(ENTRY) (((ENTRY) == PWR_STOPENTRY_WFI) || ((ENTRY) == PWR_STOPENTRY_WFE) ) 00350 00351 /** 00352 * @} 00353 */ 00354 00355 /* Include PWR HAL Extended module */ 00356 #include "stm32l4xx_hal_pwr_ex.h" 00357 00358 /* Exported functions --------------------------------------------------------*/ 00359 00360 /** @addtogroup PWR_Exported_Functions PWR Exported Functions 00361 * @{ 00362 */ 00363 00364 /** @addtogroup PWR_Exported_Functions_Group1 Initialization and de-initialization functions 00365 * @{ 00366 */ 00367 00368 /* Initialization and de-initialization functions *******************************/ 00369 void HAL_PWR_DeInit(void); 00370 void HAL_PWR_EnableBkUpAccess(void); 00371 void HAL_PWR_DisableBkUpAccess(void); 00372 00373 /** 00374 * @} 00375 */ 00376 00377 /** @addtogroup PWR_Exported_Functions_Group2 Peripheral Control functions 00378 * @{ 00379 */ 00380 00381 /* Peripheral Control functions ************************************************/ 00382 HAL_StatusTypeDef HAL_PWR_ConfigPVD(PWR_PVDTypeDef *sConfigPVD); 00383 void HAL_PWR_EnablePVD(void); 00384 void HAL_PWR_DisablePVD(void); 00385 00386 00387 /* WakeUp pins configuration functions ****************************************/ 00388 void HAL_PWR_EnableWakeUpPin(uint32_t WakeUpPinPolarity); 00389 void HAL_PWR_DisableWakeUpPin(uint32_t WakeUpPinx); 00390 00391 /* Low Power modes configuration functions ************************************/ 00392 void HAL_PWR_EnterSLEEPMode(uint32_t Regulator, uint8_t SLEEPEntry); 00393 void HAL_PWR_EnterSTOPMode(uint32_t Regulator, uint8_t STOPEntry); 00394 void HAL_PWR_EnterSTANDBYMode(void); 00395 00396 void HAL_PWR_EnableSleepOnExit(void); 00397 void HAL_PWR_DisableSleepOnExit(void); 00398 void HAL_PWR_EnableSEVOnPend(void); 00399 void HAL_PWR_DisableSEVOnPend(void); 00400 00401 void HAL_PWR_PVDCallback(void); 00402 00403 00404 /** 00405 * @} 00406 */ 00407 00408 /** 00409 * @} 00410 */ 00411 00412 /** 00413 * @} 00414 */ 00415 00416 /** 00417 * @} 00418 */ 00419 00420 #ifdef __cplusplus 00421 } 00422 #endif 00423 00424 00425 #endif /* __STM32L4xx_HAL_PWR_H */ 00426 00427 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 00428
Generated on Tue Jul 12 2022 11:35:14 by 1.7.2