Rev 50 | Details | Compare with Previous | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 77 | mjames | 1 | /** |
| 2 | ****************************************************************************** |
||
| 3 | * @file stm32l1xx_hal_pwr_ex.c |
||
| 4 | * @author MCD Application Team |
||
| 5 | * @brief Extended PWR HAL module driver. |
||
| 6 | * This file provides firmware functions to manage the following |
||
| 7 | * functionalities of the Power Controller (PWR) peripheral: |
||
| 8 | * + Extended Initialization and de-initialization functions |
||
| 9 | * + Extended Peripheral Control functions |
||
| 10 | * |
||
| 11 | ****************************************************************************** |
||
| 12 | * @attention |
||
| 13 | * |
||
| 14 | * Copyright (c) 2017 STMicroelectronics. |
||
| 15 | * All rights reserved. |
||
| 16 | * |
||
| 17 | * This software is licensed under terms that can be found in the LICENSE file |
||
| 18 | * in the root directory of this software component. |
||
| 19 | * If no LICENSE file comes with this software, it is provided AS-IS. |
||
| 20 | * |
||
| 21 | ****************************************************************************** |
||
| 22 | */ |
||
| 23 | |||
| 24 | /* Includes ------------------------------------------------------------------*/ |
||
| 25 | #include "stm32l1xx_hal.h" |
||
| 26 | |||
| 27 | /** @addtogroup STM32L1xx_HAL_Driver |
||
| 28 | * @{ |
||
| 29 | */ |
||
| 30 | |||
| 31 | /** @defgroup PWREx PWREx |
||
| 32 | * @brief PWR HAL module driver |
||
| 33 | * @{ |
||
| 34 | */ |
||
| 35 | |||
| 36 | #ifdef HAL_PWR_MODULE_ENABLED |
||
| 37 | |||
| 38 | /* Private typedef -----------------------------------------------------------*/ |
||
| 39 | /* Private define ------------------------------------------------------------*/ |
||
| 40 | /* Private macro -------------------------------------------------------------*/ |
||
| 41 | /* Private variables ---------------------------------------------------------*/ |
||
| 42 | /* Private function prototypes -----------------------------------------------*/ |
||
| 43 | /* Private functions ---------------------------------------------------------*/ |
||
| 44 | |||
| 45 | /** @defgroup PWREx_Exported_Functions PWREx Exported Functions |
||
| 46 | * @{ |
||
| 47 | */ |
||
| 48 | |||
| 49 | /** @defgroup PWREx_Exported_Functions_Group1 Peripheral Extended Features Functions |
||
| 50 | * @brief Low Power modes configuration functions |
||
| 51 | * |
||
| 52 | @verbatim |
||
| 53 | |||
| 54 | =============================================================================== |
||
| 55 | ##### Peripheral extended features functions ##### |
||
| 56 | =============================================================================== |
||
| 57 | @endverbatim |
||
| 58 | * @{ |
||
| 59 | */ |
||
| 60 | |||
| 61 | /** |
||
| 62 | * @brief Return Voltage Scaling Range. |
||
| 63 | * @retval VOS bit field (PWR_REGULATOR_VOLTAGE_SCALE1, PWR_REGULATOR_VOLTAGE_SCALE2 or PWR_REGULATOR_VOLTAGE_SCALE3) |
||
| 64 | */ |
||
| 65 | uint32_t HAL_PWREx_GetVoltageRange(void) |
||
| 66 | { |
||
| 67 | return (PWR->CR & PWR_CR_VOS); |
||
| 68 | } |
||
| 69 | |||
| 70 | |||
| 71 | /** |
||
| 72 | * @brief Enables the Fast WakeUp from Ultra Low Power mode. |
||
| 73 | * @note This bit works in conjunction with ULP bit. |
||
| 74 | * Means, when ULP = 1 and FWU = 1 :VREFINT startup time is ignored when |
||
| 75 | * exiting from low power mode. |
||
| 76 | * @retval None |
||
| 77 | */ |
||
| 78 | void HAL_PWREx_EnableFastWakeUp(void) |
||
| 79 | { |
||
| 80 | /* Enable the fast wake up */ |
||
| 81 | *(__IO uint32_t *) CR_FWU_BB = (uint32_t)ENABLE; |
||
| 82 | } |
||
| 83 | |||
| 84 | /** |
||
| 85 | * @brief Disables the Fast WakeUp from Ultra Low Power mode. |
||
| 86 | * @retval None |
||
| 87 | */ |
||
| 88 | void HAL_PWREx_DisableFastWakeUp(void) |
||
| 89 | { |
||
| 90 | /* Disable the fast wake up */ |
||
| 91 | *(__IO uint32_t *) CR_FWU_BB = (uint32_t)DISABLE; |
||
| 92 | } |
||
| 93 | |||
| 94 | /** |
||
| 95 | * @brief Enables the Ultra Low Power mode |
||
| 96 | * @retval None |
||
| 97 | */ |
||
| 98 | void HAL_PWREx_EnableUltraLowPower(void) |
||
| 99 | { |
||
| 100 | /* Enable the Ultra Low Power mode */ |
||
| 101 | *(__IO uint32_t *) CR_ULP_BB = (uint32_t)ENABLE; |
||
| 102 | } |
||
| 103 | |||
| 104 | /** |
||
| 105 | * @brief Disables the Ultra Low Power mode |
||
| 106 | * @retval None |
||
| 107 | */ |
||
| 108 | void HAL_PWREx_DisableUltraLowPower(void) |
||
| 109 | { |
||
| 110 | /* Disable the Ultra Low Power mode */ |
||
| 111 | *(__IO uint32_t *) CR_ULP_BB = (uint32_t)DISABLE; |
||
| 112 | } |
||
| 113 | |||
| 114 | /** |
||
| 115 | * @brief Enters the Low Power Run mode. |
||
| 116 | * @note Low power run mode can only be entered when VCORE is in range 2. |
||
| 117 | * In addition, the dynamic voltage scaling must not be used when Low |
||
| 118 | * power run mode is selected. Only Stop and Sleep modes with regulator |
||
| 119 | * configured in Low power mode is allowed when Low power run mode is |
||
| 120 | * selected. |
||
| 121 | * @note In Low power run mode, all I/O pins keep the same state as in Run mode. |
||
| 122 | * @retval None |
||
| 123 | */ |
||
| 124 | void HAL_PWREx_EnableLowPowerRunMode(void) |
||
| 125 | { |
||
| 126 | /* Enters the Low Power Run mode */ |
||
| 127 | *(__IO uint32_t *) CR_LPSDSR_BB = (uint32_t)ENABLE; |
||
| 128 | *(__IO uint32_t *) CR_LPRUN_BB = (uint32_t)ENABLE; |
||
| 129 | } |
||
| 130 | |||
| 131 | /** |
||
| 132 | * @brief Exits the Low Power Run mode. |
||
| 133 | * @retval None |
||
| 134 | */ |
||
| 135 | HAL_StatusTypeDef HAL_PWREx_DisableLowPowerRunMode(void) |
||
| 136 | { |
||
| 137 | /* Exits the Low Power Run mode */ |
||
| 138 | *(__IO uint32_t *) CR_LPRUN_BB = (uint32_t)DISABLE; |
||
| 139 | *(__IO uint32_t *) CR_LPSDSR_BB = (uint32_t)DISABLE; |
||
| 140 | return HAL_OK; |
||
| 141 | } |
||
| 142 | |||
| 143 | /** |
||
| 144 | * @} |
||
| 145 | */ |
||
| 146 | |||
| 147 | /** |
||
| 148 | * @} |
||
| 149 | */ |
||
| 150 | |||
| 151 | #endif /* HAL_PWR_MODULE_ENABLED */ |
||
| 152 | /** |
||
| 153 | * @} |
||
| 154 | */ |
||
| 155 | |||
| 156 | /** |
||
| 157 | * @} |
||
| 158 | */ |