2 ******************************************************************************
\r
3 * @file stm32l1xx_hal_pwr_ex.c
\r
4 * @author MCD Application Team
\r
5 * @brief Extended PWR HAL module driver.
\r
6 * This file provides firmware functions to manage the following
\r
7 * functionalities of the Power Controller (PWR) peripheral:
\r
8 * + Extended Initialization and de-initialization functions
\r
9 * + Extended Peripheral Control functions
\r
11 ******************************************************************************
\r
14 * <h2><center>© Copyright (c) 2017 STMicroelectronics.
\r
15 * All rights reserved.</center></h2>
\r
17 * This software component is licensed by ST under BSD 3-Clause license,
\r
18 * the "License"; You may not use this file except in compliance with the
\r
19 * License. You may obtain a copy of the License at:
\r
20 * opensource.org/licenses/BSD-3-Clause
\r
22 ******************************************************************************
\r
25 /* Includes ------------------------------------------------------------------*/
\r
26 #include "stm32l1xx_hal.h"
\r
28 /** @addtogroup STM32L1xx_HAL_Driver
\r
32 /** @defgroup PWREx PWREx
\r
33 * @brief PWR HAL module driver
\r
37 #ifdef HAL_PWR_MODULE_ENABLED
\r
39 /* Private typedef -----------------------------------------------------------*/
\r
40 /* Private define ------------------------------------------------------------*/
\r
41 /* Private macro -------------------------------------------------------------*/
\r
42 /* Private variables ---------------------------------------------------------*/
\r
43 /* Private function prototypes -----------------------------------------------*/
\r
44 /* Private functions ---------------------------------------------------------*/
\r
46 /** @defgroup PWREx_Exported_Functions PWREx Exported Functions
\r
50 /** @defgroup PWREx_Exported_Functions_Group1 Peripheral Extended Features Functions
\r
51 * @brief Low Power modes configuration functions
\r
55 ===============================================================================
\r
56 ##### Peripheral extended features functions #####
\r
57 ===============================================================================
\r
63 * @brief Return Voltage Scaling Range.
\r
64 * @retval VOS bit field (PWR_REGULATOR_VOLTAGE_SCALE1, PWR_REGULATOR_VOLTAGE_SCALE2 or PWR_REGULATOR_VOLTAGE_SCALE3)
\r
66 uint32_t HAL_PWREx_GetVoltageRange(void)
\r
68 return (PWR->CR & PWR_CR_VOS);
\r
73 * @brief Enables the Fast WakeUp from Ultra Low Power mode.
\r
74 * @note This bit works in conjunction with ULP bit.
\r
75 * Means, when ULP = 1 and FWU = 1 :VREFINT startup time is ignored when
\r
76 * exiting from low power mode.
\r
79 void HAL_PWREx_EnableFastWakeUp(void)
\r
81 /* Enable the fast wake up */
\r
82 *(__IO uint32_t *) CR_FWU_BB = (uint32_t)ENABLE;
\r
86 * @brief Disables the Fast WakeUp from Ultra Low Power mode.
\r
89 void HAL_PWREx_DisableFastWakeUp(void)
\r
91 /* Disable the fast wake up */
\r
92 *(__IO uint32_t *) CR_FWU_BB = (uint32_t)DISABLE;
\r
96 * @brief Enables the Ultra Low Power mode
\r
99 void HAL_PWREx_EnableUltraLowPower(void)
\r
101 /* Enable the Ultra Low Power mode */
\r
102 *(__IO uint32_t *) CR_ULP_BB = (uint32_t)ENABLE;
\r
106 * @brief Disables the Ultra Low Power mode
\r
109 void HAL_PWREx_DisableUltraLowPower(void)
\r
111 /* Disable the Ultra Low Power mode */
\r
112 *(__IO uint32_t *) CR_ULP_BB = (uint32_t)DISABLE;
\r
116 * @brief Enters the Low Power Run mode.
\r
117 * @note Low power run mode can only be entered when VCORE is in range 2.
\r
118 * In addition, the dynamic voltage scaling must not be used when Low
\r
119 * power run mode is selected. Only Stop and Sleep modes with regulator
\r
120 * configured in Low power mode is allowed when Low power run mode is
\r
122 * @note In Low power run mode, all I/O pins keep the same state as in Run mode.
\r
125 void HAL_PWREx_EnableLowPowerRunMode(void)
\r
127 /* Enters the Low Power Run mode */
\r
128 *(__IO uint32_t *) CR_LPSDSR_BB = (uint32_t)ENABLE;
\r
129 *(__IO uint32_t *) CR_LPRUN_BB = (uint32_t)ENABLE;
\r
133 * @brief Exits the Low Power Run mode.
\r
136 HAL_StatusTypeDef HAL_PWREx_DisableLowPowerRunMode(void)
\r
138 /* Exits the Low Power Run mode */
\r
139 *(__IO uint32_t *) CR_LPRUN_BB = (uint32_t)DISABLE;
\r
140 *(__IO uint32_t *) CR_LPSDSR_BB = (uint32_t)DISABLE;
\r
152 #endif /* HAL_PWR_MODULE_ENABLED */
\r
161 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
\r