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.
 
 
 

1177 lines
38 KiB

  1. /**
  2. ******************************************************************************
  3. * @file stm32l4xx_hal_pwr_ex.c
  4. * @author MCD Application Team
  5. * @version V1.3.0
  6. * @date 29-January-2016
  7. * @brief Extended PWR HAL module driver.
  8. * This file provides firmware functions to manage the following
  9. * functionalities of the Power Controller (PWR) peripheral:
  10. * + Extended Initialization and de-initialization functions
  11. * + Extended Peripheral Control functions
  12. *
  13. ******************************************************************************
  14. * @attention
  15. *
  16. * <h2><center>&copy; COPYRIGHT(c) 2016 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 "stm32l4xx_hal.h"
  44. /** @addtogroup STM32L4xx_HAL_Driver
  45. * @{
  46. */
  47. /** @defgroup PWREx PWREx
  48. * @brief PWR Extended HAL module driver
  49. * @{
  50. */
  51. #ifdef HAL_PWR_MODULE_ENABLED
  52. /* Private typedef -----------------------------------------------------------*/
  53. /* Private define ------------------------------------------------------------*/
  54. #define PWR_PORTH_AVAILABLE_PINS (PWR_GPIO_BIT_0|PWR_GPIO_BIT_1)
  55. /** @defgroup PWR_Extended_Private_Defines PWR Extended Private Defines
  56. * @{
  57. */
  58. /** @defgroup PWREx_PVM_Mode_Mask PWR PVM Mode Mask
  59. * @{
  60. */
  61. #define PVM_MODE_IT ((uint32_t)0x00010000) /*!< Mask for interruption yielded by PVM threshold crossing */
  62. #define PVM_MODE_EVT ((uint32_t)0x00020000) /*!< Mask for event yielded by PVM threshold crossing */
  63. #define PVM_RISING_EDGE ((uint32_t)0x00000001) /*!< Mask for rising edge set as PVM trigger */
  64. #define PVM_FALLING_EDGE ((uint32_t)0x00000002) /*!< Mask for falling edge set as PVM trigger */
  65. /**
  66. * @}
  67. */
  68. /** @defgroup PWREx_TimeOut_Value PWR Extended Flag Setting Time Out Value
  69. * @{
  70. */
  71. #define PWR_FLAG_SETTING_DELAY_US 50 /*!< Time out value for REGLPF and VOSF flags setting */
  72. /**
  73. * @}
  74. */
  75. /**
  76. * @}
  77. */
  78. /* Private macro -------------------------------------------------------------*/
  79. /* Private variables ---------------------------------------------------------*/
  80. /* Private function prototypes -----------------------------------------------*/
  81. /* Exported functions --------------------------------------------------------*/
  82. /** @defgroup PWREx_Exported_Functions PWR Extended Exported Functions
  83. * @{
  84. */
  85. /** @defgroup PWREx_Exported_Functions_Group1 Extended Peripheral Control functions
  86. * @brief Extended Peripheral Control functions
  87. *
  88. @verbatim
  89. ===============================================================================
  90. ##### Extended Peripheral Initialization and de-initialization functions #####
  91. ===============================================================================
  92. [..]
  93. @endverbatim
  94. * @{
  95. */
  96. /**
  97. * @brief Return Voltage Scaling Range.
  98. * @retval VOS bit field (PWR_REGULATOR_VOLTAGE_RANGE1 or PWR_REGULATOR_VOLTAGE_RANGE2)
  99. */
  100. uint32_t HAL_PWREx_GetVoltageRange(void)
  101. {
  102. return (PWR->CR1 & PWR_CR1_VOS);
  103. }
  104. /**
  105. * @brief Configure the main internal regulator output voltage.
  106. * @param VoltageScaling: specifies the regulator output voltage to achieve
  107. * a tradeoff between performance and power consumption.
  108. * This parameter can be one of the following values:
  109. * @arg @ref PWR_REGULATOR_VOLTAGE_SCALE1 Regulator voltage output range 1 mode,
  110. * typical output voltage at 1.2 V,
  111. * system frequency up to 80 MHz.
  112. * @arg @ref PWR_REGULATOR_VOLTAGE_SCALE2 Regulator voltage output range 2 mode,
  113. * typical output voltage at 1.0 V,
  114. * system frequency up to 26 MHz.
  115. * @note When moving from Range 1 to Range 2, the system frequency must be decreased to
  116. * a value below 26 MHz before calling HAL_PWREx_ControlVoltageScaling() API.
  117. * When moving from Range 2 to Range 1, the system frequency can be increased to
  118. * a value up to 80 MHz after calling HAL_PWREx_ControlVoltageScaling() API.
  119. * @note When moving from Range 2 to Range 1, the API waits for VOSF flag to be
  120. * cleared before returning the status. If the flag is not cleared within
  121. * 50 microseconds, HAL_TIMEOUT status is reported.
  122. * @retval HAL Status
  123. */
  124. HAL_StatusTypeDef HAL_PWREx_ControlVoltageScaling(uint32_t VoltageScaling)
  125. {
  126. uint32_t wait_loop_index = 0;
  127. assert_param(IS_PWR_VOLTAGE_SCALING_RANGE(VoltageScaling));
  128. /* If Set Range 1 */
  129. if (VoltageScaling == PWR_REGULATOR_VOLTAGE_SCALE1)
  130. {
  131. if (READ_BIT(PWR->CR1, PWR_CR1_VOS) != PWR_REGULATOR_VOLTAGE_SCALE1)
  132. {
  133. /* Set Range 1 */
  134. MODIFY_REG(PWR->CR1, PWR_CR1_VOS, PWR_REGULATOR_VOLTAGE_SCALE1);
  135. /* Wait until VOSF is cleared */
  136. wait_loop_index = (PWR_FLAG_SETTING_DELAY_US * (SystemCoreClock / 1000000));
  137. while ((wait_loop_index != 0) && (HAL_IS_BIT_SET(PWR->SR2, PWR_SR2_VOSF)))
  138. {
  139. wait_loop_index--;
  140. }
  141. if (HAL_IS_BIT_SET(PWR->SR2, PWR_SR2_VOSF))
  142. {
  143. return HAL_TIMEOUT;
  144. }
  145. }
  146. }
  147. else
  148. {
  149. if (READ_BIT(PWR->CR1, PWR_CR1_VOS) != PWR_REGULATOR_VOLTAGE_SCALE2)
  150. {
  151. /* Set Range 2 */
  152. MODIFY_REG(PWR->CR1, PWR_CR1_VOS, PWR_REGULATOR_VOLTAGE_SCALE2);
  153. /* No need to wait for VOSF to be cleared for this transition */
  154. }
  155. }
  156. return HAL_OK;
  157. }
  158. /**
  159. * @brief Enable battery charging.
  160. * When VDD is present, charge the external battery on VBAT thru an internal resistor.
  161. * @param ResistorSelection: specifies the resistor impedance.
  162. * This parameter can be one of the following values:
  163. * @arg @ref PWR_BATTERY_CHARGING_RESISTOR_5 5 kOhms resistor
  164. * @arg @ref PWR_BATTERY_CHARGING_RESISTOR_1_5 1.5 kOhms resistor
  165. * @retval None
  166. */
  167. void HAL_PWREx_EnableBatteryCharging(uint32_t ResistorSelection)
  168. {
  169. assert_param(IS_PWR_BATTERY_RESISTOR_SELECT(ResistorSelection));
  170. /* Specify resistor selection */
  171. MODIFY_REG(PWR->CR4, PWR_CR4_VBRS, ResistorSelection);
  172. /* Enable battery charging */
  173. SET_BIT(PWR->CR4, PWR_CR4_VBE);
  174. }
  175. /**
  176. * @brief Disable battery charging.
  177. * @retval None
  178. */
  179. void HAL_PWREx_DisableBatteryCharging(void)
  180. {
  181. CLEAR_BIT(PWR->CR4, PWR_CR4_VBE);
  182. }
  183. #if defined (STM32L475xx) || defined (STM32L476xx) || defined (STM32L485xx) || defined (STM32L486xx)
  184. /**
  185. * @brief Enable VDDUSB supply.
  186. * @note Remove VDDUSB electrical and logical isolation, once VDDUSB supply is present.
  187. * @retval None
  188. */
  189. void HAL_PWREx_EnableVddUSB(void)
  190. {
  191. SET_BIT(PWR->CR2, PWR_CR2_USV);
  192. }
  193. /**
  194. * @brief Disable VDDUSB supply.
  195. * @retval None
  196. */
  197. void HAL_PWREx_DisableVddUSB(void)
  198. {
  199. CLEAR_BIT(PWR->CR2, PWR_CR2_USV);
  200. }
  201. #endif /* defined (STM32L475xx) || defined (STM32L476xx) || defined (STM32L485xx) || defined (STM32L486xx) */
  202. /**
  203. * @brief Enable VDDIO2 supply.
  204. * @note Remove VDDIO2 electrical and logical isolation, once VDDIO2 supply is present.
  205. * @retval None
  206. */
  207. void HAL_PWREx_EnableVddIO2(void)
  208. {
  209. SET_BIT(PWR->CR2, PWR_CR2_IOSV);
  210. }
  211. /**
  212. * @brief Disable VDDIO2 supply.
  213. * @retval None
  214. */
  215. void HAL_PWREx_DisableVddIO2(void)
  216. {
  217. CLEAR_BIT(PWR->CR2, PWR_CR2_IOSV);
  218. }
  219. /**
  220. * @brief Enable Internal Wake-up Line.
  221. * @retval None
  222. */
  223. void HAL_PWREx_EnableInternalWakeUpLine(void)
  224. {
  225. SET_BIT(PWR->CR3, PWR_CR3_EIWF);
  226. }
  227. /**
  228. * @brief Disable Internal Wake-up Line.
  229. * @retval None
  230. */
  231. void HAL_PWREx_DisableInternalWakeUpLine(void)
  232. {
  233. CLEAR_BIT(PWR->CR3, PWR_CR3_EIWF);
  234. }
  235. /**
  236. * @brief Enable GPIO pull-up state in Standby and Shutdown modes.
  237. * @note Set the relevant PUy bits of PWR_PUCRx register to configure the I/O in
  238. * pull-up state in Standby and Shutdown modes.
  239. * @note This state is effective in Standby and Shutdown modes only if APC bit
  240. * is set through HAL_PWREx_EnablePullUpPullDownConfig() API.
  241. * @note The configuration is lost when exiting the Shutdown mode due to the
  242. * power-on reset, maintained when exiting the Standby mode.
  243. * @note To avoid any conflict at Standby and Shutdown modes exits, the corresponding
  244. * PDy bit of PWR_PDCRx register is cleared unless it is reserved.
  245. * @note Even if a PUy bit to set is reserved, the other PUy bits entered as input
  246. * parameter at the same time are set.
  247. * @param GPIO: Specify the IO port. This parameter can be PWR_GPIO_A, ..., PWR_GPIO_H
  248. * to select the GPIO peripheral.
  249. * @param GPIONumber: Specify the I/O pins numbers.
  250. * This parameter can be one of the following values:
  251. * PWR_GPIO_BIT_0, ..., PWR_GPIO_BIT_15 (except for PORTH where less
  252. * I/O pins are available) or the logical OR of several of them to set
  253. * several bits for a given port in a single API call.
  254. * @retval HAL Status
  255. */
  256. HAL_StatusTypeDef HAL_PWREx_EnableGPIOPullUp(uint32_t GPIO, uint32_t GPIONumber)
  257. {
  258. assert_param(IS_PWR_GPIO(GPIO));
  259. assert_param(IS_PWR_GPIO_BIT_NUMBER(GPIONumber));
  260. switch (GPIO)
  261. {
  262. case PWR_GPIO_A:
  263. SET_BIT(PWR->PUCRA, (GPIONumber & (~(PWR_GPIO_BIT_14))));
  264. CLEAR_BIT(PWR->PDCRA, (GPIONumber & (~(PWR_GPIO_BIT_13|PWR_GPIO_BIT_15))));
  265. break;
  266. case PWR_GPIO_B:
  267. SET_BIT(PWR->PUCRB, GPIONumber);
  268. CLEAR_BIT(PWR->PDCRB, (GPIONumber & (~(PWR_GPIO_BIT_4))));
  269. break;
  270. case PWR_GPIO_C:
  271. SET_BIT(PWR->PUCRC, GPIONumber);
  272. CLEAR_BIT(PWR->PDCRC, GPIONumber);
  273. break;
  274. case PWR_GPIO_D:
  275. SET_BIT(PWR->PUCRD, GPIONumber);
  276. CLEAR_BIT(PWR->PDCRD, GPIONumber);
  277. break;
  278. case PWR_GPIO_E:
  279. SET_BIT(PWR->PUCRE, GPIONumber);
  280. CLEAR_BIT(PWR->PDCRE, GPIONumber);
  281. break;
  282. case PWR_GPIO_F:
  283. SET_BIT(PWR->PUCRF, GPIONumber);
  284. CLEAR_BIT(PWR->PDCRF, GPIONumber);
  285. break;
  286. case PWR_GPIO_G:
  287. SET_BIT(PWR->PUCRG, GPIONumber);
  288. CLEAR_BIT(PWR->PDCRG, GPIONumber);
  289. break;
  290. case PWR_GPIO_H:
  291. SET_BIT(PWR->PUCRH, (GPIONumber & PWR_PORTH_AVAILABLE_PINS));
  292. CLEAR_BIT(PWR->PDCRH, (GPIONumber & PWR_PORTH_AVAILABLE_PINS));
  293. break;
  294. default:
  295. return HAL_ERROR;
  296. }
  297. return HAL_OK;
  298. }
  299. /**
  300. * @brief Disable GPIO pull-up state in Standby mode and Shutdown modes.
  301. * @note Reset the relevant PUy bits of PWR_PUCRx register used to configure the I/O
  302. * in pull-up state in Standby and Shutdown modes.
  303. * @note Even if a PUy bit to reset is reserved, the other PUy bits entered as input
  304. * parameter at the same time are reset.
  305. * @param GPIO: Specifies the IO port. This parameter can be PWR_GPIO_A, ..., PWR_GPIO_H
  306. * to select the GPIO peripheral.
  307. * @param GPIONumber: Specify the I/O pins numbers.
  308. * This parameter can be one of the following values:
  309. * PWR_GPIO_BIT_0, ..., PWR_GPIO_BIT_15 (except for PORTH where less
  310. * I/O pins are available) or the logical OR of several of them to reset
  311. * several bits for a given port in a single API call.
  312. * @retval HAL Status
  313. */
  314. HAL_StatusTypeDef HAL_PWREx_DisableGPIOPullUp(uint32_t GPIO, uint32_t GPIONumber)
  315. {
  316. assert_param(IS_PWR_GPIO(GPIO));
  317. assert_param(IS_PWR_GPIO_BIT_NUMBER(GPIONumber));
  318. switch (GPIO)
  319. {
  320. case PWR_GPIO_A:
  321. CLEAR_BIT(PWR->PUCRA, (GPIONumber & (~(PWR_GPIO_BIT_14))));
  322. break;
  323. case PWR_GPIO_B:
  324. CLEAR_BIT(PWR->PUCRB, GPIONumber);
  325. break;
  326. case PWR_GPIO_C:
  327. CLEAR_BIT(PWR->PUCRC, GPIONumber);
  328. break;
  329. case PWR_GPIO_D:
  330. CLEAR_BIT(PWR->PUCRD, GPIONumber);
  331. break;
  332. case PWR_GPIO_E:
  333. CLEAR_BIT(PWR->PUCRE, GPIONumber);
  334. break;
  335. case PWR_GPIO_F:
  336. CLEAR_BIT(PWR->PUCRF, GPIONumber);
  337. break;
  338. case PWR_GPIO_G:
  339. CLEAR_BIT(PWR->PUCRG, GPIONumber);
  340. break;
  341. case PWR_GPIO_H:
  342. CLEAR_BIT(PWR->PUCRH, (GPIONumber & PWR_PORTH_AVAILABLE_PINS));
  343. break;
  344. default:
  345. return HAL_ERROR;
  346. }
  347. return HAL_OK;
  348. }
  349. /**
  350. * @brief Enable GPIO pull-down state in Standby and Shutdown modes.
  351. * @note Set the relevant PDy bits of PWR_PDCRx register to configure the I/O in
  352. * pull-down state in Standby and Shutdown modes.
  353. * @note This state is effective in Standby and Shutdown modes only if APC bit
  354. * is set through HAL_PWREx_EnablePullUpPullDownConfig() API.
  355. * @note The configuration is lost when exiting the Shutdown mode due to the
  356. * power-on reset, maintained when exiting the Standby mode.
  357. * @note To avoid any conflict at Standby and Shutdown modes exits, the corresponding
  358. * PUy bit of PWR_PUCRx register is cleared unless it is reserved.
  359. * @note Even if a PDy bit to set is reserved, the other PDy bits entered as input
  360. * parameter at the same time are set.
  361. * @param GPIO: Specify the IO port. This parameter can be PWR_GPIO_A..PWR_GPIO_H
  362. * to select the GPIO peripheral.
  363. * @param GPIONumber: Specify the I/O pins numbers.
  364. * This parameter can be one of the following values:
  365. * PWR_GPIO_BIT_0, ..., PWR_GPIO_BIT_15 (except for PORTH where less
  366. * I/O pins are available) or the logical OR of several of them to set
  367. * several bits for a given port in a single API call.
  368. * @retval HAL Status
  369. */
  370. HAL_StatusTypeDef HAL_PWREx_EnableGPIOPullDown(uint32_t GPIO, uint32_t GPIONumber)
  371. {
  372. assert_param(IS_PWR_GPIO(GPIO));
  373. assert_param(IS_PWR_GPIO_BIT_NUMBER(GPIONumber));
  374. switch (GPIO)
  375. {
  376. case PWR_GPIO_A:
  377. SET_BIT(PWR->PDCRA, (GPIONumber & (~(PWR_GPIO_BIT_13|PWR_GPIO_BIT_15))));
  378. CLEAR_BIT(PWR->PUCRA, (GPIONumber & (~(PWR_GPIO_BIT_14))));
  379. break;
  380. case PWR_GPIO_B:
  381. SET_BIT(PWR->PDCRB, (GPIONumber & (~(PWR_GPIO_BIT_4))));
  382. CLEAR_BIT(PWR->PUCRB, GPIONumber);
  383. break;
  384. case PWR_GPIO_C:
  385. SET_BIT(PWR->PDCRC, GPIONumber);
  386. CLEAR_BIT(PWR->PUCRC, GPIONumber);
  387. break;
  388. case PWR_GPIO_D:
  389. SET_BIT(PWR->PDCRD, GPIONumber);
  390. CLEAR_BIT(PWR->PUCRD, GPIONumber);
  391. break;
  392. case PWR_GPIO_E:
  393. SET_BIT(PWR->PDCRE, GPIONumber);
  394. CLEAR_BIT(PWR->PUCRE, GPIONumber);
  395. break;
  396. case PWR_GPIO_F:
  397. SET_BIT(PWR->PDCRF, GPIONumber);
  398. CLEAR_BIT(PWR->PUCRF, GPIONumber);
  399. break;
  400. case PWR_GPIO_G:
  401. SET_BIT(PWR->PDCRG, GPIONumber);
  402. CLEAR_BIT(PWR->PUCRG, GPIONumber);
  403. break;
  404. case PWR_GPIO_H:
  405. SET_BIT(PWR->PDCRH, (GPIONumber & PWR_PORTH_AVAILABLE_PINS));
  406. CLEAR_BIT(PWR->PUCRH, (GPIONumber & PWR_PORTH_AVAILABLE_PINS));
  407. break;
  408. default:
  409. return HAL_ERROR;
  410. }
  411. return HAL_OK;
  412. }
  413. /**
  414. * @brief Disable GPIO pull-down state in Standby and Shutdown modes.
  415. * @note Reset the relevant PDy bits of PWR_PDCRx register used to configure the I/O
  416. * in pull-down state in Standby and Shutdown modes.
  417. * @note Even if a PDy bit to reset is reserved, the other PDy bits entered as input
  418. * parameter at the same time are reset.
  419. * @param GPIO: Specifies the IO port. This parameter can be PWR_GPIO_A..PWR_GPIO_H
  420. * to select the GPIO peripheral.
  421. * @param GPIONumber: Specify the I/O pins numbers.
  422. * This parameter can be one of the following values:
  423. * PWR_GPIO_BIT_0, ..., PWR_GPIO_BIT_15 (except for PORTH where less
  424. * I/O pins are available) or the logical OR of several of them to reset
  425. * several bits for a given port in a single API call.
  426. * @retval HAL Status
  427. */
  428. HAL_StatusTypeDef HAL_PWREx_DisableGPIOPullDown(uint32_t GPIO, uint32_t GPIONumber)
  429. {
  430. assert_param(IS_PWR_GPIO(GPIO));
  431. assert_param(IS_PWR_GPIO_BIT_NUMBER(GPIONumber));
  432. switch (GPIO)
  433. {
  434. case PWR_GPIO_A:
  435. CLEAR_BIT(PWR->PDCRA, (GPIONumber & (~(PWR_GPIO_BIT_13|PWR_GPIO_BIT_15))));
  436. break;
  437. case PWR_GPIO_B:
  438. CLEAR_BIT(PWR->PDCRB, (GPIONumber & (~(PWR_GPIO_BIT_4))));
  439. break;
  440. case PWR_GPIO_C:
  441. CLEAR_BIT(PWR->PDCRC, GPIONumber);
  442. break;
  443. case PWR_GPIO_D:
  444. CLEAR_BIT(PWR->PDCRD, GPIONumber);
  445. break;
  446. case PWR_GPIO_E:
  447. CLEAR_BIT(PWR->PDCRE, GPIONumber);
  448. break;
  449. case PWR_GPIO_F:
  450. CLEAR_BIT(PWR->PDCRF, GPIONumber);
  451. break;
  452. case PWR_GPIO_G:
  453. CLEAR_BIT(PWR->PDCRG, GPIONumber);
  454. break;
  455. case PWR_GPIO_H:
  456. CLEAR_BIT(PWR->PDCRH, (GPIONumber & PWR_PORTH_AVAILABLE_PINS));
  457. break;
  458. default:
  459. return HAL_ERROR;
  460. }
  461. return HAL_OK;
  462. }
  463. /**
  464. * @brief Enable pull-up and pull-down configuration.
  465. * @note When APC bit is set, the I/O pull-up and pull-down configurations defined in
  466. * PWR_PUCRx and PWR_PDCRx registers are applied in Standby and Shutdown modes.
  467. * @note Pull-up set by PUy bit of PWR_PUCRx register is not activated if the corresponding
  468. * PDy bit of PWR_PDCRx register is also set (pull-down configuration priority is higher).
  469. * HAL_PWREx_EnableGPIOPullUp() and HAL_PWREx_EnableGPIOPullDown() API's ensure there
  470. * is no conflict when setting PUy or PDy bit.
  471. * @retval None
  472. */
  473. void HAL_PWREx_EnablePullUpPullDownConfig(void)
  474. {
  475. SET_BIT(PWR->CR3, PWR_CR3_APC);
  476. }
  477. /**
  478. * @brief Disable pull-up and pull-down configuration.
  479. * @note When APC bit is cleared, the I/O pull-up and pull-down configurations defined in
  480. * PWR_PUCRx and PWR_PDCRx registers are not applied in Standby and Shutdown modes.
  481. * @retval None
  482. */
  483. void HAL_PWREx_DisablePullUpPullDownConfig(void)
  484. {
  485. CLEAR_BIT(PWR->CR3, PWR_CR3_APC);
  486. }
  487. /**
  488. * @brief Enable SRAM2 content retention in Standby mode.
  489. * @note When RRS bit is set, SRAM2 is powered by the low-power regulator in
  490. * Standby mode and its content is kept.
  491. * @retval None
  492. */
  493. void HAL_PWREx_EnableSRAM2ContentRetention(void)
  494. {
  495. SET_BIT(PWR->CR3, PWR_CR3_RRS);
  496. }
  497. /**
  498. * @brief Disable SRAM2 content retention in Standby mode.
  499. * @note When RRS bit is reset, SRAM2 is powered off in Standby mode
  500. * and its content is lost.
  501. * @retval None
  502. */
  503. void HAL_PWREx_DisableSRAM2ContentRetention(void)
  504. {
  505. CLEAR_BIT(PWR->CR3, PWR_CR3_RRS);
  506. }
  507. #if defined (STM32L475xx) || defined (STM32L476xx) || defined (STM32L485xx) || defined (STM32L486xx)
  508. /**
  509. * @brief Enable the Power Voltage Monitoring 1: VDDUSB versus 1.2V.
  510. * @retval None
  511. */
  512. void HAL_PWREx_EnablePVM1(void)
  513. {
  514. SET_BIT(PWR->CR2, PWR_PVM_1);
  515. }
  516. /**
  517. * @brief Disable the Power Voltage Monitoring 1: VDDUSB versus 1.2V.
  518. * @retval None
  519. */
  520. void HAL_PWREx_DisablePVM1(void)
  521. {
  522. CLEAR_BIT(PWR->CR2, PWR_PVM_1);
  523. }
  524. #endif /* defined (STM32L475xx) || defined (STM32L476xx) || defined (STM32L485xx) || defined (STM32L486xx) */
  525. /**
  526. * @brief Enable the Power Voltage Monitoring 2: VDDIO2 versus 0.9V.
  527. * @retval None
  528. */
  529. void HAL_PWREx_EnablePVM2(void)
  530. {
  531. SET_BIT(PWR->CR2, PWR_PVM_2);
  532. }
  533. /**
  534. * @brief Disable the Power Voltage Monitoring 2: VDDIO2 versus 0.9V.
  535. * @retval None
  536. */
  537. void HAL_PWREx_DisablePVM2(void)
  538. {
  539. CLEAR_BIT(PWR->CR2, PWR_PVM_2);
  540. }
  541. /**
  542. * @brief Enable the Power Voltage Monitoring 3: VDDA versus 1.62V.
  543. * @retval None
  544. */
  545. void HAL_PWREx_EnablePVM3(void)
  546. {
  547. SET_BIT(PWR->CR2, PWR_PVM_3);
  548. }
  549. /**
  550. * @brief Disable the Power Voltage Monitoring 3: VDDA versus 1.62V.
  551. * @retval None
  552. */
  553. void HAL_PWREx_DisablePVM3(void)
  554. {
  555. CLEAR_BIT(PWR->CR2, PWR_PVM_3);
  556. }
  557. /**
  558. * @brief Enable the Power Voltage Monitoring 4: VDDA versus 2.2V.
  559. * @retval None
  560. */
  561. void HAL_PWREx_EnablePVM4(void)
  562. {
  563. SET_BIT(PWR->CR2, PWR_PVM_4);
  564. }
  565. /**
  566. * @brief Disable the Power Voltage Monitoring 4: VDDA versus 2.2V.
  567. * @retval None
  568. */
  569. void HAL_PWREx_DisablePVM4(void)
  570. {
  571. CLEAR_BIT(PWR->CR2, PWR_PVM_4);
  572. }
  573. /**
  574. * @brief Configure the Peripheral Voltage Monitoring (PVM).
  575. * @param sConfigPVM: pointer to a PWR_PVMTypeDef structure that contains the
  576. * PVM configuration information.
  577. * @note The API configures a single PVM according to the information contained
  578. * in the input structure. To configure several PVMs, the API must be singly
  579. * called for each PVM used.
  580. * @note Refer to the electrical characteristics of your device datasheet for
  581. * more details about the voltage thresholds corresponding to each
  582. * detection level and to each monitored supply.
  583. * @retval HAL status
  584. */
  585. HAL_StatusTypeDef HAL_PWREx_ConfigPVM(PWR_PVMTypeDef *sConfigPVM)
  586. {
  587. /* Check the parameters */
  588. assert_param(IS_PWR_PVM_TYPE(sConfigPVM->PVMType));
  589. assert_param(IS_PWR_PVM_MODE(sConfigPVM->Mode));
  590. /* Configure EXTI 35 to 38 interrupts if so required:
  591. scan thru PVMType to detect which PVMx is set and
  592. configure the corresponding EXTI line accordingly. */
  593. switch (sConfigPVM->PVMType)
  594. {
  595. #if defined (STM32L475xx) || defined (STM32L476xx) || defined (STM32L485xx) || defined (STM32L486xx)
  596. case PWR_PVM_1:
  597. /* Clear any previous config. Keep it clear if no event or IT mode is selected */
  598. __HAL_PWR_PVM1_EXTI_DISABLE_EVENT();
  599. __HAL_PWR_PVM1_EXTI_DISABLE_IT();
  600. __HAL_PWR_PVM1_EXTI_DISABLE_FALLING_EDGE();
  601. __HAL_PWR_PVM1_EXTI_DISABLE_RISING_EDGE();
  602. /* Configure interrupt mode */
  603. if((sConfigPVM->Mode & PVM_MODE_IT) == PVM_MODE_IT)
  604. {
  605. __HAL_PWR_PVM1_EXTI_ENABLE_IT();
  606. }
  607. /* Configure event mode */
  608. if((sConfigPVM->Mode & PVM_MODE_EVT) == PVM_MODE_EVT)
  609. {
  610. __HAL_PWR_PVM1_EXTI_ENABLE_EVENT();
  611. }
  612. /* Configure the edge */
  613. if((sConfigPVM->Mode & PVM_RISING_EDGE) == PVM_RISING_EDGE)
  614. {
  615. __HAL_PWR_PVM1_EXTI_ENABLE_RISING_EDGE();
  616. }
  617. if((sConfigPVM->Mode & PVM_FALLING_EDGE) == PVM_FALLING_EDGE)
  618. {
  619. __HAL_PWR_PVM1_EXTI_ENABLE_FALLING_EDGE();
  620. }
  621. break;
  622. #endif /* defined (STM32L475xx) || defined (STM32L476xx) || defined (STM32L485xx) || defined (STM32L486xx) */
  623. case PWR_PVM_2:
  624. /* Clear any previous config. Keep it clear if no event or IT mode is selected */
  625. __HAL_PWR_PVM2_EXTI_DISABLE_EVENT();
  626. __HAL_PWR_PVM2_EXTI_DISABLE_IT();
  627. __HAL_PWR_PVM2_EXTI_DISABLE_FALLING_EDGE();
  628. __HAL_PWR_PVM2_EXTI_DISABLE_RISING_EDGE();
  629. /* Configure interrupt mode */
  630. if((sConfigPVM->Mode & PVM_MODE_IT) == PVM_MODE_IT)
  631. {
  632. __HAL_PWR_PVM2_EXTI_ENABLE_IT();
  633. }
  634. /* Configure event mode */
  635. if((sConfigPVM->Mode & PVM_MODE_EVT) == PVM_MODE_EVT)
  636. {
  637. __HAL_PWR_PVM2_EXTI_ENABLE_EVENT();
  638. }
  639. /* Configure the edge */
  640. if((sConfigPVM->Mode & PVM_RISING_EDGE) == PVM_RISING_EDGE)
  641. {
  642. __HAL_PWR_PVM2_EXTI_ENABLE_RISING_EDGE();
  643. }
  644. if((sConfigPVM->Mode & PVM_FALLING_EDGE) == PVM_FALLING_EDGE)
  645. {
  646. __HAL_PWR_PVM2_EXTI_ENABLE_FALLING_EDGE();
  647. }
  648. break;
  649. case PWR_PVM_3:
  650. /* Clear any previous config. Keep it clear if no event or IT mode is selected */
  651. __HAL_PWR_PVM3_EXTI_DISABLE_EVENT();
  652. __HAL_PWR_PVM3_EXTI_DISABLE_IT();
  653. __HAL_PWR_PVM3_EXTI_DISABLE_FALLING_EDGE();
  654. __HAL_PWR_PVM3_EXTI_DISABLE_RISING_EDGE();
  655. /* Configure interrupt mode */
  656. if((sConfigPVM->Mode & PVM_MODE_IT) == PVM_MODE_IT)
  657. {
  658. __HAL_PWR_PVM3_EXTI_ENABLE_IT();
  659. }
  660. /* Configure event mode */
  661. if((sConfigPVM->Mode & PVM_MODE_EVT) == PVM_MODE_EVT)
  662. {
  663. __HAL_PWR_PVM3_EXTI_ENABLE_EVENT();
  664. }
  665. /* Configure the edge */
  666. if((sConfigPVM->Mode & PVM_RISING_EDGE) == PVM_RISING_EDGE)
  667. {
  668. __HAL_PWR_PVM3_EXTI_ENABLE_RISING_EDGE();
  669. }
  670. if((sConfigPVM->Mode & PVM_FALLING_EDGE) == PVM_FALLING_EDGE)
  671. {
  672. __HAL_PWR_PVM3_EXTI_ENABLE_FALLING_EDGE();
  673. }
  674. break;
  675. case PWR_PVM_4:
  676. /* Clear any previous config. Keep it clear if no event or IT mode is selected */
  677. __HAL_PWR_PVM4_EXTI_DISABLE_EVENT();
  678. __HAL_PWR_PVM4_EXTI_DISABLE_IT();
  679. __HAL_PWR_PVM4_EXTI_DISABLE_FALLING_EDGE();
  680. __HAL_PWR_PVM4_EXTI_DISABLE_RISING_EDGE();
  681. /* Configure interrupt mode */
  682. if((sConfigPVM->Mode & PVM_MODE_IT) == PVM_MODE_IT)
  683. {
  684. __HAL_PWR_PVM4_EXTI_ENABLE_IT();
  685. }
  686. /* Configure event mode */
  687. if((sConfigPVM->Mode & PVM_MODE_EVT) == PVM_MODE_EVT)
  688. {
  689. __HAL_PWR_PVM4_EXTI_ENABLE_EVENT();
  690. }
  691. /* Configure the edge */
  692. if((sConfigPVM->Mode & PVM_RISING_EDGE) == PVM_RISING_EDGE)
  693. {
  694. __HAL_PWR_PVM4_EXTI_ENABLE_RISING_EDGE();
  695. }
  696. if((sConfigPVM->Mode & PVM_FALLING_EDGE) == PVM_FALLING_EDGE)
  697. {
  698. __HAL_PWR_PVM4_EXTI_ENABLE_FALLING_EDGE();
  699. }
  700. break;
  701. default:
  702. return HAL_ERROR;
  703. }
  704. return HAL_OK;
  705. }
  706. /**
  707. * @brief Enter Low-power Run mode
  708. * @note In Low-power Run mode, all I/O pins keep the same state as in Run mode.
  709. * @note When Regulator is set to PWR_LOWPOWERREGULATOR_ON, the user can optionally configure the
  710. * Flash in power-down monde in setting the RUN_PD bit in FLASH_ACR register.
  711. * Additionally, the clock frequency must be reduced below 2 MHz.
  712. * Setting RUN_PD in FLASH_ACR then appropriately reducing the clock frequency must
  713. * be done before calling HAL_PWREx_EnableLowPowerRunMode() API.
  714. * @retval None
  715. */
  716. void HAL_PWREx_EnableLowPowerRunMode(void)
  717. {
  718. /* Set Regulator parameter */
  719. SET_BIT(PWR->CR1, PWR_CR1_LPR);
  720. }
  721. /**
  722. * @brief Exit Low-power Run mode.
  723. * @note Before HAL_PWREx_DisableLowPowerRunMode() completion, the function checks that
  724. * REGLPF has been properly reset (otherwise, HAL_PWREx_DisableLowPowerRunMode
  725. * returns HAL_TIMEOUT status). The system clock frequency can then be
  726. * increased above 2 MHz.
  727. * @retval HAL Status
  728. */
  729. HAL_StatusTypeDef HAL_PWREx_DisableLowPowerRunMode(void)
  730. {
  731. uint32_t wait_loop_index = 0;
  732. /* Clear LPR bit */
  733. CLEAR_BIT(PWR->CR1, PWR_CR1_LPR);
  734. /* Wait until REGLPF is reset */
  735. wait_loop_index = (PWR_FLAG_SETTING_DELAY_US * (SystemCoreClock / 1000000));
  736. while ((wait_loop_index != 0) && (HAL_IS_BIT_SET(PWR->SR2, PWR_SR2_REGLPF)))
  737. {
  738. wait_loop_index--;
  739. }
  740. if (HAL_IS_BIT_SET(PWR->SR2, PWR_SR2_REGLPF))
  741. {
  742. return HAL_TIMEOUT;
  743. }
  744. return HAL_OK;
  745. }
  746. /**
  747. * @brief Enter Stop 0 mode.
  748. * @note In Stop 0 mode, main and low voltage regulators are ON.
  749. * @note In Stop 0 mode, all I/O pins keep the same state as in Run mode.
  750. * @note All clocks in the VCORE domain are stopped; the PLL, the MSI,
  751. * the HSI and the HSE oscillators are disabled. Some peripherals with the wakeup capability
  752. * (I2Cx, USARTx and LPUART) can switch on the HSI to receive a frame, and switch off the HSI
  753. * after receiving the frame if it is not a wakeup frame. In this case, the HSI clock is propagated
  754. * only to the peripheral requesting it.
  755. * SRAM1, SRAM2 and register contents are preserved.
  756. * The BOR is available.
  757. * @note When exiting Stop 0 mode by issuing an interrupt or a wakeup event,
  758. * the HSI RC oscillator is selected as system clock if STOPWUCK bit in RCC_CFGR register
  759. * is set; the MSI oscillator is selected if STOPWUCK is cleared.
  760. * @note By keeping the internal regulator ON during Stop 0 mode, the consumption
  761. * is higher although the startup time is reduced.
  762. * @param STOPEntry specifies if Stop mode in entered with WFI or WFE instruction.
  763. * This parameter can be one of the following values:
  764. * @arg @ref PWR_STOPENTRY_WFI Enter Stop mode with WFI instruction
  765. * @arg @ref PWR_STOPENTRY_WFE Enter Stop mode with WFE instruction
  766. * @retval None
  767. */
  768. void HAL_PWREx_EnterSTOP0Mode(uint8_t STOPEntry)
  769. {
  770. /* Check the parameters */
  771. assert_param(IS_PWR_STOP_ENTRY(STOPEntry));
  772. /* Stop 0 mode with Main Regulator */
  773. MODIFY_REG(PWR->CR1, PWR_CR1_LPMS, PWR_CR1_LPMS_STOP0);
  774. /* Set SLEEPDEEP bit of Cortex System Control Register */
  775. SET_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPDEEP_Msk));
  776. /* Select Stop mode entry --------------------------------------------------*/
  777. if(STOPEntry == PWR_STOPENTRY_WFI)
  778. {
  779. /* Request Wait For Interrupt */
  780. __WFI();
  781. }
  782. else
  783. {
  784. /* Request Wait For Event */
  785. __SEV();
  786. __WFE();
  787. __WFE();
  788. }
  789. /* Reset SLEEPDEEP bit of Cortex System Control Register */
  790. CLEAR_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPDEEP_Msk));
  791. }
  792. /**
  793. * @brief Enter Stop 1 mode.
  794. * @note In Stop 1 mode, only low power voltage regulator is ON.
  795. * @note In Stop 1 mode, all I/O pins keep the same state as in Run mode.
  796. * @note All clocks in the VCORE domain are stopped; the PLL, the MSI,
  797. * the HSI and the HSE oscillators are disabled. Some peripherals with the wakeup capability
  798. * (I2Cx, USARTx and LPUART) can switch on the HSI to receive a frame, and switch off the HSI
  799. * after receiving the frame if it is not a wakeup frame. In this case, the HSI clock is propagated
  800. * only to the peripheral requesting it.
  801. * SRAM1, SRAM2 and register contents are preserved.
  802. * The BOR is available.
  803. * @note When exiting Stop 1 mode by issuing an interrupt or a wakeup event,
  804. * the HSI RC oscillator is selected as system clock if STOPWUCK bit in RCC_CFGR register
  805. * is set; the MSI oscillator is selected if STOPWUCK is cleared.
  806. * @note Due to low power mode, an additional startup delay is incurred when waking up from Stop 1 mode.
  807. * @param STOPEntry specifies if Stop mode in entered with WFI or WFE instruction.
  808. * This parameter can be one of the following values:
  809. * @arg @ref PWR_STOPENTRY_WFI Enter Stop mode with WFI instruction
  810. * @arg @ref PWR_STOPENTRY_WFE Enter Stop mode with WFE instruction
  811. * @retval None
  812. */
  813. void HAL_PWREx_EnterSTOP1Mode(uint8_t STOPEntry)
  814. {
  815. /* Check the parameters */
  816. assert_param(IS_PWR_STOP_ENTRY(STOPEntry));
  817. /* Stop 1 mode with Low-Power Regulator */
  818. MODIFY_REG(PWR->CR1, PWR_CR1_LPMS, PWR_CR1_LPMS_STOP1);
  819. /* Set SLEEPDEEP bit of Cortex System Control Register */
  820. SET_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPDEEP_Msk));
  821. /* Select Stop mode entry --------------------------------------------------*/
  822. if(STOPEntry == PWR_STOPENTRY_WFI)
  823. {
  824. /* Request Wait For Interrupt */
  825. __WFI();
  826. }
  827. else
  828. {
  829. /* Request Wait For Event */
  830. __SEV();
  831. __WFE();
  832. __WFE();
  833. }
  834. /* Reset SLEEPDEEP bit of Cortex System Control Register */
  835. CLEAR_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPDEEP_Msk));
  836. }
  837. /**
  838. * @brief Enter Stop 2 mode.
  839. * @note In Stop 2 mode, only low power voltage regulator is ON.
  840. * @note In Stop 2 mode, all I/O pins keep the same state as in Run mode.
  841. * @note All clocks in the VCORE domain are stopped, the PLL, the MSI,
  842. * the HSI and the HSE oscillators are disabled. Some peripherals with wakeup capability
  843. * (LCD, LPTIM1, I2C3 and LPUART) can switch on the HSI to receive a frame, and switch off the HSI after
  844. * receiving the frame if it is not a wakeup frame. In this case the HSI clock is propagated only
  845. * to the peripheral requesting it.
  846. * SRAM1, SRAM2 and register contents are preserved.
  847. * The BOR is available.
  848. * The voltage regulator is set in low-power mode but LPR bit must be cleared to enter stop 2 mode.
  849. * Otherwise, Stop 1 mode is entered.
  850. * @note When exiting Stop 2 mode by issuing an interrupt or a wakeup event,
  851. * the HSI RC oscillator is selected as system clock if STOPWUCK bit in RCC_CFGR register
  852. * is set; the MSI oscillator is selected if STOPWUCK is cleared.
  853. * @param STOPEntry specifies if Stop mode in entered with WFI or WFE instruction.
  854. * This parameter can be one of the following values:
  855. * @arg @ref PWR_STOPENTRY_WFI Enter Stop mode with WFI instruction
  856. * @arg @ref PWR_STOPENTRY_WFE Enter Stop mode with WFE instruction
  857. * @retval None
  858. */
  859. void HAL_PWREx_EnterSTOP2Mode(uint8_t STOPEntry)
  860. {
  861. /* Check the parameter */
  862. assert_param(IS_PWR_STOP_ENTRY(STOPEntry));
  863. /* Set Stop mode 2 */
  864. MODIFY_REG(PWR->CR1, PWR_CR1_LPMS, PWR_CR1_LPMS_STOP2);
  865. /* Set SLEEPDEEP bit of Cortex System Control Register */
  866. SET_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPDEEP_Msk));
  867. /* Select Stop mode entry --------------------------------------------------*/
  868. if(STOPEntry == PWR_STOPENTRY_WFI)
  869. {
  870. /* Request Wait For Interrupt */
  871. __WFI();
  872. }
  873. else
  874. {
  875. /* Request Wait For Event */
  876. __SEV();
  877. __WFE();
  878. __WFE();
  879. }
  880. /* Reset SLEEPDEEP bit of Cortex System Control Register */
  881. CLEAR_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPDEEP_Msk));
  882. }
  883. /**
  884. * @brief Enter Shutdown mode.
  885. * @note In Shutdown mode, the PLL, the HSI, the MSI, the LSI and the HSE oscillators are switched
  886. * off. The voltage regulator is disabled and Vcore domain is powered off.
  887. * SRAM1, SRAM2 and registers contents are lost except for registers in the Backup domain.
  888. * The BOR is not available.
  889. * @note The I/Os can be configured either with a pull-up or pull-down or can be kept in analog state.
  890. * @retval None
  891. */
  892. void HAL_PWREx_EnterSHUTDOWNMode(void)
  893. {
  894. /* Set Shutdown mode */
  895. MODIFY_REG(PWR->CR1, PWR_CR1_LPMS, PWR_CR1_LPMS_SHUTDOWN);
  896. /* Set SLEEPDEEP bit of Cortex System Control Register */
  897. SET_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPDEEP_Msk));
  898. /* This option is used to ensure that store operations are completed */
  899. #if defined ( __CC_ARM)
  900. __force_stores();
  901. #endif
  902. /* Request Wait For Interrupt */
  903. __WFI();
  904. }
  905. /**
  906. * @brief This function handles the PWR PVD/PVMx interrupt request.
  907. * @note This API should be called under the PVD_PVM_IRQHandler().
  908. * @retval None
  909. */
  910. void HAL_PWREx_PVD_PVM_IRQHandler(void)
  911. {
  912. /* Check PWR exti flag */
  913. if(__HAL_PWR_PVD_EXTI_GET_FLAG() != RESET)
  914. {
  915. /* PWR PVD interrupt user callback */
  916. HAL_PWR_PVDCallback();
  917. /* Clear PVD exti pending bit */
  918. __HAL_PWR_PVD_EXTI_CLEAR_FLAG();
  919. }
  920. /* Next, successively check PVMx exti flags */
  921. #if defined (STM32L475xx) || defined (STM32L476xx) || defined (STM32L485xx) || defined (STM32L486xx)
  922. if(__HAL_PWR_PVM1_EXTI_GET_FLAG() != RESET)
  923. {
  924. /* PWR PVM1 interrupt user callback */
  925. HAL_PWREx_PVM1Callback();
  926. /* Clear PVM1 exti pending bit */
  927. __HAL_PWR_PVM1_EXTI_CLEAR_FLAG();
  928. }
  929. #endif /* defined (STM32L475xx) || defined (STM32L476xx) || defined (STM32L485xx) || defined (STM32L486xx) */
  930. if(__HAL_PWR_PVM2_EXTI_GET_FLAG() != RESET)
  931. {
  932. /* PWR PVM2 interrupt user callback */
  933. HAL_PWREx_PVM2Callback();
  934. /* Clear PVM2 exti pending bit */
  935. __HAL_PWR_PVM2_EXTI_CLEAR_FLAG();
  936. }
  937. if(__HAL_PWR_PVM3_EXTI_GET_FLAG() != RESET)
  938. {
  939. /* PWR PVM3 interrupt user callback */
  940. HAL_PWREx_PVM3Callback();
  941. /* Clear PVM3 exti pending bit */
  942. __HAL_PWR_PVM3_EXTI_CLEAR_FLAG();
  943. }
  944. if(__HAL_PWR_PVM4_EXTI_GET_FLAG() != RESET)
  945. {
  946. /* PWR PVM4 interrupt user callback */
  947. HAL_PWREx_PVM4Callback();
  948. /* Clear PVM4 exti pending bit */
  949. __HAL_PWR_PVM4_EXTI_CLEAR_FLAG();
  950. }
  951. }
  952. #if defined (STM32L475xx) || defined (STM32L476xx) || defined (STM32L485xx) || defined (STM32L486xx)
  953. /**
  954. * @brief PWR PVM1 interrupt callback
  955. * @retval None
  956. */
  957. __weak void HAL_PWREx_PVM1Callback(void)
  958. {
  959. /* NOTE : This function should not be modified; when the callback is needed,
  960. HAL_PWREx_PVM1Callback() API can be implemented in the user file
  961. */
  962. }
  963. #endif /* defined (STM32L475xx) || defined (STM32L476xx) || defined (STM32L485xx) || defined (STM32L486xx) */
  964. /**
  965. * @brief PWR PVM2 interrupt callback
  966. * @retval None
  967. */
  968. __weak void HAL_PWREx_PVM2Callback(void)
  969. {
  970. /* NOTE : This function should not be modified; when the callback is needed,
  971. HAL_PWREx_PVM2Callback() API can be implemented in the user file
  972. */
  973. }
  974. /**
  975. * @brief PWR PVM3 interrupt callback
  976. * @retval None
  977. */
  978. __weak void HAL_PWREx_PVM3Callback(void)
  979. {
  980. /* NOTE : This function should not be modified; when the callback is needed,
  981. HAL_PWREx_PVM3Callback() API can be implemented in the user file
  982. */
  983. }
  984. /**
  985. * @brief PWR PVM4 interrupt callback
  986. * @retval None
  987. */
  988. __weak void HAL_PWREx_PVM4Callback(void)
  989. {
  990. /* NOTE : This function should not be modified; when the callback is needed,
  991. HAL_PWREx_PVM4Callback() API can be implemented in the user file
  992. */
  993. }
  994. /**
  995. * @}
  996. */
  997. /**
  998. * @}
  999. */
  1000. #endif /* HAL_PWR_MODULE_ENABLED */
  1001. /**
  1002. * @}
  1003. */
  1004. /**
  1005. * @}
  1006. */
  1007. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/