2 ******************************************************************************
3 * @file stm32f30x_pwr.h
4 * @author MCD Application Team
6 * @date 27-February-2014
7 * @brief This file contains all the functions prototypes for the PWR firmware
9 ******************************************************************************
12 * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
14 * Redistribution and use in source and binary forms, with or without modification,
15 * are permitted provided that the following conditions are met:
16 * 1. Redistributions of source code must retain the above copyright notice,
17 * this list of conditions and the following disclaimer.
18 * 2. Redistributions in binary form must reproduce the above copyright notice,
19 * this list of conditions and the following disclaimer in the documentation
20 * and/or other materials provided with the distribution.
21 * 3. Neither the name of STMicroelectronics nor the names of its contributors
22 * may be used to endorse or promote products derived from this software
23 * without specific prior written permission.
25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
28 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
31 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
33 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 ******************************************************************************
39 /* Define to prevent recursive inclusion -------------------------------------*/
40 #ifndef __STM32F30x_PWR_H
41 #define __STM32F30x_PWR_H
47 /* Includes ------------------------------------------------------------------*/
48 #include "stm32f30x.h"
50 /** @addtogroup STM32F30x_StdPeriph_Driver
58 /* Exported types ------------------------------------------------------------*/
59 /* Exported constants --------------------------------------------------------*/
61 /** @defgroup PWR_Exported_Constants
65 /** @defgroup PWR_PVD_detection_level
69 #define PWR_PVDLevel_0 PWR_CR_PLS_LEV0
70 #define PWR_PVDLevel_1 PWR_CR_PLS_LEV1
71 #define PWR_PVDLevel_2 PWR_CR_PLS_LEV2
72 #define PWR_PVDLevel_3 PWR_CR_PLS_LEV3
73 #define PWR_PVDLevel_4 PWR_CR_PLS_LEV4
74 #define PWR_PVDLevel_5 PWR_CR_PLS_LEV5
75 #define PWR_PVDLevel_6 PWR_CR_PLS_LEV6
76 #define PWR_PVDLevel_7 PWR_CR_PLS_LEV7
78 #define IS_PWR_PVD_LEVEL(LEVEL) (((LEVEL) == PWR_PVDLevel_0) || ((LEVEL) == PWR_PVDLevel_1)|| \
79 ((LEVEL) == PWR_PVDLevel_2) || ((LEVEL) == PWR_PVDLevel_3)|| \
80 ((LEVEL) == PWR_PVDLevel_4) || ((LEVEL) == PWR_PVDLevel_5)|| \
81 ((LEVEL) == PWR_PVDLevel_6) || ((LEVEL) == PWR_PVDLevel_7))
86 /** @defgroup PWR_WakeUp_Pins
90 #define PWR_WakeUpPin_1 PWR_CSR_EWUP1
91 #define PWR_WakeUpPin_2 PWR_CSR_EWUP2
92 #define PWR_WakeUpPin_3 PWR_CSR_EWUP3
93 #define IS_PWR_WAKEUP_PIN(PIN) (((PIN) == PWR_WakeUpPin_1) || \
94 ((PIN) == PWR_WakeUpPin_2) || \
95 ((PIN) == PWR_WakeUpPin_3))
101 /** @defgroup PWR_Regulator_state_is_Sleep_STOP_mode
105 #define PWR_Regulator_ON ((uint32_t)0x00000000)
106 #define PWR_Regulator_LowPower PWR_CR_LPSDSR
107 #define IS_PWR_REGULATOR(REGULATOR) (((REGULATOR) == PWR_Regulator_ON) || \
108 ((REGULATOR) == PWR_Regulator_LowPower))
113 /** @defgroup PWR_SLEEP_mode_entry
117 #define PWR_SLEEPEntry_WFI ((uint8_t)0x01)
118 #define PWR_SLEEPEntry_WFE ((uint8_t)0x02)
119 #define IS_PWR_SLEEP_ENTRY(ENTRY) (((ENTRY) == PWR_SLEEPEntry_WFI) || ((ENTRY) == PWR_SLEEPEntry_WFE))
125 /** @defgroup PWR_STOP_mode_entry
129 #define PWR_STOPEntry_WFI ((uint8_t)0x01)
130 #define PWR_STOPEntry_WFE ((uint8_t)0x02)
131 #define IS_PWR_STOP_ENTRY(ENTRY) (((ENTRY) == PWR_STOPEntry_WFI) || ((ENTRY) == PWR_STOPEntry_WFE))
137 /** @defgroup PWR_Flag
141 #define PWR_FLAG_WU PWR_CSR_WUF
142 #define PWR_FLAG_SB PWR_CSR_SBF
143 #define PWR_FLAG_PVDO PWR_CSR_PVDO
144 #define PWR_FLAG_VREFINTRDY PWR_CSR_VREFINTRDYF
146 #define IS_PWR_GET_FLAG(FLAG) (((FLAG) == PWR_FLAG_WU) || ((FLAG) == PWR_FLAG_SB) || \
147 ((FLAG) == PWR_FLAG_PVDO) || ((FLAG) == PWR_FLAG_VREFINTRDY))
149 #define IS_PWR_CLEAR_FLAG(FLAG) (((FLAG) == PWR_FLAG_WU) || ((FLAG) == PWR_FLAG_SB))
158 /* Exported macro ------------------------------------------------------------*/
159 /* Exported functions ------------------------------------------------------- */
161 /* Function used to set the PWR configuration to the default reset state ******/
162 void PWR_DeInit(void);
164 /* Backup Domain Access function **********************************************/
165 void PWR_BackupAccessCmd(FunctionalState NewState);
167 /* PVD configuration functions ************************************************/
168 void PWR_PVDLevelConfig(uint32_t PWR_PVDLevel);
169 void PWR_PVDCmd(FunctionalState NewState);
171 /* WakeUp pins configuration functions ****************************************/
172 void PWR_WakeUpPinCmd(uint32_t PWR_WakeUpPin, FunctionalState NewState);
174 /* Low Power modes configuration functions ************************************/
175 void PWR_EnterSleepMode(uint8_t PWR_SLEEPEntry);
176 void PWR_EnterSTOPMode(uint32_t PWR_Regulator, uint8_t PWR_STOPEntry);
177 void PWR_EnterSTANDBYMode(void);
179 /* Flags management functions *************************************************/
180 FlagStatus PWR_GetFlagStatus(uint32_t PWR_FLAG);
181 void PWR_ClearFlag(uint32_t PWR_FLAG);
187 #endif /* __STM32F30x_PWR_H */
197 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/