stm32f2xx_pwr.c 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612
  1. /**
  2. ******************************************************************************
  3. * @file stm32f2xx_pwr.c
  4. * @author MCD Application Team
  5. * @version V1.1.3
  6. * @date 31-December-2021
  7. * @brief This file provides firmware functions to manage the following
  8. * functionalities of the Power Controller (PWR) peripheral:
  9. * - Backup Domain Access
  10. * - PVD configuration
  11. * - WakeUp pin configuration
  12. * - Backup Regulator configuration
  13. * - FLASH Power Down configuration
  14. * - Low Power modes configuration
  15. * - Flags management
  16. *
  17. ******************************************************************************
  18. * @attention
  19. *
  20. * Copyright (c) 2012 STMicroelectronics.
  21. * All rights reserved.
  22. *
  23. * This software is licensed under terms that can be found in the LICENSE file
  24. * in the root directory of this software component.
  25. * If no LICENSE file comes with this software, it is provided AS-IS.
  26. *
  27. ******************************************************************************
  28. */
  29. /* Includes ------------------------------------------------------------------*/
  30. #include "stm32f2xx_pwr.h"
  31. #include "stm32f2xx_rcc.h"
  32. /** @addtogroup STM32F2xx_StdPeriph_Driver
  33. * @{
  34. */
  35. /** @defgroup PWR
  36. * @brief PWR driver modules
  37. * @{
  38. */
  39. /* Private typedef -----------------------------------------------------------*/
  40. /* Private define ------------------------------------------------------------*/
  41. /* --------- PWR registers bit address in the alias region ---------- */
  42. #define PWR_OFFSET (PWR_BASE - PERIPH_BASE)
  43. /* --- CR Register ---*/
  44. /* Alias word address of DBP bit */
  45. #define CR_OFFSET (PWR_OFFSET + 0x00)
  46. #define DBP_BitNumber 0x08
  47. #define CR_DBP_BB (PERIPH_BB_BASE + (CR_OFFSET * 32) + (DBP_BitNumber * 4))
  48. /* Alias word address of PVDE bit */
  49. #define PVDE_BitNumber 0x04
  50. #define CR_PVDE_BB (PERIPH_BB_BASE + (CR_OFFSET * 32) + (PVDE_BitNumber * 4))
  51. /* Alias word address of FPDS bit */
  52. #define FPDS_BitNumber 0x09
  53. #define CR_FPDS_BB (PERIPH_BB_BASE + (CR_OFFSET * 32) + (FPDS_BitNumber * 4))
  54. /* --- CSR Register ---*/
  55. /* Alias word address of EWUP bit */
  56. #define CSR_OFFSET (PWR_OFFSET + 0x04)
  57. #define EWUP_BitNumber 0x08
  58. #define CSR_EWUP_BB (PERIPH_BB_BASE + (CSR_OFFSET * 32) + (EWUP_BitNumber * 4))
  59. /* Alias word address of BRE bit */
  60. #define BRE_BitNumber 0x09
  61. #define CSR_BRE_BB (PERIPH_BB_BASE + (CSR_OFFSET * 32) + (BRE_BitNumber * 4))
  62. /* ------------------ PWR registers bit mask ------------------------ */
  63. /* CR register bit mask */
  64. #define CR_DS_MASK ((uint32_t)0xFFFFFFFC)
  65. #define CR_PLS_MASK ((uint32_t)0xFFFFFF1F)
  66. /* Private macro -------------------------------------------------------------*/
  67. /* Private variables ---------------------------------------------------------*/
  68. /* Private function prototypes -----------------------------------------------*/
  69. /* Private functions ---------------------------------------------------------*/
  70. /** @defgroup PWR_Private_Functions
  71. * @{
  72. */
  73. /** @defgroup PWR_Group1 Backup Domain Access function
  74. * @brief Backup Domain Access function
  75. *
  76. @verbatim
  77. ===============================================================================
  78. Backup Domain Access function
  79. ===============================================================================
  80. After reset, the backup domain (RTC registers, RTC backup data
  81. registers and backup SRAM) is protected against possible unwanted
  82. write accesses.
  83. To enable access to the RTC Domain and RTC registers, proceed as follows:
  84. - Enable the Power Controller (PWR) APB1 interface clock using the
  85. RCC_APB1PeriphClockCmd() function.
  86. - Enable access to RTC domain using the PWR_BackupAccessCmd() function.
  87. @endverbatim
  88. * @{
  89. */
  90. /**
  91. * @brief Deinitializes the PWR peripheral registers to their default reset values.
  92. * @param None
  93. * @retval None
  94. */
  95. void PWR_DeInit(void)
  96. {
  97. RCC_APB1PeriphResetCmd(RCC_APB1Periph_PWR, ENABLE);
  98. RCC_APB1PeriphResetCmd(RCC_APB1Periph_PWR, DISABLE);
  99. }
  100. /**
  101. * @brief Enables or disables access to the backup domain (RTC registers, RTC
  102. * backup data registers and backup SRAM).
  103. * @note If the HSE divided by 2, 3, ..31 is used as the RTC clock, the
  104. * Backup Domain Access should be kept enabled.
  105. * @param NewState: new state of the access to the backup domain.
  106. * This parameter can be: ENABLE or DISABLE.
  107. * @retval None
  108. */
  109. void PWR_BackupAccessCmd(FunctionalState NewState)
  110. {
  111. /* Check the parameters */
  112. assert_param(IS_FUNCTIONAL_STATE(NewState));
  113. *(__IO uint32_t *) CR_DBP_BB = (uint32_t)NewState;
  114. }
  115. /**
  116. * @}
  117. */
  118. /** @defgroup PWR_Group2 PVD configuration functions
  119. * @brief PVD configuration functions
  120. *
  121. @verbatim
  122. ===============================================================================
  123. PVD configuration functions
  124. ===============================================================================
  125. - The PVD is used to monitor the VDD power supply by comparing it to a threshold
  126. selected by the PVD Level (PLS[2:0] bits in the PWR_CR).
  127. - A PVDO flag is available to indicate if VDD/VDDA is higher or lower than the
  128. PVD threshold. This event is internally connected to the EXTI line16
  129. and can generate an interrupt if enabled through the EXTI registers.
  130. - The PVD is stopped in Standby mode.
  131. @endverbatim
  132. * @{
  133. */
  134. /**
  135. * @brief Configures the voltage threshold detected by the Power Voltage Detector(PVD).
  136. * @param PWR_PVDLevel: specifies the PVD detection level
  137. * This parameter can be one of the following values:
  138. * @arg PWR_PVDLevel_0
  139. * @arg PWR_PVDLevel_1
  140. * @arg PWR_PVDLevel_2
  141. * @arg PWR_PVDLevel_3
  142. * @arg PWR_PVDLevel_4
  143. * @arg PWR_PVDLevel_5
  144. * @arg PWR_PVDLevel_6
  145. * @arg PWR_PVDLevel_7
  146. * @note Refer to the electrical characteristics of your device datasheet for
  147. * more details about the voltage threshold corresponding to each
  148. * detection level.
  149. * @retval None
  150. */
  151. void PWR_PVDLevelConfig(uint32_t PWR_PVDLevel)
  152. {
  153. uint32_t tmpreg = 0;
  154. /* Check the parameters */
  155. assert_param(IS_PWR_PVD_LEVEL(PWR_PVDLevel));
  156. tmpreg = PWR->CR;
  157. /* Clear PLS[7:5] bits */
  158. tmpreg &= CR_PLS_MASK;
  159. /* Set PLS[7:5] bits according to PWR_PVDLevel value */
  160. tmpreg |= PWR_PVDLevel;
  161. /* Store the new value */
  162. PWR->CR = tmpreg;
  163. }
  164. /**
  165. * @brief Enables or disables the Power Voltage Detector(PVD).
  166. * @param NewState: new state of the PVD.
  167. * This parameter can be: ENABLE or DISABLE.
  168. * @retval None
  169. */
  170. void PWR_PVDCmd(FunctionalState NewState)
  171. {
  172. /* Check the parameters */
  173. assert_param(IS_FUNCTIONAL_STATE(NewState));
  174. *(__IO uint32_t *) CR_PVDE_BB = (uint32_t)NewState;
  175. }
  176. /**
  177. * @}
  178. */
  179. /** @defgroup PWR_Group3 WakeUp pin configuration functions
  180. * @brief WakeUp pin configuration functions
  181. *
  182. @verbatim
  183. ===============================================================================
  184. WakeUp pin configuration functions
  185. ===============================================================================
  186. - WakeUp pin is used to wakeup the system from Standby mode. This pin is
  187. forced in input pull down configuration and is active on rising edges.
  188. - There is only one WakeUp pin: WakeUp Pin 1 on PA.00.
  189. @endverbatim
  190. * @{
  191. */
  192. /**
  193. * @brief Enables or disables the WakeUp Pin functionality.
  194. * @param NewState: new state of the WakeUp Pin functionality.
  195. * This parameter can be: ENABLE or DISABLE.
  196. * @retval None
  197. */
  198. void PWR_WakeUpPinCmd(FunctionalState NewState)
  199. {
  200. /* Check the parameters */
  201. assert_param(IS_FUNCTIONAL_STATE(NewState));
  202. *(__IO uint32_t *) CSR_EWUP_BB = (uint32_t)NewState;
  203. }
  204. /**
  205. * @}
  206. */
  207. /** @defgroup PWR_Group4 Backup Regulator configuration functions
  208. * @brief Backup Regulator configuration functions
  209. *
  210. @verbatim
  211. ===============================================================================
  212. Backup Regulator configuration functions
  213. ===============================================================================
  214. - The backup domain includes 4 Kbytes of backup SRAM accessible only from the
  215. CPU, and address in 32-bit, 16-bit or 8-bit mode. Its content is retained
  216. even in Standby or VBAT mode when the low power backup regulator is enabled.
  217. It can be considered as an internal EEPROM when VBAT is always present.
  218. You can use the PWR_BackupRegulatorCmd() function to enable the low power
  219. backup regulator and use the PWR_GetFlagStatus(PWR_FLAG_BRR) to check if it is
  220. ready or not.
  221. - When the backup domain is supplied by VDD (analog switch connected to VDD)
  222. the backup SRAM is powered from VDD which replaces the VBAT power supply to
  223. save battery life.
  224. - The backup SRAM is not mass erased by an tamper event. It is read protected
  225. to prevent confidential data, such as cryptographic private key, from being
  226. accessed. The backup SRAM can be erased only through the Flash interface when
  227. a protection level change from level 1 to level 0 is requested.
  228. Refer to the description of Read protection (RDP) in the Flash programming manual.
  229. @endverbatim
  230. * @{
  231. */
  232. /**
  233. * @brief Enables or disables the Backup Regulator.
  234. * @param NewState: new state of the Backup Regulator.
  235. * This parameter can be: ENABLE or DISABLE.
  236. * @retval None
  237. */
  238. void PWR_BackupRegulatorCmd(FunctionalState NewState)
  239. {
  240. /* Check the parameters */
  241. assert_param(IS_FUNCTIONAL_STATE(NewState));
  242. *(__IO uint32_t *) CSR_BRE_BB = (uint32_t)NewState;
  243. }
  244. /**
  245. * @}
  246. */
  247. /** @defgroup PWR_Group5 FLASH Power Down configuration functions
  248. * @brief FLASH Power Down configuration functions
  249. *
  250. @verbatim
  251. ===============================================================================
  252. FLASH Power Down configuration functions
  253. ===============================================================================
  254. - By setting the FPDS bit in the PWR_CR register by using the PWR_FlashPowerDownCmd()
  255. function, the Flash memory also enters power down mode when the device enters
  256. Stop mode. When the Flash memory is in power down mode, an additional startup
  257. delay is incurred when waking up from Stop mode.
  258. @endverbatim
  259. * @{
  260. */
  261. /**
  262. * @brief Enables or disables the Flash Power Down in STOP mode.
  263. * @param NewState: new state of the Flash power mode.
  264. * This parameter can be: ENABLE or DISABLE.
  265. * @retval None
  266. */
  267. void PWR_FlashPowerDownCmd(FunctionalState NewState)
  268. {
  269. /* Check the parameters */
  270. assert_param(IS_FUNCTIONAL_STATE(NewState));
  271. *(__IO uint32_t *) CR_FPDS_BB = (uint32_t)NewState;
  272. }
  273. /**
  274. * @}
  275. */
  276. /** @defgroup PWR_Group6 Low Power modes configuration functions
  277. * @brief Low Power modes configuration functions
  278. *
  279. @verbatim
  280. ===============================================================================
  281. Low Power modes configuration functions
  282. ===============================================================================
  283. The devices feature 3 low-power modes:
  284. - Sleep mode: Cortex-M3 core stopped, peripherals kept running.
  285. - Stop mode: all clocks are stopped, regulator running, regulator in low power mode
  286. - Standby mode: 1.2V domain powered off.
  287. Sleep mode
  288. ===========
  289. - Entry:
  290. - The Sleep mode is entered by using the __WFI() or __WFE() functions.
  291. - Exit:
  292. - Any peripheral interrupt acknowledged by the nested vectored interrupt
  293. controller (NVIC) can wake up the device from Sleep mode.
  294. Stop mode
  295. ==========
  296. In Stop mode, all clocks in the 1.2V domain are stopped, the PLL, the HSI,
  297. and the HSE RC oscillators are disabled. Internal SRAM and register contents
  298. are preserved.
  299. The voltage regulator can be configured either in normal or low-power mode.
  300. To minimize the consumption In Stop mode, FLASH can be powered off before
  301. entering the Stop mode. It can be switched on again by software after exiting
  302. the Stop mode using the PWR_FlashPowerDownCmd() function.
  303. - Entry:
  304. - The Stop mode is entered using the PWR_EnterSTOPMode(PWR_Regulator_LowPower,)
  305. function with regulator in LowPower or with Regulator ON.
  306. - Exit:
  307. - Any EXTI Line (Internal or External) configured in Interrupt/Event mode.
  308. Standby mode
  309. ============
  310. The Standby mode allows to achieve the lowest power consumption. It is based
  311. on the Cortex-M3 deepsleep mode, with the voltage regulator disabled.
  312. The 1.2V domain is consequently powered off. The PLL, the HSI oscillator and
  313. the HSE oscillator are also switched off. SRAM and register contents are lost
  314. except for the RTC registers, RTC backup registers, backup SRAM and Standby
  315. circuitry.
  316. The voltage regulator is OFF.
  317. - Entry:
  318. - The Standby mode is entered using the PWR_EnterSTANDBYMode() function.
  319. - Exit:
  320. - WKUP pin rising edge, RTC alarm (Alarm A and Alarm B), RTC wakeup,
  321. tamper event, time-stamp event, external reset in NRST pin, IWDG reset.
  322. Auto-wakeup (AWU) from low-power mode
  323. =====================================
  324. The MCU can be woken up from low-power mode by an RTC Alarm event, an RTC
  325. Wakeup event, a tamper event, a time-stamp event, or a comparator event,
  326. without depending on an external interrupt (Auto-wakeup mode).
  327. - RTC auto-wakeup (AWU) from the Stop mode
  328. ----------------------------------------
  329. - To wake up from the Stop mode with an RTC alarm event, it is necessary to:
  330. - Configure the EXTI Line 17 to be sensitive to rising edges (Interrupt
  331. or Event modes) using the EXTI_Init() function.
  332. - Enable the RTC Alarm Interrupt using the RTC_ITConfig() function
  333. - Configure the RTC to generate the RTC alarm using the RTC_SetAlarm()
  334. and RTC_AlarmCmd() functions.
  335. - To wake up from the Stop mode with an RTC Tamper or time stamp event, it
  336. is necessary to:
  337. - Configure the EXTI Line 21 to be sensitive to rising edges (Interrupt
  338. or Event modes) using the EXTI_Init() function.
  339. - Enable the RTC Tamper or time stamp Interrupt using the RTC_ITConfig()
  340. function
  341. - Configure the RTC to detect the tamper or time stamp event using the
  342. RTC_TimeStampConfig(), RTC_TamperTriggerConfig() and RTC_TamperCmd()
  343. functions.
  344. - To wake up from the Stop mode with an RTC WakeUp event, it is necessary to:
  345. - Configure the EXTI Line 22 to be sensitive to rising edges (Interrupt
  346. or Event modes) using the EXTI_Init() function.
  347. - Enable the RTC WakeUp Interrupt using the RTC_ITConfig() function
  348. - Configure the RTC to generate the RTC WakeUp event using the RTC_WakeUpClockConfig(),
  349. RTC_SetWakeUpCounter() and RTC_WakeUpCmd() functions.
  350. - RTC auto-wakeup (AWU) from the Standby mode
  351. -------------------------------------------
  352. - To wake up from the Standby mode with an RTC alarm event, it is necessary to:
  353. - Enable the RTC Alarm Interrupt using the RTC_ITConfig() function
  354. - Configure the RTC to generate the RTC alarm using the RTC_SetAlarm()
  355. and RTC_AlarmCmd() functions.
  356. - To wake up from the Standby mode with an RTC Tamper or time stamp event, it
  357. is necessary to:
  358. - Enable the RTC Tamper or time stamp Interrupt using the RTC_ITConfig()
  359. function
  360. - Configure the RTC to detect the tamper or time stamp event using the
  361. RTC_TimeStampConfig(), RTC_TamperTriggerConfig() and RTC_TamperCmd()
  362. functions.
  363. - To wake up from the Standby mode with an RTC WakeUp event, it is necessary to:
  364. - Enable the RTC WakeUp Interrupt using the RTC_ITConfig() function
  365. - Configure the RTC to generate the RTC WakeUp event using the RTC_WakeUpClockConfig(),
  366. RTC_SetWakeUpCounter() and RTC_WakeUpCmd() functions.
  367. @endverbatim
  368. * @{
  369. */
  370. /**
  371. * @brief Enters STOP mode.
  372. *
  373. * @note In Stop mode, all I/O pins keep the same state as in Run mode.
  374. * @note When exiting Stop mode by issuing an interrupt or a wakeup event,
  375. * the HSI RC oscillator is selected as system clock.
  376. * @note When the voltage regulator operates in low power mode, an additional
  377. * startup delay is incurred when waking up from Stop mode.
  378. * By keeping the internal regulator ON during Stop mode, the consumption
  379. * is higher although the startup time is reduced.
  380. *
  381. * @param PWR_Regulator: specifies the regulator state in STOP mode.
  382. * This parameter can be one of the following values:
  383. * @arg PWR_Regulator_ON: STOP mode with regulator ON
  384. * @arg PWR_Regulator_LowPower: STOP mode with regulator in low power mode
  385. * @param PWR_STOPEntry: specifies if STOP mode in entered with WFI or WFE instruction.
  386. * This parameter can be one of the following values:
  387. * @arg PWR_STOPEntry_WFI: enter STOP mode with WFI instruction
  388. * @arg PWR_STOPEntry_WFE: enter STOP mode with WFE instruction
  389. * @retval None
  390. */
  391. void PWR_EnterSTOPMode(uint32_t PWR_Regulator, uint8_t PWR_STOPEntry)
  392. {
  393. uint32_t tmpreg = 0;
  394. /* Check the parameters */
  395. assert_param(IS_PWR_REGULATOR(PWR_Regulator));
  396. assert_param(IS_PWR_STOP_ENTRY(PWR_STOPEntry));
  397. /* Select the regulator state in STOP mode ---------------------------------*/
  398. tmpreg = PWR->CR;
  399. /* Clear PDDS and LPDSR bits */
  400. tmpreg &= CR_DS_MASK;
  401. /* Set LPDSR bit according to PWR_Regulator value */
  402. tmpreg |= PWR_Regulator;
  403. /* Store the new value */
  404. PWR->CR = tmpreg;
  405. /* Set SLEEPDEEP bit of Cortex System Control Register */
  406. SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk;
  407. /* Select STOP mode entry --------------------------------------------------*/
  408. if(PWR_STOPEntry == PWR_STOPEntry_WFI)
  409. {
  410. /* Request Wait For Interrupt */
  411. __WFI();
  412. }
  413. else
  414. {
  415. /* Request Wait For Event */
  416. __WFE();
  417. }
  418. /* Reset SLEEPDEEP bit of Cortex System Control Register */
  419. SCB->SCR &= (uint32_t)~((uint32_t)SCB_SCR_SLEEPDEEP_Msk);
  420. }
  421. /**
  422. * @brief Enters STANDBY mode.
  423. * @note In Standby mode, all I/O pins are high impedance except for:
  424. * - Reset pad (still available)
  425. * - RTC_AF1 pin (PC13) if configured for tamper, time-stamp, RTC
  426. * Alarm out, or RTC clock calibration out.
  427. * - RTC_AF2 pin (PI8) if configured for tamper or time-stamp.
  428. * - WKUP pin 1 (PA0) if enabled.
  429. * @param None
  430. * @retval None
  431. */
  432. void PWR_EnterSTANDBYMode(void)
  433. {
  434. /* Clear Wakeup flag */
  435. PWR->CR |= PWR_CR_CWUF;
  436. /* Select STANDBY mode */
  437. PWR->CR |= PWR_CR_PDDS;
  438. /* Set SLEEPDEEP bit of Cortex System Control Register */
  439. SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk;
  440. /* This option is used to ensure that store operations are completed */
  441. #if defined ( __CC_ARM )
  442. __force_stores();
  443. #endif
  444. /* Request Wait For Interrupt */
  445. __WFI();
  446. }
  447. /**
  448. * @}
  449. */
  450. /** @defgroup PWR_Group7 Flags management functions
  451. * @brief Flags management functions
  452. *
  453. @verbatim
  454. ===============================================================================
  455. Flags management functions
  456. ===============================================================================
  457. @endverbatim
  458. * @{
  459. */
  460. /**
  461. * @brief Checks whether the specified PWR flag is set or not.
  462. * @param PWR_FLAG: specifies the flag to check.
  463. * This parameter can be one of the following values:
  464. * @arg PWR_FLAG_WU: Wake Up flag. This flag indicates that a wakeup event
  465. * was received from the WKUP pin or from the RTC alarm (Alarm A
  466. * or Alarm B), RTC Tamper event, RTC TimeStamp event or RTC Wakeup.
  467. * An additional wakeup event is detected if the WKUP pin is enabled
  468. * (by setting the EWUP bit) when the WKUP pin level is already high.
  469. * @arg PWR_FLAG_SB: StandBy flag. This flag indicates that the system was
  470. * resumed from StandBy mode.
  471. * @arg PWR_FLAG_PVDO: PVD Output. This flag is valid only if PVD is enabled
  472. * by the PWR_PVDCmd() function. The PVD is stopped by Standby mode
  473. * For this reason, this bit is equal to 0 after Standby or reset
  474. * until the PVDE bit is set.
  475. * @arg PWR_FLAG_BRR: Backup regulator ready flag. This bit is not reset
  476. * when the device wakes up from Standby mode or by a system reset
  477. * or power reset.
  478. * @retval The new state of PWR_FLAG (SET or RESET).
  479. */
  480. FlagStatus PWR_GetFlagStatus(uint32_t PWR_FLAG)
  481. {
  482. FlagStatus bitstatus = RESET;
  483. /* Check the parameters */
  484. assert_param(IS_PWR_GET_FLAG(PWR_FLAG));
  485. if ((PWR->CSR & PWR_FLAG) != (uint32_t)RESET)
  486. {
  487. bitstatus = SET;
  488. }
  489. else
  490. {
  491. bitstatus = RESET;
  492. }
  493. /* Return the flag status */
  494. return bitstatus;
  495. }
  496. /**
  497. * @brief Clears the PWR's pending flags.
  498. * @param PWR_FLAG: specifies the flag to clear.
  499. * This parameter can be one of the following values:
  500. * @arg PWR_FLAG_WU: Wake Up flag
  501. * @arg PWR_FLAG_SB: StandBy flag
  502. * @retval None
  503. */
  504. void PWR_ClearFlag(uint32_t PWR_FLAG)
  505. {
  506. /* Check the parameters */
  507. assert_param(IS_PWR_CLEAR_FLAG(PWR_FLAG));
  508. PWR->CR |= PWR_FLAG << 2;
  509. }
  510. /**
  511. * @}
  512. */
  513. /**
  514. * @}
  515. */
  516. /**
  517. * @}
  518. */
  519. /**
  520. * @}
  521. */