Implement a secure ICS protocol targeting LoRa Node151 microcontroller for controlling irrigation.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

622 lines
20 KiB

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