stm32f4xx_hal_pwr.c 20 KB

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