2 ******************************************************************************
3 * @file stm32f3xx_hal_pwr.h
4 * @author MCD Application Team
7 * @brief Header file of PWR HAL module.
8 ******************************************************************************
11 * <h2><center>© COPYRIGHT(c) 2014 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 __STM32F3xx_HAL_PWR_H
40 #define __STM32F3xx_HAL_PWR_H
46 /* Includes ------------------------------------------------------------------*/
47 #include "stm32f3xx_hal_def.h"
49 /** @addtogroup STM32F3xx_HAL_Driver
53 /** @addtogroup PWR PWR HAL Driver module
57 /* Exported types ------------------------------------------------------------*/
58 /* Exported constants --------------------------------------------------------*/
59 /** @defgroup PWR_Alias_Exported_Constants PWR Alias Exported Constants
62 /* ------------- PWR registers bit address in the alias region ---------------*/
63 #define PWR_OFFSET (PWR_BASE - PERIPH_BASE)
65 /* --- CR Register ---*/
66 #define CR_OFFSET (PWR_OFFSET + 0x00)
67 /* Alias word address of DBP bit */
68 #define DBP_BitNumber POSITION_VAL(PWR_CR_DBP)
69 #define CR_DBP_BB (PERIPH_BB_BASE + (CR_OFFSET * 32) + (DBP_BitNumber * 4))
71 /* Alias word address of PVDE bit */
72 #define PVDE_BitNumber POSITION_VAL(PWR_CR_PVDE)
73 #define CR_PVDE_BB (PERIPH_BB_BASE + (CR_OFFSET * 32) + (PVDE_BitNumber * 4))
75 /* --- CSR Register ---*/
76 #define CSR_OFFSET (PWR_OFFSET + 0x04)
77 /* Alias word address of EWUP1 bit */
78 #define EWUP1_BitNumber POSITION_VAL(PWR_CSR_EWUP1)
79 #define CSR_EWUP1_BB (PERIPH_BB_BASE + (CSR_OFFSET * 32) + (EWUP1_BitNumber * 4))
81 /* Alias word address of EWUP2 bit */
82 #define EWUP2_BitNumber POSITION_VAL(PWR_CSR_EWUP2)
83 #define CSR_EWUP2_BB (PERIPH_BB_BASE + (CSR_OFFSET * 32) + (EWUP2_BitNumber * 4))
85 /* Alias word address of EWUP3 bit */
86 #define EWUP3_BitNumber POSITION_VAL(PWR_CSR_EWUP3)
87 #define CSR_EWUP3_BB (PERIPH_BB_BASE + (CSR_OFFSET * 32) + (EWUP3_BitNumber * 4))
92 /** @defgroup PWR_Exported_Constants PWR Exported Constants
96 /** @defgroup PWR_WakeUp_Pins PWR WakeUp Pins
100 #define PWR_WAKEUP_PIN1 ((uint32_t)0x00)
101 #define PWR_WAKEUP_PIN2 ((uint32_t)0x01)
102 #define PWR_WAKEUP_PIN3 ((uint32_t)0x02)
103 #define IS_PWR_WAKEUP_PIN(PIN) (((PIN) == PWR_WAKEUP_PIN1) || \
104 ((PIN) == PWR_WAKEUP_PIN2) || \
105 ((PIN) == PWR_WAKEUP_PIN3))
110 /** @defgroup PWR_Regulator_state_in_STOP_mode PWR Regulator state in STOP mode
113 #define PWR_MAINREGULATOR_ON ((uint32_t)0x00000000)
114 #define PWR_LOWPOWERREGULATOR_ON PWR_CR_LPDS
116 #define IS_PWR_REGULATOR(REGULATOR) (((REGULATOR) == PWR_MAINREGULATOR_ON) || \
117 ((REGULATOR) == PWR_LOWPOWERREGULATOR_ON))
122 /** @defgroup PWR_SLEEP_mode_entry PWR SLEEP mode entry
125 #define PWR_SLEEPENTRY_WFI ((uint8_t)0x01)
126 #define PWR_SLEEPENTRY_WFE ((uint8_t)0x02)
127 #define IS_PWR_SLEEP_ENTRY(ENTRY) (((ENTRY) == PWR_SLEEPENTRY_WFI) || ((ENTRY) == PWR_SLEEPENTRY_WFE))
132 /** @defgroup PWR_STOP_mode_entry PWR STOP mode entry
135 #define PWR_STOPENTRY_WFI ((uint8_t)0x01)
136 #define PWR_STOPENTRY_WFE ((uint8_t)0x02)
137 #define IS_PWR_STOP_ENTRY(ENTRY) (((ENTRY) == PWR_STOPENTRY_WFI) || ((ENTRY) == PWR_STOPENTRY_WFE))
142 /** @defgroup PWR_Flag PWR Flag
145 #define PWR_FLAG_WU PWR_CSR_WUF
146 #define PWR_FLAG_SB PWR_CSR_SBF
147 #define PWR_FLAG_PVDO PWR_CSR_PVDO
148 #define PWR_FLAG_VREFINTRDY PWR_CSR_VREFINTRDYF
149 #define IS_PWR_GET_FLAG(FLAG) (((FLAG) == PWR_FLAG_WU) || ((FLAG) == PWR_FLAG_SB) || \
150 ((FLAG) == PWR_FLAG_PVDO) || ((FLAG) == PWR_FLAG_VREFINTRDY))
161 /* Exported macro ------------------------------------------------------------*/
162 /** @defgroup PWR_Exported_Macro PWR Exported Macro
166 /** @brief Check PWR flag is set or not.
167 * @param __FLAG__: specifies the flag to check.
168 * This parameter can be one of the following values:
169 * @arg PWR_FLAG_WU: Wake Up flag. This flag indicates that a wakeup event
170 * was received from the WKUP pin or from the RTC alarm (Alarm A
171 * or Alarm B), RTC Tamper event, RTC TimeStamp event or RTC Wakeup.
172 * An additional wakeup event is detected if the WKUP pin is enabled
173 * (by setting the EWUP bit) when the WKUP pin level is already high.
174 * @arg PWR_FLAG_SB: StandBy flag. This flag indicates that the system was
175 * resumed from StandBy mode.
176 * @arg PWR_FLAG_PVDO: PVD Output. This flag is valid only if PVD is enabled
177 * by the HAL_PWR_EnablePVD() function. The PVD is stopped by Standby mode
178 * For this reason, this bit is equal to 0 after Standby or reset
179 * until the PVDE bit is set.
180 * @arg PWR_FLAG_VREFINTRDY: This flag indicates that the internal reference
181 * voltage VREFINT is ready.
182 * @retval The new state of __FLAG__ (TRUE or FALSE).
184 #define __HAL_PWR_GET_FLAG(__FLAG__) ((PWR->CSR & (__FLAG__)) == (__FLAG__))
186 /** @brief Clear the PWR's pending flags.
187 * @param __FLAG__: specifies the flag to clear.
188 * This parameter can be one of the following values:
189 * @arg PWR_FLAG_WU: Wake Up flag
190 * @arg PWR_FLAG_SB: StandBy flag
192 #define __HAL_PWR_CLEAR_FLAG(__FLAG__) (PWR->CR |= (__FLAG__) << 2)
198 /* Include PWR HAL Extended module */
199 #include "stm32f3xx_hal_pwr_ex.h"
201 /* Exported functions --------------------------------------------------------*/
203 /** @addtogroup PWR_Exported_Functions PWR Exported Functions
207 /** @addtogroup PWR_Exported_Functions_Group1 Initialization and de-initialization functions
211 /* Initialization and de-initialization functions *****************************/
212 void HAL_PWR_DeInit(void);
218 /** @addtogroup PWR_Exported_Functions_Group2 Peripheral Control functions
222 /* Peripheral Control functions **********************************************/
223 void HAL_PWR_EnableBkUpAccess(void);
224 void HAL_PWR_DisableBkUpAccess(void);
226 /* WakeUp pins configuration functions ****************************************/
227 void HAL_PWR_EnableWakeUpPin(uint32_t WakeUpPinx);
228 void HAL_PWR_DisableWakeUpPin(uint32_t WakeUpPinx);
230 /* Low Power modes configuration functions ************************************/
231 void HAL_PWR_EnterSTOPMode(uint32_t Regulator, uint8_t STOPEntry);
232 void HAL_PWR_EnterSLEEPMode(uint32_t Regulator, uint8_t SLEEPEntry);
233 void HAL_PWR_EnterSTANDBYMode(void);
256 #endif /* __STM32F3xx_HAL_PWR_H */
258 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/