stm32f7xx_hal_pwr.c 21 KB

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