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