38
|
1 /**
|
|
2 ******************************************************************************
|
|
3 * @file stm32f4xx_hal_pwr.c
|
|
4 * @author MCD Application Team
|
|
5 * @version V1.2.0
|
|
6 * @date 26-December-2014
|
|
7 * @brief PWR HAL module driver.
|
|
8 * This file provides firmware functions to manage the following
|
|
9 * functionalities of the Power Controller (PWR) peripheral:
|
|
10 * + Initialization and de-initialization functions
|
|
11 * + Peripheral Control functions
|
|
12 *
|
|
13 ******************************************************************************
|
|
14 * @attention
|
|
15 *
|
|
16 * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
|
|
17 *
|
|
18 * Redistribution and use in source and binary forms, with or without modification,
|
|
19 * are permitted provided that the following conditions are met:
|
|
20 * 1. Redistributions of source code must retain the above copyright notice,
|
|
21 * this list of conditions and the following disclaimer.
|
|
22 * 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
23 * this list of conditions and the following disclaimer in the documentation
|
|
24 * and/or other materials provided with the distribution.
|
|
25 * 3. Neither the name of STMicroelectronics nor the names of its contributors
|
|
26 * may be used to endorse or promote products derived from this software
|
|
27 * without specific prior written permission.
|
|
28 *
|
|
29 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
30 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
31 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
32 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
33 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
34 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
35 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
36 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
37 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
38 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
39 *
|
|
40 ******************************************************************************
|
|
41 */
|
|
42
|
|
43 /* Includes ------------------------------------------------------------------*/
|
|
44 #include "stm32f4xx_hal.h"
|
|
45
|
|
46 /** @addtogroup STM32F4xx_HAL_Driver
|
|
47 * @{
|
|
48 */
|
|
49
|
|
50 /** @defgroup PWR PWR
|
|
51 * @brief PWR HAL module driver
|
|
52 * @{
|
|
53 */
|
|
54
|
|
55 #ifdef HAL_PWR_MODULE_ENABLED
|
|
56
|
|
57 /* Private typedef -----------------------------------------------------------*/
|
|
58 /* Private define ------------------------------------------------------------*/
|
|
59 /** @addtogroup PWR_Private_Constants
|
|
60 * @{
|
|
61 */
|
|
62
|
|
63 /** @defgroup PWR_PVD_Mode_Mask PWR PVD Mode Mask
|
|
64 * @{
|
|
65 */
|
|
66 #define PVD_MODE_IT ((uint32_t)0x00010000)
|
|
67 #define PVD_MODE_EVT ((uint32_t)0x00020000)
|
|
68 #define PVD_RISING_EDGE ((uint32_t)0x00000001)
|
|
69 #define PVD_FALLING_EDGE ((uint32_t)0x00000002)
|
|
70 /**
|
|
71 * @}
|
|
72 */
|
|
73
|
|
74 /**
|
|
75 * @}
|
|
76 */
|
|
77 /* Private macro -------------------------------------------------------------*/
|
|
78 /* Private variables ---------------------------------------------------------*/
|
|
79 /* Private function prototypes -----------------------------------------------*/
|
|
80 /* Private functions ---------------------------------------------------------*/
|
|
81
|
|
82 /** @defgroup PWR_Exported_Functions PWR Exported Functions
|
|
83 * @{
|
|
84 */
|
|
85
|
|
86 /** @defgroup PWR_Exported_Functions_Group1 Initialization and de-initialization functions
|
|
87 * @brief Initialization and de-initialization functions
|
|
88 *
|
|
89 @verbatim
|
|
90 ===============================================================================
|
|
91 ##### Initialization and de-initialization functions #####
|
|
92 ===============================================================================
|
|
93 [..]
|
|
94 After reset, the backup domain (RTC registers, RTC backup data
|
|
95 registers and backup SRAM) is protected against possible unwanted
|
|
96 write accesses.
|
|
97 To enable access to the RTC Domain and RTC registers, proceed as follows:
|
|
98 (+) Enable the Power Controller (PWR) APB1 interface clock using the
|
|
99 __HAL_RCC_PWR_CLK_ENABLE() macro.
|
|
100 (+) Enable access to RTC domain using the HAL_PWR_EnableBkUpAccess() function.
|
|
101
|
|
102 @endverbatim
|
|
103 * @{
|
|
104 */
|
|
105
|
|
106 /**
|
|
107 * @brief Deinitializes the HAL PWR peripheral registers to their default reset values.
|
|
108 * @retval None
|
|
109 */
|
|
110 void HAL_PWR_DeInit(void)
|
|
111 {
|
|
112 __HAL_RCC_PWR_FORCE_RESET();
|
|
113 __HAL_RCC_PWR_RELEASE_RESET();
|
|
114 }
|
|
115
|
|
116 /**
|
|
117 * @brief Enables access to the backup domain (RTC registers, RTC
|
|
118 * backup data registers and backup SRAM).
|
|
119 * @note If the HSE divided by 2, 3, ..31 is used as the RTC clock, the
|
|
120 * Backup Domain Access should be kept enabled.
|
|
121 * @retval None
|
|
122 */
|
|
123 void HAL_PWR_EnableBkUpAccess(void)
|
|
124 {
|
|
125 *(__IO uint32_t *) CR_DBP_BB = (uint32_t)ENABLE;
|
|
126 }
|
|
127
|
|
128 /**
|
|
129 * @brief Disables access to the backup domain (RTC registers, RTC
|
|
130 * backup data registers and backup SRAM).
|
|
131 * @note If the HSE divided by 2, 3, ..31 is used as the RTC clock, the
|
|
132 * Backup Domain Access should be kept enabled.
|
|
133 * @retval None
|
|
134 */
|
|
135 void HAL_PWR_DisableBkUpAccess(void)
|
|
136 {
|
|
137 *(__IO uint32_t *) CR_DBP_BB = (uint32_t)DISABLE;
|
|
138 }
|
|
139
|
|
140 /**
|
|
141 * @}
|
|
142 */
|
|
143
|
|
144 /** @defgroup PWR_Exported_Functions_Group2 Peripheral Control functions
|
|
145 * @brief Low Power modes configuration functions
|
|
146 *
|
|
147 @verbatim
|
|
148
|
|
149 ===============================================================================
|
|
150 ##### Peripheral Control functions #####
|
|
151 ===============================================================================
|
|
152
|
|
153 *** PVD configuration ***
|
|
154 =========================
|
|
155 [..]
|
|
156 (+) The PVD is used to monitor the VDD power supply by comparing it to a
|
|
157 threshold selected by the PVD Level (PLS[2:0] bits in the PWR_CR).
|
|
158 (+) A PVDO flag is available to indicate if VDD/VDDA is higher or lower
|
|
159 than the PVD threshold. This event is internally connected to the EXTI
|
|
160 line16 and can generate an interrupt if enabled. This is done through
|
|
161 __HAL_PWR_PVD_EXTI_ENABLE_IT() macro.
|
|
162 (+) The PVD is stopped in Standby mode.
|
|
163
|
|
164 *** Wake-up pin configuration ***
|
|
165 ================================
|
|
166 [..]
|
|
167 (+) Wake-up pin is used to wake up the system from Standby mode. This pin is
|
|
168 forced in input pull-down configuration and is active on rising edges.
|
|
169 (+) There is only one Wake-up pin: Wake-up Pin 1 on PA.00.
|
|
170
|
|
171 *** Low Power modes configuration ***
|
|
172 =====================================
|
|
173 [..]
|
|
174 The devices feature 3 low-power modes:
|
|
175 (+) Sleep mode: Cortex-M4 core stopped, peripherals kept running.
|
|
176 (+) Stop mode: all clocks are stopped, regulator running, regulator
|
|
177 in low power mode
|
|
178 (+) Standby mode: 1.2V domain powered off.
|
|
179
|
|
180 *** Sleep mode ***
|
|
181 ==================
|
|
182 [..]
|
|
183 (+) Entry:
|
|
184 The Sleep mode is entered by using the HAL_PWR_EnterSLEEPMode(PWR_MAINREGULATOR_ON, PWR_SLEEPENTRY_WFI)
|
|
185 functions with
|
|
186 (++) PWR_SLEEPENTRY_WFI: enter SLEEP mode with WFI instruction
|
|
187 (++) PWR_SLEEPENTRY_WFE: enter SLEEP mode with WFE instruction
|
|
188
|
|
189 -@@- The Regulator parameter is not used for the STM32F4 family
|
|
190 and is kept as parameter just to maintain compatibility with the
|
|
191 lower power families (STM32L).
|
|
192 (+) Exit:
|
|
193 Any peripheral interrupt acknowledged by the nested vectored interrupt
|
|
194 controller (NVIC) can wake up the device from Sleep mode.
|
|
195
|
|
196 *** Stop mode ***
|
|
197 =================
|
|
198 [..]
|
|
199 In Stop mode, all clocks in the 1.2V domain are stopped, the PLL, the HSI,
|
|
200 and the HSE RC oscillators are disabled. Internal SRAM and register contents
|
|
201 are preserved.
|
|
202 The voltage regulator can be configured either in normal or low-power mode.
|
|
203 To minimize the consumption In Stop mode, FLASH can be powered off before
|
|
204 entering the Stop mode using the HAL_PWREx_EnableFlashPowerDown() function.
|
|
205 It can be switched on again by software after exiting the Stop mode using
|
|
206 the HAL_PWREx_DisableFlashPowerDown() function.
|
|
207
|
|
208 (+) Entry:
|
|
209 The Stop mode is entered using the HAL_PWR_EnterSTOPMode(PWR_MAINREGULATOR_ON)
|
|
210 function with:
|
|
211 (++) Main regulator ON.
|
|
212 (++) Low Power regulator ON.
|
|
213 (+) Exit:
|
|
214 Any EXTI Line (Internal or External) configured in Interrupt/Event mode.
|
|
215
|
|
216 *** Standby mode ***
|
|
217 ====================
|
|
218 [..]
|
|
219 (+)
|
|
220 The Standby mode allows to achieve the lowest power consumption. It is based
|
|
221 on the Cortex-M4 deep sleep mode, with the voltage regulator disabled.
|
|
222 The 1.2V domain is consequently powered off. The PLL, the HSI oscillator and
|
|
223 the HSE oscillator are also switched off. SRAM and register contents are lost
|
|
224 except for the RTC registers, RTC backup registers, backup SRAM and Standby
|
|
225 circuitry.
|
|
226
|
|
227 The voltage regulator is OFF.
|
|
228
|
|
229 (++) Entry:
|
|
230 (+++) The Standby mode is entered using the HAL_PWR_EnterSTANDBYMode() function.
|
|
231 (++) Exit:
|
|
232 (+++) WKUP pin rising edge, RTC alarm (Alarm A and Alarm B), RTC wake-up,
|
|
233 tamper event, time-stamp event, external reset in NRST pin, IWDG reset.
|
|
234
|
|
235 *** Auto-wake-up (AWU) from low-power mode ***
|
|
236 =============================================
|
|
237 [..]
|
|
238
|
|
239 (+) The MCU can be woken up from low-power mode by an RTC Alarm event, an RTC
|
|
240 Wake-up event, a tamper event or a time-stamp event, without depending on
|
|
241 an external interrupt (Auto-wake-up mode).
|
|
242
|
|
243 (+) RTC auto-wake-up (AWU) from the Stop and Standby modes
|
|
244
|
|
245 (++) To wake up from the Stop mode with an RTC alarm event, it is necessary to
|
|
246 configure the RTC to generate the RTC alarm using the HAL_RTC_SetAlarm_IT() function.
|
|
247
|
|
248 (++) To wake up from the Stop mode with an RTC Tamper or time stamp event, it
|
|
249 is necessary to configure the RTC to detect the tamper or time stamp event using the
|
|
250 HAL_RTCEx_SetTimeStamp_IT() or HAL_RTCEx_SetTamper_IT() functions.
|
|
251
|
|
252 (++) To wake up from the Stop mode with an RTC Wake-up event, it is necessary to
|
|
253 configure the RTC to generate the RTC Wake-up event using the HAL_RTCEx_SetWakeUpTimer_IT() function.
|
|
254
|
|
255 @endverbatim
|
|
256 * @{
|
|
257 */
|
|
258
|
|
259 /**
|
|
260 * @brief Configures the voltage threshold detected by the Power Voltage Detector(PVD).
|
|
261 * @param sConfigPVD: pointer to an PWR_PVDTypeDef structure that contains the configuration
|
|
262 * information for the PVD.
|
|
263 * @note Refer to the electrical characteristics of your device datasheet for
|
|
264 * more details about the voltage threshold corresponding to each
|
|
265 * detection level.
|
|
266 * @retval None
|
|
267 */
|
|
268 void HAL_PWR_ConfigPVD(PWR_PVDTypeDef *sConfigPVD)
|
|
269 {
|
|
270 /* Check the parameters */
|
|
271 assert_param(IS_PWR_PVD_LEVEL(sConfigPVD->PVDLevel));
|
|
272 assert_param(IS_PWR_PVD_MODE(sConfigPVD->Mode));
|
|
273
|
|
274 /* Set PLS[7:5] bits according to PVDLevel value */
|
|
275 MODIFY_REG(PWR->CR, PWR_CR_PLS, sConfigPVD->PVDLevel);
|
|
276
|
|
277 /* Clear any previous config. Keep it clear if no event or IT mode is selected */
|
|
278 __HAL_PWR_PVD_EXTI_DISABLE_EVENT();
|
|
279 __HAL_PWR_PVD_EXTI_DISABLE_IT();
|
|
280 __HAL_PWR_PVD_EXTI_DISABLE_RISING_EDGE();
|
|
281 __HAL_PWR_PVD_EXTI_DISABLE_FALLING_EDGE();
|
|
282
|
|
283 /* Configure interrupt mode */
|
|
284 if((sConfigPVD->Mode & PVD_MODE_IT) == PVD_MODE_IT)
|
|
285 {
|
|
286 __HAL_PWR_PVD_EXTI_ENABLE_IT();
|
|
287 }
|
|
288
|
|
289 /* Configure event mode */
|
|
290 if((sConfigPVD->Mode & PVD_MODE_EVT) == PVD_MODE_EVT)
|
|
291 {
|
|
292 __HAL_PWR_PVD_EXTI_ENABLE_EVENT();
|
|
293 }
|
|
294
|
|
295 /* Configure the edge */
|
|
296 if((sConfigPVD->Mode & PVD_RISING_EDGE) == PVD_RISING_EDGE)
|
|
297 {
|
|
298 __HAL_PWR_PVD_EXTI_ENABLE_RISING_EDGE();
|
|
299 }
|
|
300
|
|
301 if((sConfigPVD->Mode & PVD_FALLING_EDGE) == PVD_FALLING_EDGE)
|
|
302 {
|
|
303 __HAL_PWR_PVD_EXTI_ENABLE_FALLING_EDGE();
|
|
304 }
|
|
305 }
|
|
306
|
|
307 /**
|
|
308 * @brief Enables the Power Voltage Detector(PVD).
|
|
309 * @retval None
|
|
310 */
|
|
311 void HAL_PWR_EnablePVD(void)
|
|
312 {
|
|
313 *(__IO uint32_t *) CR_PVDE_BB = (uint32_t)ENABLE;
|
|
314 }
|
|
315
|
|
316 /**
|
|
317 * @brief Disables the Power Voltage Detector(PVD).
|
|
318 * @retval None
|
|
319 */
|
|
320 void HAL_PWR_DisablePVD(void)
|
|
321 {
|
|
322 *(__IO uint32_t *) CR_PVDE_BB = (uint32_t)DISABLE;
|
|
323 }
|
|
324
|
|
325 /**
|
|
326 * @brief Enables the Wake-up PINx functionality.
|
|
327 * @param WakeUpPinx: Specifies the Power Wake-Up pin to enable.
|
|
328 * This parameter can be one of the following values:
|
|
329 * @arg PWR_WAKEUP_PIN1
|
|
330 * @retval None
|
|
331 */
|
|
332 void HAL_PWR_EnableWakeUpPin(uint32_t WakeUpPinx)
|
|
333 {
|
|
334 /* Check the parameter */
|
|
335 assert_param(IS_PWR_WAKEUP_PIN(WakeUpPinx));
|
|
336 *(__IO uint32_t *) CSR_EWUP_BB = (uint32_t)ENABLE;
|
|
337 }
|
|
338
|
|
339 /**
|
|
340 * @brief Disables the Wake-up PINx functionality.
|
|
341 * @param WakeUpPinx: Specifies the Power Wake-Up pin to disable.
|
|
342 * This parameter can be one of the following values:
|
|
343 * @arg PWR_WAKEUP_PIN1
|
|
344 * @retval None
|
|
345 */
|
|
346 void HAL_PWR_DisableWakeUpPin(uint32_t WakeUpPinx)
|
|
347 {
|
|
348 /* Check the parameter */
|
|
349 assert_param(IS_PWR_WAKEUP_PIN(WakeUpPinx));
|
|
350 *(__IO uint32_t *) CSR_EWUP_BB = (uint32_t)DISABLE;
|
|
351 }
|
|
352
|
|
353 /**
|
|
354 * @brief Enters Sleep mode.
|
|
355 *
|
|
356 * @note In Sleep mode, all I/O pins keep the same state as in Run mode.
|
|
357 *
|
|
358 * @note In Sleep mode, the systick is stopped to avoid exit from this mode with
|
|
359 * systick interrupt when used as time base for Timeout
|
|
360 *
|
|
361 * @param Regulator: Specifies the regulator state in SLEEP mode.
|
|
362 * This parameter can be one of the following values:
|
|
363 * @arg PWR_MAINREGULATOR_ON: SLEEP mode with regulator ON
|
|
364 * @arg PWR_LOWPOWERREGULATOR_ON: SLEEP mode with low power regulator ON
|
|
365 * @note This parameter is not used for the STM32F4 family and is kept as parameter
|
|
366 * just to maintain compatibility with the lower power families.
|
|
367 * @param SLEEPEntry: Specifies if SLEEP mode in entered with WFI or WFE instruction.
|
|
368 * This parameter can be one of the following values:
|
|
369 * @arg PWR_SLEEPENTRY_WFI: enter SLEEP mode with WFI instruction
|
|
370 * @arg PWR_SLEEPENTRY_WFE: enter SLEEP mode with WFE instruction
|
|
371 * @retval None
|
|
372 */
|
|
373 void HAL_PWR_EnterSLEEPMode(uint32_t Regulator, uint8_t SLEEPEntry)
|
|
374 {
|
|
375 /* Check the parameters */
|
|
376 assert_param(IS_PWR_REGULATOR(Regulator));
|
|
377 assert_param(IS_PWR_SLEEP_ENTRY(SLEEPEntry));
|
|
378
|
|
379 /* Clear SLEEPDEEP bit of Cortex System Control Register */
|
|
380 CLEAR_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPDEEP_Msk));
|
|
381
|
|
382 /* Select SLEEP mode entry -------------------------------------------------*/
|
|
383 if(SLEEPEntry == PWR_SLEEPENTRY_WFI)
|
|
384 {
|
|
385 /* Request Wait For Interrupt */
|
|
386 __WFI();
|
|
387 }
|
|
388 else
|
|
389 {
|
|
390 /* Request Wait For Event */
|
|
391 __SEV();
|
|
392 __WFE();
|
|
393 __WFE();
|
|
394 }
|
|
395 }
|
|
396
|
|
397 /**
|
|
398 * @brief Enters Stop mode.
|
|
399 * @note In Stop mode, all I/O pins keep the same state as in Run mode.
|
|
400 * @note When exiting Stop mode by issuing an interrupt or a wake-up event,
|
|
401 * the HSI RC oscillator is selected as system clock.
|
|
402 * @note When the voltage regulator operates in low power mode, an additional
|
|
403 * startup delay is incurred when waking up from Stop mode.
|
|
404 * By keeping the internal regulator ON during Stop mode, the consumption
|
|
405 * is higher although the startup time is reduced.
|
|
406 * @param Regulator: Specifies the regulator state in Stop mode.
|
|
407 * This parameter can be one of the following values:
|
|
408 * @arg PWR_MAINREGULATOR_ON: Stop mode with regulator ON
|
|
409 * @arg PWR_LOWPOWERREGULATOR_ON: Stop mode with low power regulator ON
|
|
410 * @param STOPEntry: Specifies if Stop mode in entered with WFI or WFE instruction.
|
|
411 * This parameter can be one of the following values:
|
|
412 * @arg PWR_STOPENTRY_WFI: Enter Stop mode with WFI instruction
|
|
413 * @arg PWR_STOPENTRY_WFE: Enter Stop mode with WFE instruction
|
|
414 * @retval None
|
|
415 */
|
|
416 void HAL_PWR_EnterSTOPMode(uint32_t Regulator, uint8_t STOPEntry)
|
|
417 {
|
|
418 /* Check the parameters */
|
|
419 assert_param(IS_PWR_REGULATOR(Regulator));
|
|
420 assert_param(IS_PWR_STOP_ENTRY(STOPEntry));
|
|
421
|
|
422 /* Select the regulator state in Stop mode: Set PDDS and LPDS bits according to PWR_Regulator value */
|
|
423 MODIFY_REG(PWR->CR, (PWR_CR_PDDS | PWR_CR_LPDS), Regulator);
|
|
424
|
|
425 /* Set SLEEPDEEP bit of Cortex System Control Register */
|
|
426 SET_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPDEEP_Msk));
|
|
427
|
|
428 /* Select Stop mode entry --------------------------------------------------*/
|
|
429 if(STOPEntry == PWR_STOPENTRY_WFI)
|
|
430 {
|
|
431 /* Request Wait For Interrupt */
|
|
432 __WFI();
|
|
433 }
|
|
434 else
|
|
435 {
|
|
436 /* Request Wait For Event */
|
|
437 __SEV();
|
|
438 __WFE();
|
|
439 __WFE();
|
|
440 }
|
|
441 /* Reset SLEEPDEEP bit of Cortex System Control Register */
|
|
442 CLEAR_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPDEEP_Msk));
|
|
443 }
|
|
444
|
|
445 /**
|
|
446 * @brief Enters Standby mode.
|
|
447 * @note In Standby mode, all I/O pins are high impedance except for:
|
|
448 * - Reset pad (still available)
|
|
449 * - RTC_AF1 pin (PC13) if configured for tamper, time-stamp, RTC
|
|
450 * Alarm out, or RTC clock calibration out.
|
|
451 * - RTC_AF2 pin (PI8) if configured for tamper or time-stamp.
|
|
452 * - WKUP pin 1 (PA0) if enabled.
|
|
453 * @retval None
|
|
454 */
|
|
455 void HAL_PWR_EnterSTANDBYMode(void)
|
|
456 {
|
|
457 /* Select Standby mode */
|
|
458 SET_BIT(PWR->CR, PWR_CR_PDDS);
|
|
459
|
|
460 /* Set SLEEPDEEP bit of Cortex System Control Register */
|
|
461 SET_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPDEEP_Msk));
|
|
462
|
|
463 /* This option is used to ensure that store operations are completed */
|
|
464 #if defined ( __CC_ARM)
|
|
465 __force_stores();
|
|
466 #endif
|
|
467 /* Request Wait For Interrupt */
|
|
468 __WFI();
|
|
469 }
|
|
470
|
|
471 /**
|
|
472 * @brief This function handles the PWR PVD interrupt request.
|
|
473 * @note This API should be called under the PVD_IRQHandler().
|
|
474 * @retval None
|
|
475 */
|
|
476 void HAL_PWR_PVD_IRQHandler(void)
|
|
477 {
|
|
478 /* Check PWR Exti flag */
|
|
479 if(__HAL_PWR_PVD_EXTI_GET_FLAG() != RESET)
|
|
480 {
|
|
481 /* PWR PVD interrupt user callback */
|
|
482 HAL_PWR_PVDCallback();
|
|
483
|
|
484 /* Clear PWR Exti pending bit */
|
|
485 __HAL_PWR_PVD_EXTI_CLEAR_FLAG();
|
|
486 }
|
|
487 }
|
|
488
|
|
489 /**
|
|
490 * @brief PWR PVD interrupt callback
|
|
491 * @retval None
|
|
492 */
|
|
493 __weak void HAL_PWR_PVDCallback(void)
|
|
494 {
|
|
495 /* NOTE : This function Should not be modified, when the callback is needed,
|
|
496 the HAL_PWR_PVDCallback could be implemented in the user file
|
|
497 */
|
|
498 }
|
|
499
|
|
500 /**
|
|
501 * @brief Indicates Sleep-On-Exit when returning from Handler mode to Thread mode.
|
|
502 * @note Set SLEEPONEXIT bit of SCR register. When this bit is set, the processor
|
|
503 * re-enters SLEEP mode when an interruption handling is over.
|
|
504 * Setting this bit is useful when the processor is expected to run only on
|
|
505 * interruptions handling.
|
|
506 * @retval None
|
|
507 */
|
|
508 void HAL_PWR_EnableSleepOnExit(void)
|
|
509 {
|
|
510 /* Set SLEEPONEXIT bit of Cortex System Control Register */
|
|
511 SET_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPONEXIT_Msk));
|
|
512 }
|
|
513
|
|
514 /**
|
|
515 * @brief Disables Sleep-On-Exit feature when returning from Handler mode to Thread mode.
|
|
516 * @note Clears SLEEPONEXIT bit of SCR register. When this bit is set, the processor
|
|
517 * re-enters SLEEP mode when an interruption handling is over.
|
|
518 * @retval None
|
|
519 */
|
|
520 void HAL_PWR_DisableSleepOnExit(void)
|
|
521 {
|
|
522 /* Clear SLEEPONEXIT bit of Cortex System Control Register */
|
|
523 CLEAR_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPONEXIT_Msk));
|
|
524 }
|
|
525
|
|
526 /**
|
|
527 * @brief Enables CORTEX M4 SEVONPEND bit.
|
|
528 * @note Sets SEVONPEND bit of SCR register. When this bit is set, this causes
|
|
529 * WFE to wake up when an interrupt moves from inactive to pended.
|
|
530 * @retval None
|
|
531 */
|
|
532 void HAL_PWR_EnableSEVOnPend(void)
|
|
533 {
|
|
534 /* Set SEVONPEND bit of Cortex System Control Register */
|
|
535 SET_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SEVONPEND_Msk));
|
|
536 }
|
|
537
|
|
538 /**
|
|
539 * @brief Disables CORTEX M4 SEVONPEND bit.
|
|
540 * @note Clears SEVONPEND bit of SCR register. When this bit is set, this causes
|
|
541 * WFE to wake up when an interrupt moves from inactive to pended.
|
|
542 * @retval None
|
|
543 */
|
|
544 void HAL_PWR_DisableSEVOnPend(void)
|
|
545 {
|
|
546 /* Clear SEVONPEND bit of Cortex System Control Register */
|
|
547 CLEAR_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SEVONPEND_Msk));
|
|
548 }
|
|
549
|
|
550 /**
|
|
551 * @}
|
|
552 */
|
|
553
|
|
554 /**
|
|
555 * @}
|
|
556 */
|
|
557
|
|
558 #endif /* HAL_PWR_MODULE_ENABLED */
|
|
559 /**
|
|
560 * @}
|
|
561 */
|
|
562
|
|
563 /**
|
|
564 * @}
|
|
565 */
|
|
566
|
|
567 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|