stm32f1xx_hal_pwr.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618
  1. /**
  2. ******************************************************************************
  3. * @file stm32f1xx_hal_pwr.c
  4. * @author MCD Application Team
  5. * @brief PWR HAL module driver.
  6. *
  7. * This file provides firmware functions to manage the following
  8. * functionalities of the Power Controller (PWR) peripheral:
  9. * + Initialization/de-initialization functions
  10. * + Peripheral Control functions
  11. *
  12. ******************************************************************************
  13. * @attention
  14. *
  15. * Copyright (c) 2016 STMicroelectronics.
  16. * All rights reserved.
  17. *
  18. * This software is licensed under terms that can be found in the LICENSE file
  19. * in the root directory of this software component.
  20. * If no LICENSE file comes with this software, it is provided AS-IS.
  21. *
  22. ******************************************************************************
  23. */
  24. /* Includes ------------------------------------------------------------------*/
  25. #include "stm32f1xx_hal.h"
  26. /** @addtogroup STM32F1xx_HAL_Driver
  27. * @{
  28. */
  29. /** @defgroup PWR PWR
  30. * @brief PWR HAL module driver
  31. * @{
  32. */
  33. #ifdef HAL_PWR_MODULE_ENABLED
  34. /* Private typedef -----------------------------------------------------------*/
  35. /* Private define ------------------------------------------------------------*/
  36. /** @defgroup PWR_Private_Constants PWR Private Constants
  37. * @{
  38. */
  39. /** @defgroup PWR_PVD_Mode_Mask PWR PVD Mode Mask
  40. * @{
  41. */
  42. #define PVD_MODE_IT 0x00010000U
  43. #define PVD_MODE_EVT 0x00020000U
  44. #define PVD_RISING_EDGE 0x00000001U
  45. #define PVD_FALLING_EDGE 0x00000002U
  46. /**
  47. * @}
  48. */
  49. /** @defgroup PWR_register_alias_address PWR Register alias address
  50. * @{
  51. */
  52. /* ------------- PWR registers bit address in the alias region ---------------*/
  53. #define PWR_OFFSET (PWR_BASE - PERIPH_BASE)
  54. #define PWR_CR_OFFSET 0x00U
  55. #define PWR_CSR_OFFSET 0x04U
  56. #define PWR_CR_OFFSET_BB (PWR_OFFSET + PWR_CR_OFFSET)
  57. #define PWR_CSR_OFFSET_BB (PWR_OFFSET + PWR_CSR_OFFSET)
  58. /**
  59. * @}
  60. */
  61. /** @defgroup PWR_CR_register_alias PWR CR Register alias address
  62. * @{
  63. */
  64. /* --- CR Register ---*/
  65. /* Alias word address of LPSDSR bit */
  66. #define LPSDSR_BIT_NUMBER PWR_CR_LPDS_Pos
  67. #define CR_LPSDSR_BB ((uint32_t)(PERIPH_BB_BASE + (PWR_CR_OFFSET_BB * 32U) + (LPSDSR_BIT_NUMBER * 4U)))
  68. /* Alias word address of DBP bit */
  69. #define DBP_BIT_NUMBER PWR_CR_DBP_Pos
  70. #define CR_DBP_BB ((uint32_t)(PERIPH_BB_BASE + (PWR_CR_OFFSET_BB * 32U) + (DBP_BIT_NUMBER * 4U)))
  71. /* Alias word address of PVDE bit */
  72. #define PVDE_BIT_NUMBER PWR_CR_PVDE_Pos
  73. #define CR_PVDE_BB ((uint32_t)(PERIPH_BB_BASE + (PWR_CR_OFFSET_BB * 32U) + (PVDE_BIT_NUMBER * 4U)))
  74. /**
  75. * @}
  76. */
  77. /** @defgroup PWR_CSR_register_alias PWR CSR Register alias address
  78. * @{
  79. */
  80. /* --- CSR Register ---*/
  81. /* Alias word address of EWUP1 bit */
  82. #define CSR_EWUP_BB(VAL) ((uint32_t)(PERIPH_BB_BASE + (PWR_CSR_OFFSET_BB * 32U) + (POSITION_VAL(VAL) * 4U)))
  83. /**
  84. * @}
  85. */
  86. /**
  87. * @}
  88. */
  89. /* Private variables ---------------------------------------------------------*/
  90. /* Private function prototypes -----------------------------------------------*/
  91. /** @defgroup PWR_Private_Functions PWR Private Functions
  92. * brief WFE cortex command overloaded for HAL_PWR_EnterSTOPMode usage only (see Workaround section)
  93. * @{
  94. */
  95. static void PWR_OverloadWfe(void);
  96. /* Private functions ---------------------------------------------------------*/
  97. __NOINLINE
  98. static void PWR_OverloadWfe(void)
  99. {
  100. __asm volatile( "wfe" );
  101. __asm volatile( "nop" );
  102. }
  103. /**
  104. * @}
  105. */
  106. /** @defgroup PWR_Exported_Functions PWR Exported Functions
  107. * @{
  108. */
  109. /** @defgroup PWR_Exported_Functions_Group1 Initialization and de-initialization functions
  110. * @brief Initialization and de-initialization functions
  111. *
  112. @verbatim
  113. ===============================================================================
  114. ##### Initialization and de-initialization functions #####
  115. ===============================================================================
  116. [..]
  117. After reset, the backup domain (RTC registers, RTC backup data
  118. registers) is protected against possible unwanted
  119. write accesses.
  120. To enable access to the RTC Domain and RTC registers, proceed as follows:
  121. (+) Enable the Power Controller (PWR) APB1 interface clock using the
  122. __HAL_RCC_PWR_CLK_ENABLE() macro.
  123. (+) Enable access to RTC domain using the HAL_PWR_EnableBkUpAccess() function.
  124. @endverbatim
  125. * @{
  126. */
  127. /**
  128. * @brief Deinitializes the PWR peripheral registers to their default reset values.
  129. * @retval None
  130. */
  131. void HAL_PWR_DeInit(void)
  132. {
  133. __HAL_RCC_PWR_FORCE_RESET();
  134. __HAL_RCC_PWR_RELEASE_RESET();
  135. }
  136. /**
  137. * @brief Enables access to the backup domain (RTC registers, RTC
  138. * backup data registers ).
  139. * @note If the HSE divided by 128 is used as the RTC clock, the
  140. * Backup Domain Access should be kept enabled.
  141. * @retval None
  142. */
  143. void HAL_PWR_EnableBkUpAccess(void)
  144. {
  145. /* Enable access to RTC and backup registers */
  146. *(__IO uint32_t *) CR_DBP_BB = (uint32_t)ENABLE;
  147. }
  148. /**
  149. * @brief Disables access to the backup domain (RTC registers, RTC
  150. * backup data registers).
  151. * @note If the HSE divided by 128 is used as the RTC clock, the
  152. * Backup Domain Access should be kept enabled.
  153. * @retval None
  154. */
  155. void HAL_PWR_DisableBkUpAccess(void)
  156. {
  157. /* Disable access to RTC and backup registers */
  158. *(__IO uint32_t *) CR_DBP_BB = (uint32_t)DISABLE;
  159. }
  160. /**
  161. * @}
  162. */
  163. /** @defgroup PWR_Exported_Functions_Group2 Peripheral Control functions
  164. * @brief Low Power modes configuration functions
  165. *
  166. @verbatim
  167. ===============================================================================
  168. ##### Peripheral Control functions #####
  169. ===============================================================================
  170. *** PVD configuration ***
  171. =========================
  172. [..]
  173. (+) The PVD is used to monitor the VDD power supply by comparing it to a
  174. threshold selected by the PVD Level (PLS[2:0] bits in the PWR_CR).
  175. (+) A PVDO flag is available to indicate if VDD/VDDA is higher or lower
  176. than the PVD threshold. This event is internally connected to the EXTI
  177. line16 and can generate an interrupt if enabled. This is done through
  178. __HAL_PVD_EXTI_ENABLE_IT() macro.
  179. (+) The PVD is stopped in Standby mode.
  180. *** WakeUp pin configuration ***
  181. ================================
  182. [..]
  183. (+) WakeUp pin is used to wake up the system from Standby mode. This pin is
  184. forced in input pull-down configuration and is active on rising edges.
  185. (+) There is one WakeUp pin:
  186. WakeUp Pin 1 on PA.00.
  187. [..]
  188. *** Low Power modes configuration ***
  189. =====================================
  190. [..]
  191. The device features 3 low-power modes:
  192. (+) Sleep mode: CPU clock off, all peripherals including Cortex-M3 core peripherals like
  193. NVIC, SysTick, etc. are kept running
  194. (+) Stop mode: All clocks are stopped
  195. (+) Standby mode: 1.8V domain powered off
  196. *** Sleep mode ***
  197. ==================
  198. [..]
  199. (+) Entry:
  200. The Sleep mode is entered by using the HAL_PWR_EnterSLEEPMode(PWR_MAINREGULATOR_ON, PWR_SLEEPENTRY_WFx)
  201. functions with
  202. (++) PWR_SLEEPENTRY_WFI: enter SLEEP mode with WFI instruction
  203. (++) PWR_SLEEPENTRY_WFE: enter SLEEP mode with WFE instruction
  204. (+) Exit:
  205. (++) WFI entry mode, Any peripheral interrupt acknowledged by the nested vectored interrupt
  206. controller (NVIC) can wake up the device from Sleep mode.
  207. (++) WFE entry mode, Any wakeup event can wake up the device from Sleep mode.
  208. (+++) Any peripheral interrupt w/o NVIC configuration & SEVONPEND bit set in the Cortex (HAL_PWR_EnableSEVOnPend)
  209. (+++) Any EXTI Line (Internal or External) configured in Event mode
  210. *** Stop mode ***
  211. =================
  212. [..]
  213. The Stop mode is based on the Cortex-M3 deepsleep mode combined with peripheral
  214. clock gating. The voltage regulator can be configured either in normal or low-power mode.
  215. In Stop mode, all clocks in the 1.8 V domain are stopped, the PLL, the HSI and the HSE RC
  216. oscillators are disabled. SRAM and register contents are preserved.
  217. In Stop mode, all I/O pins keep the same state as in Run mode.
  218. (+) Entry:
  219. The Stop mode is entered using the HAL_PWR_EnterSTOPMode(PWR_REGULATOR_VALUE, PWR_SLEEPENTRY_WFx )
  220. function with:
  221. (++) PWR_REGULATOR_VALUE= PWR_MAINREGULATOR_ON: Main regulator ON.
  222. (++) PWR_REGULATOR_VALUE= PWR_LOWPOWERREGULATOR_ON: Low Power regulator ON.
  223. (++) PWR_SLEEPENTRY_WFx= PWR_SLEEPENTRY_WFI: enter STOP mode with WFI instruction
  224. (++) PWR_SLEEPENTRY_WFx= PWR_SLEEPENTRY_WFE: enter STOP mode with WFE instruction
  225. (+) Exit:
  226. (++) WFI entry mode, Any EXTI Line (Internal or External) configured in Interrupt mode with NVIC configured
  227. (++) WFE entry mode, Any EXTI Line (Internal or External) configured in Event mode.
  228. *** Standby mode ***
  229. ====================
  230. [..]
  231. The Standby mode allows to achieve the lowest power consumption. It is based on the
  232. Cortex-M3 deepsleep mode, with the voltage regulator disabled. The 1.8 V domain is
  233. consequently powered off. The PLL, the HSI oscillator and the HSE oscillator are also
  234. switched off. SRAM and register contents are lost except for registers in the Backup domain
  235. and Standby circuitry
  236. (+) Entry:
  237. (++) The Standby mode is entered using the HAL_PWR_EnterSTANDBYMode() function.
  238. (+) Exit:
  239. (++) WKUP pin rising edge, RTC alarm event rising edge, external Reset in
  240. NRSTpin, IWDG Reset
  241. *** Auto-wakeup (AWU) from low-power mode ***
  242. =============================================
  243. [..]
  244. (+) The MCU can be woken up from low-power mode by an RTC Alarm event,
  245. without depending on an external interrupt (Auto-wakeup mode).
  246. (+) RTC auto-wakeup (AWU) from the Stop and Standby modes
  247. (++) To wake up from the Stop mode with an RTC alarm event, it is necessary to
  248. configure the RTC to generate the RTC alarm using the HAL_RTC_SetAlarm_IT() function.
  249. *** PWR Workarounds linked to Silicon Limitation ***
  250. ====================================================
  251. [..]
  252. Below the list of all silicon limitations known on STM32F1xx prouct.
  253. (#)Workarounds Implemented inside PWR HAL Driver
  254. (##)Debugging Stop mode with WFE entry - overloaded the WFE by an internal function
  255. @endverbatim
  256. * @{
  257. */
  258. /**
  259. * @brief Configures the voltage threshold detected by the Power Voltage Detector(PVD).
  260. * @param sConfigPVD: pointer to an PWR_PVDTypeDef structure that contains the configuration
  261. * information for the PVD.
  262. * @note Refer to the electrical characteristics of your device datasheet for
  263. * more details about the voltage threshold corresponding to each
  264. * detection level.
  265. * @retval None
  266. */
  267. void HAL_PWR_ConfigPVD(PWR_PVDTypeDef *sConfigPVD)
  268. {
  269. /* Check the parameters */
  270. assert_param(IS_PWR_PVD_LEVEL(sConfigPVD->PVDLevel));
  271. assert_param(IS_PWR_PVD_MODE(sConfigPVD->Mode));
  272. /* Set PLS[7:5] bits according to PVDLevel value */
  273. MODIFY_REG(PWR->CR, PWR_CR_PLS, sConfigPVD->PVDLevel);
  274. /* Clear any previous config. Keep it clear if no event or IT mode is selected */
  275. __HAL_PWR_PVD_EXTI_DISABLE_EVENT();
  276. __HAL_PWR_PVD_EXTI_DISABLE_IT();
  277. __HAL_PWR_PVD_EXTI_DISABLE_FALLING_EDGE();
  278. __HAL_PWR_PVD_EXTI_DISABLE_RISING_EDGE();
  279. /* Configure interrupt mode */
  280. if((sConfigPVD->Mode & PVD_MODE_IT) == PVD_MODE_IT)
  281. {
  282. __HAL_PWR_PVD_EXTI_ENABLE_IT();
  283. }
  284. /* Configure event mode */
  285. if((sConfigPVD->Mode & PVD_MODE_EVT) == PVD_MODE_EVT)
  286. {
  287. __HAL_PWR_PVD_EXTI_ENABLE_EVENT();
  288. }
  289. /* Configure the edge */
  290. if((sConfigPVD->Mode & PVD_RISING_EDGE) == PVD_RISING_EDGE)
  291. {
  292. __HAL_PWR_PVD_EXTI_ENABLE_RISING_EDGE();
  293. }
  294. if((sConfigPVD->Mode & PVD_FALLING_EDGE) == PVD_FALLING_EDGE)
  295. {
  296. __HAL_PWR_PVD_EXTI_ENABLE_FALLING_EDGE();
  297. }
  298. }
  299. /**
  300. * @brief Enables the Power Voltage Detector(PVD).
  301. * @retval None
  302. */
  303. void HAL_PWR_EnablePVD(void)
  304. {
  305. /* Enable the power voltage detector */
  306. *(__IO uint32_t *) CR_PVDE_BB = (uint32_t)ENABLE;
  307. }
  308. /**
  309. * @brief Disables the Power Voltage Detector(PVD).
  310. * @retval None
  311. */
  312. void HAL_PWR_DisablePVD(void)
  313. {
  314. /* Disable the power voltage detector */
  315. *(__IO uint32_t *) CR_PVDE_BB = (uint32_t)DISABLE;
  316. }
  317. /**
  318. * @brief Enables the WakeUp PINx functionality.
  319. * @param WakeUpPinx: Specifies the Power Wake-Up pin to enable.
  320. * This parameter can be one of the following values:
  321. * @arg PWR_WAKEUP_PIN1
  322. * @retval None
  323. */
  324. void HAL_PWR_EnableWakeUpPin(uint32_t WakeUpPinx)
  325. {
  326. /* Check the parameter */
  327. assert_param(IS_PWR_WAKEUP_PIN(WakeUpPinx));
  328. /* Enable the EWUPx pin */
  329. *(__IO uint32_t *) CSR_EWUP_BB(WakeUpPinx) = (uint32_t)ENABLE;
  330. }
  331. /**
  332. * @brief Disables the WakeUp PINx functionality.
  333. * @param WakeUpPinx: Specifies the Power Wake-Up pin to disable.
  334. * This parameter can be one of the following values:
  335. * @arg PWR_WAKEUP_PIN1
  336. * @retval None
  337. */
  338. void HAL_PWR_DisableWakeUpPin(uint32_t WakeUpPinx)
  339. {
  340. /* Check the parameter */
  341. assert_param(IS_PWR_WAKEUP_PIN(WakeUpPinx));
  342. /* Disable the EWUPx pin */
  343. *(__IO uint32_t *) CSR_EWUP_BB(WakeUpPinx) = (uint32_t)DISABLE;
  344. }
  345. /**
  346. * @brief Enters Sleep mode.
  347. * @note In Sleep mode, all I/O pins keep the same state as in Run mode.
  348. * @param Regulator: Regulator state as no effect in SLEEP mode - allows to support portability from legacy software
  349. * @param SLEEPEntry: Specifies if SLEEP mode is entered with WFI or WFE instruction.
  350. * When WFI entry is used, tick interrupt have to be disabled if not desired as
  351. * the interrupt wake up source.
  352. * This parameter can be one of the following values:
  353. * @arg PWR_SLEEPENTRY_WFI: enter SLEEP mode with WFI instruction
  354. * @arg PWR_SLEEPENTRY_WFE: enter SLEEP mode with WFE instruction
  355. * @retval None
  356. */
  357. void HAL_PWR_EnterSLEEPMode(uint32_t Regulator, uint8_t SLEEPEntry)
  358. {
  359. /* Check the parameters */
  360. /* No check on Regulator because parameter not used in SLEEP mode */
  361. /* Prevent unused argument(s) compilation warning */
  362. UNUSED(Regulator);
  363. assert_param(IS_PWR_SLEEP_ENTRY(SLEEPEntry));
  364. /* Clear SLEEPDEEP bit of Cortex System Control Register */
  365. CLEAR_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPDEEP_Msk));
  366. /* Select SLEEP mode entry -------------------------------------------------*/
  367. if(SLEEPEntry == PWR_SLEEPENTRY_WFI)
  368. {
  369. /* Request Wait For Interrupt */
  370. __WFI();
  371. }
  372. else
  373. {
  374. /* Request Wait For Event */
  375. __SEV();
  376. __WFE();
  377. __WFE();
  378. }
  379. }
  380. /**
  381. * @brief Enters Stop mode.
  382. * @note In Stop mode, all I/O pins keep the same state as in Run mode.
  383. * @note When exiting Stop mode by using an interrupt or a wakeup event,
  384. * HSI RC oscillator is selected as system clock.
  385. * @note When the voltage regulator operates in low power mode, an additional
  386. * startup delay is incurred when waking up from Stop mode.
  387. * By keeping the internal regulator ON during Stop mode, the consumption
  388. * is higher although the startup time is reduced.
  389. * @param Regulator: Specifies the regulator state in Stop mode.
  390. * This parameter can be one of the following values:
  391. * @arg PWR_MAINREGULATOR_ON: Stop mode with regulator ON
  392. * @arg PWR_LOWPOWERREGULATOR_ON: Stop mode with low power regulator ON
  393. * @param STOPEntry: Specifies if Stop mode in entered with WFI or WFE instruction.
  394. * This parameter can be one of the following values:
  395. * @arg PWR_STOPENTRY_WFI: Enter Stop mode with WFI instruction
  396. * @arg PWR_STOPENTRY_WFE: Enter Stop mode with WFE instruction
  397. * @retval None
  398. */
  399. void HAL_PWR_EnterSTOPMode(uint32_t Regulator, uint8_t STOPEntry)
  400. {
  401. /* Check the parameters */
  402. assert_param(IS_PWR_REGULATOR(Regulator));
  403. assert_param(IS_PWR_STOP_ENTRY(STOPEntry));
  404. /* Clear PDDS bit in PWR register to specify entering in STOP mode when CPU enter in Deepsleep */
  405. CLEAR_BIT(PWR->CR, PWR_CR_PDDS);
  406. /* Select the voltage regulator mode by setting LPDS bit in PWR register according to Regulator parameter value */
  407. MODIFY_REG(PWR->CR, PWR_CR_LPDS, Regulator);
  408. /* Set SLEEPDEEP bit of Cortex System Control Register */
  409. SET_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPDEEP_Msk));
  410. /* Select Stop mode entry --------------------------------------------------*/
  411. if(STOPEntry == PWR_STOPENTRY_WFI)
  412. {
  413. /* Request Wait For Interrupt */
  414. __WFI();
  415. }
  416. else
  417. {
  418. /* Request Wait For Event */
  419. __SEV();
  420. PWR_OverloadWfe(); /* WFE redefine locally */
  421. PWR_OverloadWfe(); /* WFE redefine locally */
  422. }
  423. /* Reset SLEEPDEEP bit of Cortex System Control Register */
  424. CLEAR_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPDEEP_Msk));
  425. }
  426. /**
  427. * @brief Enters Standby mode.
  428. * @note In Standby mode, all I/O pins are high impedance except for:
  429. * - Reset pad (still available)
  430. * - TAMPER pin if configured for tamper or calibration out.
  431. * - WKUP pin (PA0) if enabled.
  432. * @retval None
  433. */
  434. void HAL_PWR_EnterSTANDBYMode(void)
  435. {
  436. /* Select Standby mode */
  437. SET_BIT(PWR->CR, PWR_CR_PDDS);
  438. /* Set SLEEPDEEP bit of Cortex System Control Register */
  439. SET_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPDEEP_Msk));
  440. /* This option is used to ensure that store operations are completed */
  441. #if defined ( __CC_ARM)
  442. __force_stores();
  443. #endif
  444. /* Request Wait For Interrupt */
  445. __WFI();
  446. }
  447. /**
  448. * @brief Indicates Sleep-On-Exit when returning from Handler mode to Thread mode.
  449. * @note Set SLEEPONEXIT bit of SCR register. When this bit is set, the processor
  450. * re-enters SLEEP mode when an interruption handling is over.
  451. * Setting this bit is useful when the processor is expected to run only on
  452. * interruptions handling.
  453. * @retval None
  454. */
  455. void HAL_PWR_EnableSleepOnExit(void)
  456. {
  457. /* Set SLEEPONEXIT bit of Cortex System Control Register */
  458. SET_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPONEXIT_Msk));
  459. }
  460. /**
  461. * @brief Disables Sleep-On-Exit feature when returning from Handler mode to Thread mode.
  462. * @note Clears SLEEPONEXIT bit of SCR register. When this bit is set, the processor
  463. * re-enters SLEEP mode when an interruption handling is over.
  464. * @retval None
  465. */
  466. void HAL_PWR_DisableSleepOnExit(void)
  467. {
  468. /* Clear SLEEPONEXIT bit of Cortex System Control Register */
  469. CLEAR_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPONEXIT_Msk));
  470. }
  471. /**
  472. * @brief Enables CORTEX M3 SEVONPEND bit.
  473. * @note Sets SEVONPEND bit of SCR register. When this bit is set, this causes
  474. * WFE to wake up when an interrupt moves from inactive to pended.
  475. * @retval None
  476. */
  477. void HAL_PWR_EnableSEVOnPend(void)
  478. {
  479. /* Set SEVONPEND bit of Cortex System Control Register */
  480. SET_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SEVONPEND_Msk));
  481. }
  482. /**
  483. * @brief Disables CORTEX M3 SEVONPEND bit.
  484. * @note Clears SEVONPEND bit of SCR register. When this bit is set, this causes
  485. * WFE to wake up when an interrupt moves from inactive to pended.
  486. * @retval None
  487. */
  488. void HAL_PWR_DisableSEVOnPend(void)
  489. {
  490. /* Clear SEVONPEND bit of Cortex System Control Register */
  491. CLEAR_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SEVONPEND_Msk));
  492. }
  493. /**
  494. * @brief This function handles the PWR PVD interrupt request.
  495. * @note This API should be called under the PVD_IRQHandler().
  496. * @retval None
  497. */
  498. void HAL_PWR_PVD_IRQHandler(void)
  499. {
  500. /* Check PWR exti flag */
  501. if(__HAL_PWR_PVD_EXTI_GET_FLAG() != RESET)
  502. {
  503. /* PWR PVD interrupt user callback */
  504. HAL_PWR_PVDCallback();
  505. /* Clear PWR Exti pending bit */
  506. __HAL_PWR_PVD_EXTI_CLEAR_FLAG();
  507. }
  508. }
  509. /**
  510. * @brief PWR PVD interrupt callback
  511. * @retval None
  512. */
  513. __weak void HAL_PWR_PVDCallback(void)
  514. {
  515. /* NOTE : This function Should not be modified, when the callback is needed,
  516. the HAL_PWR_PVDCallback could be implemented in the user file
  517. */
  518. }
  519. /**
  520. * @}
  521. */
  522. /**
  523. * @}
  524. */
  525. #endif /* HAL_PWR_MODULE_ENABLED */
  526. /**
  527. * @}
  528. */
  529. /**
  530. * @}
  531. */