2 ******************************************************************************
\r
3 * @file stm32f7xx_hal_pwr.h
\r
4 * @author MCD Application Team
\r
6 * @date 06-March-2015
\r
7 * @brief Header file of PWR HAL module.
\r
8 ******************************************************************************
\r
11 * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
\r
13 * Redistribution and use in source and binary forms, with or without modification,
\r
14 * are permitted provided that the following conditions are met:
\r
15 * 1. Redistributions of source code must retain the above copyright notice,
\r
16 * this list of conditions and the following disclaimer.
\r
17 * 2. Redistributions in binary form must reproduce the above copyright notice,
\r
18 * this list of conditions and the following disclaimer in the documentation
\r
19 * and/or other materials provided with the distribution.
\r
20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
\r
21 * may be used to endorse or promote products derived from this software
\r
22 * without specific prior written permission.
\r
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
\r
25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
\r
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
\r
27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
\r
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
\r
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
\r
30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
\r
31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
\r
32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
\r
33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\r
35 ******************************************************************************
\r
38 /* Define to prevent recursive inclusion -------------------------------------*/
\r
39 #ifndef __STM32F7xx_HAL_PWR_H
\r
40 #define __STM32F7xx_HAL_PWR_H
\r
46 /* Includes ------------------------------------------------------------------*/
\r
47 #include "stm32f7xx_hal_def.h"
\r
49 /** @addtogroup STM32F7xx_HAL_Driver
\r
57 /* Exported types ------------------------------------------------------------*/
\r
59 /** @defgroup PWR_Exported_Types PWR Exported Types
\r
64 * @brief PWR PVD configuration structure definition
\r
68 uint32_t PVDLevel; /*!< PVDLevel: Specifies the PVD detection level.
\r
69 This parameter can be a value of @ref PWR_PVD_detection_level */
\r
71 uint32_t Mode; /*!< Mode: Specifies the operating mode for the selected pins.
\r
72 This parameter can be a value of @ref PWR_PVD_Mode */
\r
79 /* Exported constants --------------------------------------------------------*/
\r
80 /** @defgroup PWR_Exported_Constants PWR Exported Constants
\r
84 /** @defgroup PWR_PVD_detection_level PWR PVD detection level
\r
87 #define PWR_PVDLEVEL_0 PWR_CR1_PLS_LEV0
\r
88 #define PWR_PVDLEVEL_1 PWR_CR1_PLS_LEV1
\r
89 #define PWR_PVDLEVEL_2 PWR_CR1_PLS_LEV2
\r
90 #define PWR_PVDLEVEL_3 PWR_CR1_PLS_LEV3
\r
91 #define PWR_PVDLEVEL_4 PWR_CR1_PLS_LEV4
\r
92 #define PWR_PVDLEVEL_5 PWR_CR1_PLS_LEV5
\r
93 #define PWR_PVDLEVEL_6 PWR_CR1_PLS_LEV6
\r
94 #define PWR_PVDLEVEL_7 PWR_CR1_PLS_LEV7/* External input analog voltage
\r
95 (Compare internally to VREFINT) */
\r
101 /** @defgroup PWR_PVD_Mode PWR PVD Mode
\r
104 #define PWR_PVD_MODE_NORMAL ((uint32_t)0x00000000) /*!< basic mode is used */
\r
105 #define PWR_PVD_MODE_IT_RISING ((uint32_t)0x00010001) /*!< External Interrupt Mode with Rising edge trigger detection */
\r
106 #define PWR_PVD_MODE_IT_FALLING ((uint32_t)0x00010002) /*!< External Interrupt Mode with Falling edge trigger detection */
\r
107 #define PWR_PVD_MODE_IT_RISING_FALLING ((uint32_t)0x00010003) /*!< External Interrupt Mode with Rising/Falling edge trigger detection */
\r
108 #define PWR_PVD_MODE_EVENT_RISING ((uint32_t)0x00020001) /*!< Event Mode with Rising edge trigger detection */
\r
109 #define PWR_PVD_MODE_EVENT_FALLING ((uint32_t)0x00020002) /*!< Event Mode with Falling edge trigger detection */
\r
110 #define PWR_PVD_MODE_EVENT_RISING_FALLING ((uint32_t)0x00020003) /*!< Event Mode with Rising/Falling edge trigger detection */
\r
115 /** @defgroup PWR_Regulator_state_in_STOP_mode PWR Regulator state in SLEEP/STOP mode
\r
118 #define PWR_MAINREGULATOR_ON ((uint32_t)0x00000000)
\r
119 #define PWR_LOWPOWERREGULATOR_ON PWR_CR1_LPDS
\r
124 /** @defgroup PWR_SLEEP_mode_entry PWR SLEEP mode entry
\r
127 #define PWR_SLEEPENTRY_WFI ((uint8_t)0x01)
\r
128 #define PWR_SLEEPENTRY_WFE ((uint8_t)0x02)
\r
133 /** @defgroup PWR_STOP_mode_entry PWR STOP mode entry
\r
136 #define PWR_STOPENTRY_WFI ((uint8_t)0x01)
\r
137 #define PWR_STOPENTRY_WFE ((uint8_t)0x02)
\r
142 /** @defgroup PWR_Regulator_Voltage_Scale PWR Regulator Voltage Scale
\r
145 #define PWR_REGULATOR_VOLTAGE_SCALE1 PWR_CR1_VOS
\r
146 #define PWR_REGULATOR_VOLTAGE_SCALE2 PWR_CR1_VOS_1
\r
147 #define PWR_REGULATOR_VOLTAGE_SCALE3 PWR_CR1_VOS_0
\r
152 /** @defgroup PWR_Flag PWR Flag
\r
155 #define PWR_FLAG_WU PWR_CSR1_WUIF
\r
156 #define PWR_FLAG_SB PWR_CSR1_SBF
\r
157 #define PWR_FLAG_PVDO PWR_CSR1_PVDO
\r
158 #define PWR_FLAG_BRR PWR_CSR1_BRR
\r
159 #define PWR_FLAG_VOSRDY PWR_CSR1_VOSRDY
\r
168 /* Exported macro ------------------------------------------------------------*/
\r
169 /** @defgroup PWR_Exported_Macro PWR Exported Macro
\r
173 /** @brief macros configure the main internal regulator output voltage.
\r
174 * @param __REGULATOR__: specifies the regulator output voltage to achieve
\r
175 * a tradeoff between performance and power consumption when the device does
\r
176 * not operate at the maximum frequency (refer to the datasheets for more details).
\r
177 * This parameter can be one of the following values:
\r
178 * @arg PWR_REGULATOR_VOLTAGE_SCALE1: Regulator voltage output Scale 1 mode
\r
179 * @arg PWR_REGULATOR_VOLTAGE_SCALE2: Regulator voltage output Scale 2 mode
\r
180 * @arg PWR_REGULATOR_VOLTAGE_SCALE3: Regulator voltage output Scale 3 mode
\r
183 #define __HAL_PWR_VOLTAGESCALING_CONFIG(__REGULATOR__) do { \
\r
184 __IO uint32_t tmpreg; \
\r
185 MODIFY_REG(PWR->CR1, PWR_CR1_VOS, (__REGULATOR__)); \
\r
186 /* Delay after an RCC peripheral clock enabling */ \
\r
187 tmpreg = READ_BIT(PWR->CR1, PWR_CR1_VOS); \
\r
191 /** @brief Check PWR flag is set or not.
\r
192 * @param __FLAG__: specifies the flag to check.
\r
193 * This parameter can be one of the following values:
\r
194 * @arg PWR_FLAG_WU: Wake Up flag. This flag indicates that a wakeup event
\r
195 * was received on the internal wakeup line in standby mode (RTC alarm (Alarm A or Alarm B),
\r
196 * RTC Tamper event, RTC TimeStamp event or RTC Wakeup)).
\r
197 * @arg PWR_FLAG_SB: StandBy flag. This flag indicates that the system was
\r
198 * resumed from StandBy mode.
\r
199 * @arg PWR_FLAG_PVDO: PVD Output. This flag is valid only if PVD is enabled
\r
200 * by the HAL_PWR_EnablePVD() function. The PVD is stopped by Standby mode
\r
201 * For this reason, this bit is equal to 0 after Standby or reset
\r
202 * until the PVDE bit is set.
\r
203 * @arg PWR_FLAG_BRR: Backup regulator ready flag. This bit is not reset
\r
204 * when the device wakes up from Standby mode or by a system reset
\r
206 * @arg PWR_FLAG_VOSRDY: This flag indicates that the Regulator voltage
\r
207 * scaling output selection is ready.
\r
208 * @retval The new state of __FLAG__ (TRUE or FALSE).
\r
210 #define __HAL_PWR_GET_FLAG(__FLAG__) ((PWR->CSR1 & (__FLAG__)) == (__FLAG__))
\r
212 /** @brief Clear the PWR's pending flags.
\r
213 * @param __FLAG__: specifies the flag to clear.
\r
214 * This parameter can be one of the following values:
\r
215 * @arg PWR_FLAG_SB: StandBy flag
\r
217 #define __HAL_PWR_CLEAR_FLAG(__FLAG__) (PWR->CR1 |= (__FLAG__) << 2)
\r
220 * @brief Enable the PVD Exti Line 16.
\r
223 #define __HAL_PWR_PVD_EXTI_ENABLE_IT() (EXTI->IMR |= (PWR_EXTI_LINE_PVD))
\r
226 * @brief Disable the PVD EXTI Line 16.
\r
229 #define __HAL_PWR_PVD_EXTI_DISABLE_IT() (EXTI->IMR &= ~(PWR_EXTI_LINE_PVD))
\r
232 * @brief Enable event on PVD Exti Line 16.
\r
235 #define __HAL_PWR_PVD_EXTI_ENABLE_EVENT() (EXTI->EMR |= (PWR_EXTI_LINE_PVD))
\r
238 * @brief Disable event on PVD Exti Line 16.
\r
241 #define __HAL_PWR_PVD_EXTI_DISABLE_EVENT() (EXTI->EMR &= ~(PWR_EXTI_LINE_PVD))
\r
244 * @brief Enable the PVD Extended Interrupt Rising Trigger.
\r
247 #define __HAL_PWR_PVD_EXTI_ENABLE_RISING_EDGE() SET_BIT(EXTI->RTSR, PWR_EXTI_LINE_PVD)
\r
250 * @brief Disable the PVD Extended Interrupt Rising Trigger.
\r
253 #define __HAL_PWR_PVD_EXTI_DISABLE_RISING_EDGE() CLEAR_BIT(EXTI->RTSR, PWR_EXTI_LINE_PVD)
\r
256 * @brief Enable the PVD Extended Interrupt Falling Trigger.
\r
259 #define __HAL_PWR_PVD_EXTI_ENABLE_FALLING_EDGE() SET_BIT(EXTI->FTSR, PWR_EXTI_LINE_PVD)
\r
263 * @brief Disable the PVD Extended Interrupt Falling Trigger.
\r
266 #define __HAL_PWR_PVD_EXTI_DISABLE_FALLING_EDGE() CLEAR_BIT(EXTI->FTSR, PWR_EXTI_LINE_PVD)
\r
270 * @brief PVD EXTI line configuration: set rising & falling edge trigger.
\r
273 #define __HAL_PWR_PVD_EXTI_ENABLE_RISING_FALLING_EDGE() __HAL_PWR_PVD_EXTI_ENABLE_RISING_EDGE();__HAL_PWR_PVD_EXTI_ENABLE_FALLING_EDGE();
\r
276 * @brief Disable the PVD Extended Interrupt Rising & Falling Trigger.
\r
279 #define __HAL_PWR_PVD_EXTI_DISABLE_RISING_FALLING_EDGE() __HAL_PWR_PVD_EXTI_DISABLE_RISING_EDGE();__HAL_PWR_PVD_EXTI_DISABLE_FALLING_EDGE();
\r
282 * @brief checks whether the specified PVD Exti interrupt flag is set or not.
\r
283 * @retval EXTI PVD Line Status.
\r
285 #define __HAL_PWR_PVD_EXTI_GET_FLAG() (EXTI->PR & (PWR_EXTI_LINE_PVD))
\r
288 * @brief Clear the PVD Exti flag.
\r
291 #define __HAL_PWR_PVD_EXTI_CLEAR_FLAG() (EXTI->PR = (PWR_EXTI_LINE_PVD))
\r
294 * @brief Generates a Software interrupt on PVD EXTI line.
\r
297 #define __HAL_PWR_PVD_EXTI_GENERATE_SWIT() (EXTI->SWIER |= (PWR_EXTI_LINE_PVD))
\r
303 /* Include PWR HAL Extension module */
\r
304 #include "stm32f7xx_hal_pwr_ex.h"
\r
306 /* Exported functions --------------------------------------------------------*/
\r
307 /** @addtogroup PWR_Exported_Functions PWR Exported Functions
\r
311 /** @addtogroup PWR_Exported_Functions_Group1 Initialization and de-initialization functions
\r
314 /* Initialization and de-initialization functions *****************************/
\r
315 void HAL_PWR_DeInit(void);
\r
316 void HAL_PWR_EnableBkUpAccess(void);
\r
317 void HAL_PWR_DisableBkUpAccess(void);
\r
322 /** @addtogroup PWR_Exported_Functions_Group2 Peripheral Control functions
\r
325 /* Peripheral Control functions **********************************************/
\r
326 /* PVD configuration */
\r
327 void HAL_PWR_ConfigPVD(PWR_PVDTypeDef *sConfigPVD);
\r
328 void HAL_PWR_EnablePVD(void);
\r
329 void HAL_PWR_DisablePVD(void);
\r
331 /* WakeUp pins configuration */
\r
332 void HAL_PWR_EnableWakeUpPin(uint32_t WakeUpPinPolarity);
\r
333 void HAL_PWR_DisableWakeUpPin(uint32_t WakeUpPinx);
\r
335 /* Low Power modes entry */
\r
336 void HAL_PWR_EnterSTOPMode(uint32_t Regulator, uint8_t STOPEntry);
\r
337 void HAL_PWR_EnterSLEEPMode(uint32_t Regulator, uint8_t SLEEPEntry);
\r
338 void HAL_PWR_EnterSTANDBYMode(void);
\r
340 /* Power PVD IRQ Handler */
\r
341 void HAL_PWR_PVD_IRQHandler(void);
\r
342 void HAL_PWR_PVDCallback(void);
\r
344 /* Cortex System Control functions *******************************************/
\r
345 void HAL_PWR_EnableSleepOnExit(void);
\r
346 void HAL_PWR_DisableSleepOnExit(void);
\r
347 void HAL_PWR_EnableSEVOnPend(void);
\r
348 void HAL_PWR_DisableSEVOnPend(void);
\r
357 /* Private types -------------------------------------------------------------*/
\r
358 /* Private variables ---------------------------------------------------------*/
\r
359 /* Private constants ---------------------------------------------------------*/
\r
360 /** @defgroup PWR_Private_Constants PWR Private Constants
\r
364 /** @defgroup PWR_PVD_EXTI_Line PWR PVD EXTI Line
\r
367 #define PWR_EXTI_LINE_PVD ((uint32_t)0x00010000) /*!< External interrupt line 16 Connected to the PVD EXTI Line */
\r
375 /* Private macros ------------------------------------------------------------*/
\r
376 /** @defgroup PWR_Private_Macros PWR Private Macros
\r
380 /** @defgroup PWR_IS_PWR_Definitions PWR Private macros to check input parameters
\r
383 #define IS_PWR_WAKEUP_POLARITY(POLARITY) (((POLARITY) == PWR_POLARITY_RISINGEDGE) || \
\r
384 ((POLARITY) == PWR_POLARITY_FALLINGEDGE))
\r
385 #define IS_PWR_PVD_LEVEL(LEVEL) (((LEVEL) == PWR_PVDLEVEL_0) || ((LEVEL) == PWR_PVDLEVEL_1)|| \
\r
386 ((LEVEL) == PWR_PVDLEVEL_2) || ((LEVEL) == PWR_PVDLEVEL_3)|| \
\r
387 ((LEVEL) == PWR_PVDLEVEL_4) || ((LEVEL) == PWR_PVDLEVEL_5)|| \
\r
388 ((LEVEL) == PWR_PVDLEVEL_6) || ((LEVEL) == PWR_PVDLEVEL_7))
\r
389 #define IS_PWR_PVD_MODE(MODE) (((MODE) == PWR_PVD_MODE_IT_RISING)|| ((MODE) == PWR_PVD_MODE_IT_FALLING) || \
\r
390 ((MODE) == PWR_PVD_MODE_IT_RISING_FALLING) || ((MODE) == PWR_PVD_MODE_EVENT_RISING) || \
\r
391 ((MODE) == PWR_PVD_MODE_EVENT_FALLING) || ((MODE) == PWR_PVD_MODE_EVENT_RISING_FALLING) || \
\r
392 ((MODE) == PWR_PVD_MODE_NORMAL))
\r
393 #define IS_PWR_REGULATOR(REGULATOR) (((REGULATOR) == PWR_MAINREGULATOR_ON) || \
\r
394 ((REGULATOR) == PWR_LOWPOWERREGULATOR_ON))
\r
395 #define IS_PWR_SLEEP_ENTRY(ENTRY) (((ENTRY) == PWR_SLEEPENTRY_WFI) || ((ENTRY) == PWR_SLEEPENTRY_WFE))
\r
396 #define IS_PWR_STOP_ENTRY(ENTRY) (((ENTRY) == PWR_STOPENTRY_WFI) || ((ENTRY) == PWR_STOPENTRY_WFE))
\r
397 #define IS_PWR_REGULATOR_VOLTAGE(VOLTAGE) (((VOLTAGE) == PWR_REGULATOR_VOLTAGE_SCALE1) || \
\r
398 ((VOLTAGE) == PWR_REGULATOR_VOLTAGE_SCALE2) || \
\r
399 ((VOLTAGE) == PWR_REGULATOR_VOLTAGE_SCALE3))
\r
422 #endif /* __STM32F7xx_HAL_PWR_H */
\r
424 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
\r