Increment eeprom version
[betaflight.git] / lib / main / STM32F1 / Drivers / STM32F1xx_HAL_Driver / Inc / stm32f1xx_hal_pwr.h
blob968e7c9d27c29eeab45878c58dff6b9469430dbe
1 /**
2 ******************************************************************************
3 * @file stm32f1xx_hal_pwr.h
4 * @author MCD Application Team
5 * @version V1.1.1
6 * @date 12-May-2017
7 * @brief Header file of PWR HAL module.
8 ******************************************************************************
9 * @attention
11 * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
13 * Redistribution and use in source and binary forms, with or without modification,
14 * are permitted provided that the following conditions are met:
15 * 1. Redistributions of source code must retain the above copyright notice,
16 * this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright notice,
18 * this list of conditions and the following disclaimer in the documentation
19 * and/or other materials provided with the distribution.
20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 ******************************************************************************
38 /* Define to prevent recursive inclusion -------------------------------------*/
39 #ifndef __STM32F1xx_HAL_PWR_H
40 #define __STM32F1xx_HAL_PWR_H
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
46 /* Includes ------------------------------------------------------------------*/
47 #include "stm32f1xx_hal_def.h"
49 /** @addtogroup STM32F1xx_HAL_Driver
50 * @{
53 /** @addtogroup PWR
54 * @{
57 /* Exported types ------------------------------------------------------------*/
59 /** @defgroup PWR_Exported_Types PWR Exported Types
60 * @{
61 */
63 /**
64 * @brief PWR PVD configuration structure definition
66 typedef struct
68 uint32_t PVDLevel; /*!< PVDLevel: Specifies the PVD detection level.
69 This parameter can be a value of @ref PWR_PVD_detection_level */
71 uint32_t Mode; /*!< Mode: Specifies the operating mode for the selected pins.
72 This parameter can be a value of @ref PWR_PVD_Mode */
73 }PWR_PVDTypeDef;
76 /**
77 * @}
81 /* Internal constants --------------------------------------------------------*/
83 /** @addtogroup PWR_Private_Constants
84 * @{
85 */
87 #define PWR_EXTI_LINE_PVD ((uint32_t)0x00010000) /*!< External interrupt line 16 Connected to the PVD EXTI Line */
89 /**
90 * @}
94 /* Exported constants --------------------------------------------------------*/
96 /** @defgroup PWR_Exported_Constants PWR Exported Constants
97 * @{
98 */
100 /** @defgroup PWR_PVD_detection_level PWR PVD detection level
101 * @{
103 #define PWR_PVDLEVEL_0 PWR_CR_PLS_2V2
104 #define PWR_PVDLEVEL_1 PWR_CR_PLS_2V3
105 #define PWR_PVDLEVEL_2 PWR_CR_PLS_2V4
106 #define PWR_PVDLEVEL_3 PWR_CR_PLS_2V5
107 #define PWR_PVDLEVEL_4 PWR_CR_PLS_2V6
108 #define PWR_PVDLEVEL_5 PWR_CR_PLS_2V7
109 #define PWR_PVDLEVEL_6 PWR_CR_PLS_2V8
110 #define PWR_PVDLEVEL_7 PWR_CR_PLS_2V9
113 * @}
116 /** @defgroup PWR_PVD_Mode PWR PVD Mode
117 * @{
119 #define PWR_PVD_MODE_NORMAL 0x00000000U /*!< basic mode is used */
120 #define PWR_PVD_MODE_IT_RISING 0x00010001U /*!< External Interrupt Mode with Rising edge trigger detection */
121 #define PWR_PVD_MODE_IT_FALLING 0x00010002U /*!< External Interrupt Mode with Falling edge trigger detection */
122 #define PWR_PVD_MODE_IT_RISING_FALLING 0x00010003U /*!< External Interrupt Mode with Rising/Falling edge trigger detection */
123 #define PWR_PVD_MODE_EVENT_RISING 0x00020001U /*!< Event Mode with Rising edge trigger detection */
124 #define PWR_PVD_MODE_EVENT_FALLING 0x00020002U /*!< Event Mode with Falling edge trigger detection */
125 #define PWR_PVD_MODE_EVENT_RISING_FALLING 0x00020003U /*!< Event Mode with Rising/Falling edge trigger detection */
128 * @}
132 /** @defgroup PWR_WakeUp_Pins PWR WakeUp Pins
133 * @{
136 #define PWR_WAKEUP_PIN1 PWR_CSR_EWUP
139 * @}
142 /** @defgroup PWR_Regulator_state_in_SLEEP_STOP_mode PWR Regulator state in SLEEP/STOP mode
143 * @{
145 #define PWR_MAINREGULATOR_ON 0x00000000U
146 #define PWR_LOWPOWERREGULATOR_ON PWR_CR_LPDS
149 * @}
152 /** @defgroup PWR_SLEEP_mode_entry PWR SLEEP mode entry
153 * @{
155 #define PWR_SLEEPENTRY_WFI ((uint8_t)0x01)
156 #define PWR_SLEEPENTRY_WFE ((uint8_t)0x02)
159 * @}
162 /** @defgroup PWR_STOP_mode_entry PWR STOP mode entry
163 * @{
165 #define PWR_STOPENTRY_WFI ((uint8_t)0x01)
166 #define PWR_STOPENTRY_WFE ((uint8_t)0x02)
169 * @}
172 /** @defgroup PWR_Flag PWR Flag
173 * @{
175 #define PWR_FLAG_WU PWR_CSR_WUF
176 #define PWR_FLAG_SB PWR_CSR_SBF
177 #define PWR_FLAG_PVDO PWR_CSR_PVDO
181 * @}
185 * @}
188 /* Exported macro ------------------------------------------------------------*/
189 /** @defgroup PWR_Exported_Macros PWR Exported Macros
190 * @{
193 /** @brief Check PWR flag is set or not.
194 * @param __FLAG__: specifies the flag to check.
195 * This parameter can be one of the following values:
196 * @arg PWR_FLAG_WU: Wake Up flag. This flag indicates that a wakeup event
197 * was received from the WKUP pin or from the RTC alarm
198 * An additional wakeup event is detected if the WKUP pin is enabled
199 * (by setting the EWUP bit) when the WKUP pin level is already high.
200 * @arg PWR_FLAG_SB: StandBy flag. This flag indicates that the system was
201 * resumed from StandBy mode.
202 * @arg PWR_FLAG_PVDO: PVD Output. This flag is valid only if PVD is enabled
203 * by the HAL_PWR_EnablePVD() function. The PVD is stopped by Standby mode
204 * For this reason, this bit is equal to 0 after Standby or reset
205 * until the PVDE bit is set.
206 * @retval The new state of __FLAG__ (TRUE or FALSE).
208 #define __HAL_PWR_GET_FLAG(__FLAG__) ((PWR->CSR & (__FLAG__)) == (__FLAG__))
210 /** @brief Clear the PWR's pending flags.
211 * @param __FLAG__: specifies the flag to clear.
212 * This parameter can be one of the following values:
213 * @arg PWR_FLAG_WU: Wake Up flag
214 * @arg PWR_FLAG_SB: StandBy flag
216 #define __HAL_PWR_CLEAR_FLAG(__FLAG__) SET_BIT(PWR->CR, ((__FLAG__) << 2))
219 * @brief Enable interrupt on PVD Exti Line 16.
220 * @retval None.
222 #define __HAL_PWR_PVD_EXTI_ENABLE_IT() SET_BIT(EXTI->IMR, PWR_EXTI_LINE_PVD)
225 * @brief Disable interrupt on PVD Exti Line 16.
226 * @retval None.
228 #define __HAL_PWR_PVD_EXTI_DISABLE_IT() CLEAR_BIT(EXTI->IMR, PWR_EXTI_LINE_PVD)
231 * @brief Enable event on PVD Exti Line 16.
232 * @retval None.
234 #define __HAL_PWR_PVD_EXTI_ENABLE_EVENT() SET_BIT(EXTI->EMR, PWR_EXTI_LINE_PVD)
237 * @brief Disable event on PVD Exti Line 16.
238 * @retval None.
240 #define __HAL_PWR_PVD_EXTI_DISABLE_EVENT() CLEAR_BIT(EXTI->EMR, PWR_EXTI_LINE_PVD)
244 * @brief PVD EXTI line configuration: set falling edge trigger.
245 * @retval None.
247 #define __HAL_PWR_PVD_EXTI_ENABLE_FALLING_EDGE() SET_BIT(EXTI->FTSR, PWR_EXTI_LINE_PVD)
251 * @brief Disable the PVD Extended Interrupt Falling Trigger.
252 * @retval None.
254 #define __HAL_PWR_PVD_EXTI_DISABLE_FALLING_EDGE() CLEAR_BIT(EXTI->FTSR, PWR_EXTI_LINE_PVD)
258 * @brief PVD EXTI line configuration: set rising edge trigger.
259 * @retval None.
261 #define __HAL_PWR_PVD_EXTI_ENABLE_RISING_EDGE() SET_BIT(EXTI->RTSR, PWR_EXTI_LINE_PVD)
264 * @brief Disable the PVD Extended Interrupt Rising Trigger.
265 * This parameter can be:
266 * @retval None.
268 #define __HAL_PWR_PVD_EXTI_DISABLE_RISING_EDGE() CLEAR_BIT(EXTI->RTSR, PWR_EXTI_LINE_PVD)
271 * @brief PVD EXTI line configuration: set rising & falling edge trigger.
272 * @retval None.
274 #define __HAL_PWR_PVD_EXTI_ENABLE_RISING_FALLING_EDGE() __HAL_PWR_PVD_EXTI_ENABLE_RISING_EDGE();__HAL_PWR_PVD_EXTI_ENABLE_FALLING_EDGE();
277 * @brief Disable the PVD Extended Interrupt Rising & Falling Trigger.
278 * This parameter can be:
279 * @retval None.
281 #define __HAL_PWR_PVD_EXTI_DISABLE_RISING_FALLING_EDGE() __HAL_PWR_PVD_EXTI_DISABLE_RISING_EDGE();__HAL_PWR_PVD_EXTI_DISABLE_FALLING_EDGE();
286 * @brief Check whether the specified PVD EXTI interrupt flag is set or not.
287 * @retval EXTI PVD Line Status.
289 #define __HAL_PWR_PVD_EXTI_GET_FLAG() (EXTI->PR & (PWR_EXTI_LINE_PVD))
292 * @brief Clear the PVD EXTI flag.
293 * @retval None.
295 #define __HAL_PWR_PVD_EXTI_CLEAR_FLAG() (EXTI->PR = (PWR_EXTI_LINE_PVD))
298 * @brief Generate a Software interrupt on selected EXTI line.
299 * @retval None.
301 #define __HAL_PWR_PVD_EXTI_GENERATE_SWIT() SET_BIT(EXTI->SWIER, PWR_EXTI_LINE_PVD)
303 * @}
306 /* Private macro -------------------------------------------------------------*/
307 /** @defgroup PWR_Private_Macros PWR Private Macros
308 * @{
310 #define IS_PWR_PVD_LEVEL(LEVEL) (((LEVEL) == PWR_PVDLEVEL_0) || ((LEVEL) == PWR_PVDLEVEL_1)|| \
311 ((LEVEL) == PWR_PVDLEVEL_2) || ((LEVEL) == PWR_PVDLEVEL_3)|| \
312 ((LEVEL) == PWR_PVDLEVEL_4) || ((LEVEL) == PWR_PVDLEVEL_5)|| \
313 ((LEVEL) == PWR_PVDLEVEL_6) || ((LEVEL) == PWR_PVDLEVEL_7))
316 #define IS_PWR_PVD_MODE(MODE) (((MODE) == PWR_PVD_MODE_IT_RISING)|| ((MODE) == PWR_PVD_MODE_IT_FALLING) || \
317 ((MODE) == PWR_PVD_MODE_IT_RISING_FALLING) || ((MODE) == PWR_PVD_MODE_EVENT_RISING) || \
318 ((MODE) == PWR_PVD_MODE_EVENT_FALLING) || ((MODE) == PWR_PVD_MODE_EVENT_RISING_FALLING) || \
319 ((MODE) == PWR_PVD_MODE_NORMAL))
321 #define IS_PWR_WAKEUP_PIN(PIN) (((PIN) == PWR_WAKEUP_PIN1))
323 #define IS_PWR_REGULATOR(REGULATOR) (((REGULATOR) == PWR_MAINREGULATOR_ON) || \
324 ((REGULATOR) == PWR_LOWPOWERREGULATOR_ON))
326 #define IS_PWR_SLEEP_ENTRY(ENTRY) (((ENTRY) == PWR_SLEEPENTRY_WFI) || ((ENTRY) == PWR_SLEEPENTRY_WFE))
328 #define IS_PWR_STOP_ENTRY(ENTRY) (((ENTRY) == PWR_STOPENTRY_WFI) || ((ENTRY) == PWR_STOPENTRY_WFE))
331 * @}
336 /* Exported functions --------------------------------------------------------*/
338 /** @addtogroup PWR_Exported_Functions PWR Exported Functions
339 * @{
342 /** @addtogroup PWR_Exported_Functions_Group1 Initialization and de-initialization functions
343 * @{
346 /* Initialization and de-initialization functions *******************************/
347 void HAL_PWR_DeInit(void);
348 void HAL_PWR_EnableBkUpAccess(void);
349 void HAL_PWR_DisableBkUpAccess(void);
352 * @}
355 /** @addtogroup PWR_Exported_Functions_Group2 Peripheral Control functions
356 * @{
359 /* Peripheral Control functions ************************************************/
360 void HAL_PWR_ConfigPVD(PWR_PVDTypeDef *sConfigPVD);
361 /* #define HAL_PWR_ConfigPVD 12*/
362 void HAL_PWR_EnablePVD(void);
363 void HAL_PWR_DisablePVD(void);
365 /* WakeUp pins configuration functions ****************************************/
366 void HAL_PWR_EnableWakeUpPin(uint32_t WakeUpPinx);
367 void HAL_PWR_DisableWakeUpPin(uint32_t WakeUpPinx);
369 /* Low Power modes configuration functions ************************************/
370 void HAL_PWR_EnterSTOPMode(uint32_t Regulator, uint8_t STOPEntry);
371 void HAL_PWR_EnterSLEEPMode(uint32_t Regulator, uint8_t SLEEPEntry);
372 void HAL_PWR_EnterSTANDBYMode(void);
374 void HAL_PWR_EnableSleepOnExit(void);
375 void HAL_PWR_DisableSleepOnExit(void);
376 void HAL_PWR_EnableSEVOnPend(void);
377 void HAL_PWR_DisableSEVOnPend(void);
381 void HAL_PWR_PVD_IRQHandler(void);
382 void HAL_PWR_PVDCallback(void);
384 * @}
388 * @}
392 * @}
396 * @}
399 #ifdef __cplusplus
401 #endif
404 #endif /* __STM32F1xx_HAL_PWR_H */
406 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/