stm32f4xx_hal_pwr.c 21 KB

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