2 ******************************************************************************
\r
3 * @file stm32l4xx_hal_pwr.c
\r
4 * @author MCD Application Team
\r
5 * @brief PWR HAL module driver.
\r
6 * This file provides firmware functions to manage the following
\r
7 * functionalities of the Power Controller (PWR) peripheral:
\r
8 * + Initialization/de-initialization functions
\r
9 * + Peripheral Control functions
\r
11 ******************************************************************************
\r
14 * <h2><center>© Copyright (c) 2017 STMicroelectronics.
\r
15 * All rights reserved.</center></h2>
\r
17 * This software component is licensed by ST under BSD 3-Clause license,
\r
18 * the "License"; You may not use this file except in compliance with the
\r
19 * License. You may obtain a copy of the License at:
\r
20 * opensource.org/licenses/BSD-3-Clause
\r
22 ******************************************************************************
\r
25 /* Includes ------------------------------------------------------------------*/
\r
26 #include "stm32l4xx_hal.h"
\r
28 /** @addtogroup STM32L4xx_HAL_Driver
\r
32 /** @defgroup PWR PWR
\r
33 * @brief PWR HAL module driver
\r
37 #ifdef HAL_PWR_MODULE_ENABLED
\r
39 /* Private typedef -----------------------------------------------------------*/
\r
40 /* Private define ------------------------------------------------------------*/
\r
42 /** @defgroup PWR_Private_Defines PWR Private Defines
\r
46 /** @defgroup PWR_PVD_Mode_Mask PWR PVD Mode Mask
\r
49 #define PVD_MODE_IT ((uint32_t)0x00010000) /*!< Mask for interruption yielded by PVD threshold crossing */
\r
50 #define PVD_MODE_EVT ((uint32_t)0x00020000) /*!< Mask for event yielded by PVD threshold crossing */
\r
51 #define PVD_RISING_EDGE ((uint32_t)0x00000001) /*!< Mask for rising edge set as PVD trigger */
\r
52 #define PVD_FALLING_EDGE ((uint32_t)0x00000002) /*!< Mask for falling edge set as PVD trigger */
\r
61 /* Private macro -------------------------------------------------------------*/
\r
62 /* Private variables ---------------------------------------------------------*/
\r
63 /* Private function prototypes -----------------------------------------------*/
\r
64 /* Exported functions --------------------------------------------------------*/
\r
66 /** @defgroup PWR_Exported_Functions PWR Exported Functions
\r
70 /** @defgroup PWR_Exported_Functions_Group1 Initialization and de-initialization functions
\r
71 * @brief Initialization and de-initialization functions
\r
74 ===============================================================================
\r
75 ##### Initialization and de-initialization functions #####
\r
76 ===============================================================================
\r
84 * @brief Deinitialize the HAL PWR peripheral registers to their default reset values.
\r
87 void HAL_PWR_DeInit(void)
\r
89 __HAL_RCC_PWR_FORCE_RESET();
\r
90 __HAL_RCC_PWR_RELEASE_RESET();
\r
94 * @brief Enable access to the backup domain
\r
95 * (RTC registers, RTC backup data registers).
\r
96 * @note After reset, the backup domain is protected against
\r
97 * possible unwanted write accesses.
\r
98 * @note RTCSEL that sets the RTC clock source selection is in the RTC back-up domain.
\r
99 * In order to set or modify the RTC clock, the backup domain access must be
\r
101 * @note LSEON bit that switches on and off the LSE crystal belongs as well to the
\r
105 void HAL_PWR_EnableBkUpAccess(void)
\r
107 SET_BIT(PWR->CR1, PWR_CR1_DBP);
\r
111 * @brief Disable access to the backup domain
\r
112 * (RTC registers, RTC backup data registers).
\r
115 void HAL_PWR_DisableBkUpAccess(void)
\r
117 CLEAR_BIT(PWR->CR1, PWR_CR1_DBP);
\r
129 /** @defgroup PWR_Exported_Functions_Group2 Peripheral Control functions
\r
130 * @brief Low Power modes configuration functions
\r
134 ===============================================================================
\r
135 ##### Peripheral Control functions #####
\r
136 ===============================================================================
\r
139 *** PVD configuration ***
\r
140 =========================
\r
142 (+) The PVD is used to monitor the VDD power supply by comparing it to a
\r
143 threshold selected by the PVD Level (PLS[2:0] bits in PWR_CR2 register).
\r
145 (+) PVDO flag is available to indicate if VDD/VDDA is higher or lower
\r
146 than the PVD threshold. This event is internally connected to the EXTI
\r
147 line16 and can generate an interrupt if enabled. This is done through
\r
148 __HAL_PVD_EXTI_ENABLE_IT() macro.
\r
149 (+) The PVD is stopped in Standby mode.
\r
152 *** WakeUp pin configuration ***
\r
153 ================================
\r
155 (+) WakeUp pins are used to wakeup the system from Standby mode or Shutdown mode.
\r
156 The polarity of these pins can be set to configure event detection on high
\r
157 level (rising edge) or low level (falling edge).
\r
161 *** Low Power modes configuration ***
\r
162 =====================================
\r
164 The devices feature 8 low-power modes:
\r
165 (+) Low-power Run mode: core and peripherals are running, main regulator off, low power regulator on.
\r
166 (+) Sleep mode: Cortex-M4 core stopped, peripherals kept running, main and low power regulators on.
\r
167 (+) Low-power Sleep mode: Cortex-M4 core stopped, peripherals kept running, main regulator off, low power regulator on.
\r
168 (+) Stop 0 mode: all clocks are stopped except LSI and LSE, main and low power regulators on.
\r
169 (+) Stop 1 mode: all clocks are stopped except LSI and LSE, main regulator off, low power regulator on.
\r
170 (+) Stop 2 mode: all clocks are stopped except LSI and LSE, main regulator off, low power regulator on, reduced set of waking up IPs compared to Stop 1 mode.
\r
171 (+) Standby mode with SRAM2: all clocks are stopped except LSI and LSE, SRAM2 content preserved, main regulator off, low power regulator on.
\r
172 (+) Standby mode without SRAM2: all clocks are stopped except LSI and LSE, main and low power regulators off.
\r
173 (+) Shutdown mode: all clocks are stopped except LSE, main and low power regulators off.
\r
176 *** Low-power run mode ***
\r
177 ==========================
\r
179 (+) Entry: (from main run mode)
\r
180 (++) set LPR bit with HAL_PWREx_EnableLowPowerRunMode() API after having decreased the system clock below 2 MHz.
\r
183 (++) clear LPR bit then wait for REGLP bit to be reset with HAL_PWREx_DisableLowPowerRunMode() API. Only
\r
184 then can the system clock frequency be increased above 2 MHz.
\r
187 *** Sleep mode / Low-power sleep mode ***
\r
188 =========================================
\r
191 The Sleep mode / Low-power Sleep mode is entered thru HAL_PWR_EnterSLEEPMode() API
\r
192 in specifying whether or not the regulator is forced to low-power mode and if exit is interrupt or event-triggered.
\r
193 (++) PWR_MAINREGULATOR_ON: Sleep mode (regulator in main mode).
\r
194 (++) PWR_LOWPOWERREGULATOR_ON: Low-power sleep (regulator in low power mode).
\r
195 In the latter case, the system clock frequency must have been decreased below 2 MHz beforehand.
\r
196 (++) PWR_SLEEPENTRY_WFI: enter SLEEP mode with WFI instruction
\r
197 (++) PWR_SLEEPENTRY_WFE: enter SLEEP mode with WFE instruction
\r
200 (++) Any peripheral interrupt acknowledged by the nested vectored interrupt
\r
201 controller (NVIC) or any wake-up event.
\r
204 (++) Any wake-up event such as an EXTI line configured in event mode.
\r
206 [..] When exiting the Low-power sleep mode by issuing an interrupt or a wakeup event,
\r
207 the MCU is in Low-power Run mode.
\r
209 *** Stop 0, Stop 1 and Stop 2 modes ***
\r
210 ===============================
\r
213 The Stop 0, Stop 1 or Stop 2 modes are entered thru the following API's:
\r
214 (++) HAL_PWREx_EnterSTOP0Mode() for mode 0 or HAL_PWREx_EnterSTOP1Mode() for mode 1 or for porting reasons HAL_PWR_EnterSTOPMode().
\r
215 (++) HAL_PWREx_EnterSTOP2Mode() for mode 2.
\r
216 (+) Regulator setting (applicable to HAL_PWR_EnterSTOPMode() only):
\r
217 (++) PWR_MAINREGULATOR_ON
\r
218 (++) PWR_LOWPOWERREGULATOR_ON
\r
219 (+) Exit (interrupt or event-triggered, specified when entering STOP mode):
\r
220 (++) PWR_STOPENTRY_WFI: enter Stop mode with WFI instruction
\r
221 (++) PWR_STOPENTRY_WFE: enter Stop mode with WFE instruction
\r
224 (++) Any EXTI Line (Internal or External) configured in Interrupt mode.
\r
225 (++) Some specific communication peripherals (USART, LPUART, I2C) interrupts
\r
226 when programmed in wakeup mode.
\r
228 (++) Any EXTI Line (Internal or External) configured in Event mode.
\r
231 When exiting Stop 0 and Stop 1 modes, the MCU is either in Run mode or in Low-power Run mode
\r
232 depending on the LPR bit setting.
\r
233 When exiting Stop 2 mode, the MCU is in Run mode.
\r
235 *** Standby mode ***
\r
236 ====================
\r
238 The Standby mode offers two options:
\r
239 (+) option a) all clocks off except LSI and LSE, RRS bit set (keeps voltage regulator in low power mode).
\r
240 SRAM and registers contents are lost except for the SRAM2 content, the RTC registers, RTC backup registers
\r
241 and Standby circuitry.
\r
242 (+) option b) all clocks off except LSI and LSE, RRS bit cleared (voltage regulator then disabled).
\r
243 SRAM and register contents are lost except for the RTC registers, RTC backup registers
\r
244 and Standby circuitry.
\r
247 (+++) The Standby mode is entered thru HAL_PWR_EnterSTANDBYMode() API.
\r
248 SRAM1 and register contents are lost except for registers in the Backup domain and
\r
249 Standby circuitry. SRAM2 content can be preserved if the bit RRS is set in PWR_CR3 register.
\r
250 To enable this feature, the user can resort to HAL_PWREx_EnableSRAM2ContentRetention() API
\r
254 (+++) WKUP pin rising edge, RTC alarm or wakeup, tamper event, time-stamp event,
\r
255 external reset in NRST pin, IWDG reset.
\r
257 [..] After waking up from Standby mode, program execution restarts in the same way as after a Reset.
\r
260 *** Shutdown mode ***
\r
261 ======================
\r
264 voltage regulator is disabled, all clocks are off except LSE, RRS bit is cleared.
\r
265 SRAM and registers contents are lost except for backup domain registers.
\r
268 The Shutdown mode is entered thru HAL_PWREx_EnterSHUTDOWNMode() API.
\r
271 (++) WKUP pin rising edge, RTC alarm or wakeup, tamper event, time-stamp event,
\r
272 external reset in NRST pin.
\r
274 [..] After waking up from Shutdown mode, program execution restarts in the same way as after a Reset.
\r
277 *** Auto-wakeup (AWU) from low-power mode ***
\r
278 =============================================
\r
280 The MCU can be woken up from low-power mode by an RTC Alarm event, an RTC
\r
281 Wakeup event, a tamper event or a time-stamp event, without depending on
\r
282 an external interrupt (Auto-wakeup mode).
\r
284 (+) RTC auto-wakeup (AWU) from the Stop, Standby and Shutdown modes
\r
287 (++) To wake up from the Stop mode with an RTC alarm event, it is necessary to
\r
288 configure the RTC to generate the RTC alarm using the HAL_RTC_SetAlarm_IT() function.
\r
290 (++) To wake up from the Stop mode with an RTC Tamper or time stamp event, it
\r
291 is necessary to configure the RTC to detect the tamper or time stamp event using the
\r
292 HAL_RTCEx_SetTimeStamp_IT() or HAL_RTCEx_SetTamper_IT() functions.
\r
294 (++) To wake up from the Stop mode with an RTC WakeUp event, it is necessary to
\r
295 configure the RTC to generate the RTC WakeUp event using the HAL_RTCEx_SetWakeUpTimer_IT() function.
\r
304 * @brief Configure the voltage threshold detected by the Power Voltage Detector (PVD).
\r
305 * @param sConfigPVD: pointer to a PWR_PVDTypeDef structure that contains the PVD
\r
306 * configuration information.
\r
307 * @note Refer to the electrical characteristics of your device datasheet for
\r
308 * more details about the voltage thresholds corresponding to each
\r
312 HAL_StatusTypeDef HAL_PWR_ConfigPVD(PWR_PVDTypeDef *sConfigPVD)
\r
314 /* Check the parameters */
\r
315 assert_param(IS_PWR_PVD_LEVEL(sConfigPVD->PVDLevel));
\r
316 assert_param(IS_PWR_PVD_MODE(sConfigPVD->Mode));
\r
318 /* Set PLS bits according to PVDLevel value */
\r
319 MODIFY_REG(PWR->CR2, PWR_CR2_PLS, sConfigPVD->PVDLevel);
\r
321 /* Clear any previous config. Keep it clear if no event or IT mode is selected */
\r
322 __HAL_PWR_PVD_EXTI_DISABLE_EVENT();
\r
323 __HAL_PWR_PVD_EXTI_DISABLE_IT();
\r
324 __HAL_PWR_PVD_EXTI_DISABLE_FALLING_EDGE();
\r
325 __HAL_PWR_PVD_EXTI_DISABLE_RISING_EDGE();
\r
327 /* Configure interrupt mode */
\r
328 if((sConfigPVD->Mode & PVD_MODE_IT) == PVD_MODE_IT)
\r
330 __HAL_PWR_PVD_EXTI_ENABLE_IT();
\r
333 /* Configure event mode */
\r
334 if((sConfigPVD->Mode & PVD_MODE_EVT) == PVD_MODE_EVT)
\r
336 __HAL_PWR_PVD_EXTI_ENABLE_EVENT();
\r
339 /* Configure the edge */
\r
340 if((sConfigPVD->Mode & PVD_RISING_EDGE) == PVD_RISING_EDGE)
\r
342 __HAL_PWR_PVD_EXTI_ENABLE_RISING_EDGE();
\r
345 if((sConfigPVD->Mode & PVD_FALLING_EDGE) == PVD_FALLING_EDGE)
\r
347 __HAL_PWR_PVD_EXTI_ENABLE_FALLING_EDGE();
\r
355 * @brief Enable the Power Voltage Detector (PVD).
\r
358 void HAL_PWR_EnablePVD(void)
\r
360 SET_BIT(PWR->CR2, PWR_CR2_PVDE);
\r
364 * @brief Disable the Power Voltage Detector (PVD).
\r
367 void HAL_PWR_DisablePVD(void)
\r
369 CLEAR_BIT(PWR->CR2, PWR_CR2_PVDE);
\r
376 * @brief Enable the WakeUp PINx functionality.
\r
377 * @param WakeUpPinPolarity: Specifies which Wake-Up pin to enable.
\r
378 * This parameter can be one of the following legacy values which set the default polarity
\r
379 * i.e. detection on high level (rising edge):
\r
380 * @arg @ref PWR_WAKEUP_PIN1, PWR_WAKEUP_PIN2, PWR_WAKEUP_PIN3, PWR_WAKEUP_PIN4, PWR_WAKEUP_PIN5
\r
382 * or one of the following value where the user can explicitly specify the enabled pin and
\r
383 * the chosen polarity:
\r
384 * @arg @ref PWR_WAKEUP_PIN1_HIGH or PWR_WAKEUP_PIN1_LOW
\r
385 * @arg @ref PWR_WAKEUP_PIN2_HIGH or PWR_WAKEUP_PIN2_LOW
\r
386 * @arg @ref PWR_WAKEUP_PIN3_HIGH or PWR_WAKEUP_PIN3_LOW
\r
387 * @arg @ref PWR_WAKEUP_PIN4_HIGH or PWR_WAKEUP_PIN4_LOW
\r
388 * @arg @ref PWR_WAKEUP_PIN5_HIGH or PWR_WAKEUP_PIN5_LOW
\r
389 * @note PWR_WAKEUP_PINx and PWR_WAKEUP_PINx_HIGH are equivalent.
\r
392 void HAL_PWR_EnableWakeUpPin(uint32_t WakeUpPinPolarity)
\r
394 assert_param(IS_PWR_WAKEUP_PIN(WakeUpPinPolarity));
\r
396 /* Specifies the Wake-Up pin polarity for the event detection
\r
397 (rising or falling edge) */
\r
398 MODIFY_REG(PWR->CR4, (PWR_CR3_EWUP & WakeUpPinPolarity), (WakeUpPinPolarity >> PWR_WUP_POLARITY_SHIFT));
\r
400 /* Enable wake-up pin */
\r
401 SET_BIT(PWR->CR3, (PWR_CR3_EWUP & WakeUpPinPolarity));
\r
407 * @brief Disable the WakeUp PINx functionality.
\r
408 * @param WakeUpPinx: Specifies the Power Wake-Up pin to disable.
\r
409 * This parameter can be one of the following values:
\r
410 * @arg @ref PWR_WAKEUP_PIN1, PWR_WAKEUP_PIN2, PWR_WAKEUP_PIN3, PWR_WAKEUP_PIN4, PWR_WAKEUP_PIN5
\r
413 void HAL_PWR_DisableWakeUpPin(uint32_t WakeUpPinx)
\r
415 assert_param(IS_PWR_WAKEUP_PIN(WakeUpPinx));
\r
417 CLEAR_BIT(PWR->CR3, (PWR_CR3_EWUP & WakeUpPinx));
\r
422 * @brief Enter Sleep or Low-power Sleep mode.
\r
423 * @note In Sleep/Low-power Sleep mode, all I/O pins keep the same state as in Run mode.
\r
424 * @param Regulator: Specifies the regulator state in Sleep/Low-power Sleep mode.
\r
425 * This parameter can be one of the following values:
\r
426 * @arg @ref PWR_MAINREGULATOR_ON Sleep mode (regulator in main mode)
\r
427 * @arg @ref PWR_LOWPOWERREGULATOR_ON Low-power Sleep mode (regulator in low-power mode)
\r
428 * @note Low-power Sleep mode is entered from Low-power Run mode. Therefore, if not yet
\r
429 * in Low-power Run mode before calling HAL_PWR_EnterSLEEPMode() with Regulator set
\r
430 * to PWR_LOWPOWERREGULATOR_ON, the user can optionally configure the
\r
431 * Flash in power-down monde in setting the SLEEP_PD bit in FLASH_ACR register.
\r
432 * Additionally, the clock frequency must be reduced below 2 MHz.
\r
433 * Setting SLEEP_PD in FLASH_ACR then appropriately reducing the clock frequency must
\r
434 * be done before calling HAL_PWR_EnterSLEEPMode() API.
\r
435 * @note When exiting Low-power Sleep mode, the MCU is in Low-power Run mode. To move in
\r
436 * Run mode, the user must resort to HAL_PWREx_DisableLowPowerRunMode() API.
\r
437 * @param SLEEPEntry: Specifies if Sleep mode is entered with WFI or WFE instruction.
\r
438 * This parameter can be one of the following values:
\r
439 * @arg @ref PWR_SLEEPENTRY_WFI enter Sleep or Low-power Sleep mode with WFI instruction
\r
440 * @arg @ref PWR_SLEEPENTRY_WFE enter Sleep or Low-power Sleep mode with WFE instruction
\r
441 * @note When WFI entry is used, tick interrupt have to be disabled if not desired as
\r
442 * the interrupt wake up source.
\r
445 void HAL_PWR_EnterSLEEPMode(uint32_t Regulator, uint8_t SLEEPEntry)
\r
447 /* Check the parameters */
\r
448 assert_param(IS_PWR_REGULATOR(Regulator));
\r
449 assert_param(IS_PWR_SLEEP_ENTRY(SLEEPEntry));
\r
451 /* Set Regulator parameter */
\r
452 if (Regulator == PWR_MAINREGULATOR_ON)
\r
454 /* If in low-power run mode at this point, exit it */
\r
455 if (HAL_IS_BIT_SET(PWR->SR2, PWR_SR2_REGLPF))
\r
457 if (HAL_PWREx_DisableLowPowerRunMode() != HAL_OK)
\r
462 /* Regulator now in main mode. */
\r
466 /* If in run mode, first move to low-power run mode.
\r
467 The system clock frequency must be below 2 MHz at this point. */
\r
468 if (HAL_IS_BIT_SET(PWR->SR2, PWR_SR2_REGLPF) == RESET)
\r
470 HAL_PWREx_EnableLowPowerRunMode();
\r
474 /* Clear SLEEPDEEP bit of Cortex System Control Register */
\r
475 CLEAR_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPDEEP_Msk));
\r
477 /* Select SLEEP mode entry -------------------------------------------------*/
\r
478 if(SLEEPEntry == PWR_SLEEPENTRY_WFI)
\r
480 /* Request Wait For Interrupt */
\r
485 /* Request Wait For Event */
\r
495 * @brief Enter Stop mode
\r
496 * @note This API is named HAL_PWR_EnterSTOPMode to ensure compatibility with legacy code running
\r
497 * on devices where only "Stop mode" is mentioned with main or low power regulator ON.
\r
498 * @note In Stop mode, all I/O pins keep the same state as in Run mode.
\r
499 * @note All clocks in the VCORE domain are stopped; the PLL, the MSI,
\r
500 * the HSI and the HSE oscillators are disabled. Some peripherals with the wakeup capability
\r
501 * (I2Cx, USARTx and LPUART) can switch on the HSI to receive a frame, and switch off the HSI
\r
502 * after receiving the frame if it is not a wakeup frame. In this case, the HSI clock is propagated
\r
503 * only to the peripheral requesting it.
\r
504 * SRAM1, SRAM2 and register contents are preserved.
\r
505 * The BOR is available.
\r
506 * The voltage regulator can be configured either in normal (Stop 0) or low-power mode (Stop 1).
\r
507 * @note When exiting Stop 0 or Stop 1 mode by issuing an interrupt or a wakeup event,
\r
508 * the HSI RC oscillator is selected as system clock if STOPWUCK bit in RCC_CFGR register
\r
509 * is set; the MSI oscillator is selected if STOPWUCK is cleared.
\r
510 * @note When the voltage regulator operates in low power mode (Stop 1), an additional
\r
511 * startup delay is incurred when waking up.
\r
512 * By keeping the internal regulator ON during Stop mode (Stop 0), the consumption
\r
513 * is higher although the startup time is reduced.
\r
514 * @param Regulator: Specifies the regulator state in Stop mode.
\r
515 * This parameter can be one of the following values:
\r
516 * @arg @ref PWR_MAINREGULATOR_ON Stop 0 mode (main regulator ON)
\r
517 * @arg @ref PWR_LOWPOWERREGULATOR_ON Stop 1 mode (low power regulator ON)
\r
518 * @param STOPEntry: Specifies Stop 0 or Stop 1 mode is entered with WFI or WFE instruction.
\r
519 * This parameter can be one of the following values:
\r
520 * @arg @ref PWR_STOPENTRY_WFI Enter Stop 0 or Stop 1 mode with WFI instruction.
\r
521 * @arg @ref PWR_STOPENTRY_WFE Enter Stop 0 or Stop 1 mode with WFE instruction.
\r
524 void HAL_PWR_EnterSTOPMode(uint32_t Regulator, uint8_t STOPEntry)
\r
526 /* Check the parameters */
\r
527 assert_param(IS_PWR_REGULATOR(Regulator));
\r
529 if(Regulator == PWR_LOWPOWERREGULATOR_ON)
\r
531 HAL_PWREx_EnterSTOP1Mode(STOPEntry);
\r
535 HAL_PWREx_EnterSTOP0Mode(STOPEntry);
\r
540 * @brief Enter Standby mode.
\r
541 * @note In Standby mode, the PLL, the HSI, the MSI and the HSE oscillators are switched
\r
542 * off. The voltage regulator is disabled, except when SRAM2 content is preserved
\r
543 * in which case the regulator is in low-power mode.
\r
544 * SRAM1 and register contents are lost except for registers in the Backup domain and
\r
545 * Standby circuitry. SRAM2 content can be preserved if the bit RRS is set in PWR_CR3 register.
\r
546 * To enable this feature, the user can resort to HAL_PWREx_EnableSRAM2ContentRetention() API
\r
548 * The BOR is available.
\r
549 * @note The I/Os can be configured either with a pull-up or pull-down or can be kept in analog state.
\r
550 * HAL_PWREx_EnableGPIOPullUp() and HAL_PWREx_EnableGPIOPullDown() respectively enable Pull Up and
\r
551 * Pull Down state, HAL_PWREx_DisableGPIOPullUp() and HAL_PWREx_DisableGPIOPullDown() disable the
\r
553 * These states are effective in Standby mode only if APC bit is set through
\r
554 * HAL_PWREx_EnablePullUpPullDownConfig() API.
\r
557 void HAL_PWR_EnterSTANDBYMode(void)
\r
559 /* Set Stand-by mode */
\r
560 MODIFY_REG(PWR->CR1, PWR_CR1_LPMS, PWR_CR1_LPMS_STANDBY);
\r
562 /* Set SLEEPDEEP bit of Cortex System Control Register */
\r
563 SET_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPDEEP_Msk));
\r
565 /* This option is used to ensure that store operations are completed */
\r
566 #if defined ( __CC_ARM)
\r
569 /* Request Wait For Interrupt */
\r
576 * @brief Indicate Sleep-On-Exit when returning from Handler mode to Thread mode.
\r
577 * @note Set SLEEPONEXIT bit of SCR register. When this bit is set, the processor
\r
578 * re-enters SLEEP mode when an interruption handling is over.
\r
579 * Setting this bit is useful when the processor is expected to run only on
\r
580 * interruptions handling.
\r
583 void HAL_PWR_EnableSleepOnExit(void)
\r
585 /* Set SLEEPONEXIT bit of Cortex System Control Register */
\r
586 SET_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPONEXIT_Msk));
\r
591 * @brief Disable Sleep-On-Exit feature when returning from Handler mode to Thread mode.
\r
592 * @note Clear SLEEPONEXIT bit of SCR register. When this bit is set, the processor
\r
593 * re-enters SLEEP mode when an interruption handling is over.
\r
596 void HAL_PWR_DisableSleepOnExit(void)
\r
598 /* Clear SLEEPONEXIT bit of Cortex System Control Register */
\r
599 CLEAR_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPONEXIT_Msk));
\r
605 * @brief Enable CORTEX M4 SEVONPEND bit.
\r
606 * @note Set SEVONPEND bit of SCR register. When this bit is set, this causes
\r
607 * WFE to wake up when an interrupt moves from inactive to pended.
\r
610 void HAL_PWR_EnableSEVOnPend(void)
\r
612 /* Set SEVONPEND bit of Cortex System Control Register */
\r
613 SET_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SEVONPEND_Msk));
\r
618 * @brief Disable CORTEX M4 SEVONPEND bit.
\r
619 * @note Clear SEVONPEND bit of SCR register. When this bit is set, this causes
\r
620 * WFE to wake up when an interrupt moves from inactive to pended.
\r
623 void HAL_PWR_DisableSEVOnPend(void)
\r
625 /* Clear SEVONPEND bit of Cortex System Control Register */
\r
626 CLEAR_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SEVONPEND_Msk));
\r
634 * @brief PWR PVD interrupt callback
\r
637 __weak void HAL_PWR_PVDCallback(void)
\r
639 /* NOTE : This function should not be modified; when the callback is needed,
\r
640 the HAL_PWR_PVDCallback can be implemented in the user file
\r
652 #endif /* HAL_PWR_MODULE_ENABLED */
\r
661 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
\r