SHIO

Fork of mbed-stm32l0/l1-src by lzbp li

Committer:
mbed_official
Date:
Fri Oct 31 11:00:10 2014 +0000
Revision:
376:cb4d9db17537
Synchronized with git revision 07b49da75eac883fc8916d3d6b6962664b8db29e

Full URL: https://github.com/mbedmicro/mbed/commit/07b49da75eac883fc8916d3d6b6962664b8db29e/

Targets: DISCO_L053C8 - new platform - STM32L0 Discovery board

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 376:cb4d9db17537 1 /**
mbed_official 376:cb4d9db17537 2 ******************************************************************************
mbed_official 376:cb4d9db17537 3 * @file stm32l0xx_hal_pwr.c
mbed_official 376:cb4d9db17537 4 * @author MCD Application Team
mbed_official 376:cb4d9db17537 5 * @version V1.1.0
mbed_official 376:cb4d9db17537 6 * @date 18-June-2014
mbed_official 376:cb4d9db17537 7 * @brief PWR HAL module driver.
mbed_official 376:cb4d9db17537 8 *
mbed_official 376:cb4d9db17537 9 * This file provides firmware functions to manage the following
mbed_official 376:cb4d9db17537 10 * functionalities of the Power Controller (PWR) peripheral:
mbed_official 376:cb4d9db17537 11 * + Initialization/de-initialization functions
mbed_official 376:cb4d9db17537 12 * + Peripheral Control functions
mbed_official 376:cb4d9db17537 13 *
mbed_official 376:cb4d9db17537 14 @verbatim
mbed_official 376:cb4d9db17537 15 ******************************************************************************
mbed_official 376:cb4d9db17537 16 * @attention
mbed_official 376:cb4d9db17537 17 *
mbed_official 376:cb4d9db17537 18 * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
mbed_official 376:cb4d9db17537 19 *
mbed_official 376:cb4d9db17537 20 * Redistribution and use in source and binary forms, with or without modification,
mbed_official 376:cb4d9db17537 21 * are permitted provided that the following conditions are met:
mbed_official 376:cb4d9db17537 22 * 1. Redistributions of source code must retain the above copyright notice,
mbed_official 376:cb4d9db17537 23 * this list of conditions and the following disclaimer.
mbed_official 376:cb4d9db17537 24 * 2. Redistributions in binary form must reproduce the above copyright notice,
mbed_official 376:cb4d9db17537 25 * this list of conditions and the following disclaimer in the documentation
mbed_official 376:cb4d9db17537 26 * and/or other materials provided with the distribution.
mbed_official 376:cb4d9db17537 27 * 3. Neither the name of STMicroelectronics nor the names of its contributors
mbed_official 376:cb4d9db17537 28 * may be used to endorse or promote products derived from this software
mbed_official 376:cb4d9db17537 29 * without specific prior written permission.
mbed_official 376:cb4d9db17537 30 *
mbed_official 376:cb4d9db17537 31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
mbed_official 376:cb4d9db17537 32 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
mbed_official 376:cb4d9db17537 33 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
mbed_official 376:cb4d9db17537 34 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
mbed_official 376:cb4d9db17537 35 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
mbed_official 376:cb4d9db17537 36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
mbed_official 376:cb4d9db17537 37 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
mbed_official 376:cb4d9db17537 38 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
mbed_official 376:cb4d9db17537 39 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
mbed_official 376:cb4d9db17537 40 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
mbed_official 376:cb4d9db17537 41 *
mbed_official 376:cb4d9db17537 42 ******************************************************************************
mbed_official 376:cb4d9db17537 43 */
mbed_official 376:cb4d9db17537 44
mbed_official 376:cb4d9db17537 45 /* Includes ------------------------------------------------------------------*/
mbed_official 376:cb4d9db17537 46 #include "stm32l0xx_hal.h"
mbed_official 376:cb4d9db17537 47
mbed_official 376:cb4d9db17537 48 /** @addtogroup STM32L0xx_HAL_Driver
mbed_official 376:cb4d9db17537 49 * @{
mbed_official 376:cb4d9db17537 50 */
mbed_official 376:cb4d9db17537 51
mbed_official 376:cb4d9db17537 52 /** @defgroup PWR
mbed_official 376:cb4d9db17537 53 * @brief PWR HAL module driver
mbed_official 376:cb4d9db17537 54 * @{
mbed_official 376:cb4d9db17537 55 */
mbed_official 376:cb4d9db17537 56
mbed_official 376:cb4d9db17537 57 #ifdef HAL_PWR_MODULE_ENABLED
mbed_official 376:cb4d9db17537 58
mbed_official 376:cb4d9db17537 59 /* Private typedef -----------------------------------------------------------*/
mbed_official 376:cb4d9db17537 60 /* Private define ------------------------------------------------------------*/
mbed_official 376:cb4d9db17537 61 /* Private macro -------------------------------------------------------------*/
mbed_official 376:cb4d9db17537 62 /* Private variables ---------------------------------------------------------*/
mbed_official 376:cb4d9db17537 63 /* Private function prototypes -----------------------------------------------*/
mbed_official 376:cb4d9db17537 64 /* Private functions ---------------------------------------------------------*/
mbed_official 376:cb4d9db17537 65
mbed_official 376:cb4d9db17537 66 /** @defgroup PWR_Private_Functions
mbed_official 376:cb4d9db17537 67 * @{
mbed_official 376:cb4d9db17537 68 */
mbed_official 376:cb4d9db17537 69
mbed_official 376:cb4d9db17537 70 /** @defgroup PWR_Group1 Initialization and De-initialization functions
mbed_official 376:cb4d9db17537 71 * @brief Initialization and Configuration functions
mbed_official 376:cb4d9db17537 72 *
mbed_official 376:cb4d9db17537 73 @verbatim
mbed_official 376:cb4d9db17537 74 ===============================================================================
mbed_official 376:cb4d9db17537 75 ##### Initialization and de-initialization functions #####
mbed_official 376:cb4d9db17537 76 ===============================================================================
mbed_official 376:cb4d9db17537 77 [..]
mbed_official 376:cb4d9db17537 78 After reset, the backup domain (RTC registers, RTC backup data
mbed_official 376:cb4d9db17537 79 registers) is protected against possible unwanted
mbed_official 376:cb4d9db17537 80 write accesses.
mbed_official 376:cb4d9db17537 81 To enable access to the RTC Domain and RTC registers, proceed as follows:
mbed_official 376:cb4d9db17537 82 (+) Enable the Power Controller (PWR) APB1 interface clock using the
mbed_official 376:cb4d9db17537 83 __PWR_CLK_ENABLE() macro.
mbed_official 376:cb4d9db17537 84 (+) Enable access to RTC domain using the HAL_PWR_EnableBkUpAccess() function.
mbed_official 376:cb4d9db17537 85
mbed_official 376:cb4d9db17537 86 @endverbatim
mbed_official 376:cb4d9db17537 87 * @{
mbed_official 376:cb4d9db17537 88 */
mbed_official 376:cb4d9db17537 89
mbed_official 376:cb4d9db17537 90 /**
mbed_official 376:cb4d9db17537 91 * @brief Deinitializes the HAL PWR peripheral registers to their default reset values.
mbed_official 376:cb4d9db17537 92 * @param None
mbed_official 376:cb4d9db17537 93 * @retval None
mbed_official 376:cb4d9db17537 94 */
mbed_official 376:cb4d9db17537 95 void HAL_PWR_DeInit(void)
mbed_official 376:cb4d9db17537 96 {
mbed_official 376:cb4d9db17537 97 __PWR_FORCE_RESET();
mbed_official 376:cb4d9db17537 98 __PWR_RELEASE_RESET();
mbed_official 376:cb4d9db17537 99 }
mbed_official 376:cb4d9db17537 100
mbed_official 376:cb4d9db17537 101 /**
mbed_official 376:cb4d9db17537 102 * @brief Enables access to the backup domain (RTC registers, RTC
mbed_official 376:cb4d9db17537 103 * backup data registers ).
mbed_official 376:cb4d9db17537 104 * @note If the HSE divided by 2, 4, 8 or 16 is used as the RTC clock, the
mbed_official 376:cb4d9db17537 105 * Backup Domain Access should be kept enabled.
mbed_official 376:cb4d9db17537 106 * @param None
mbed_official 376:cb4d9db17537 107 * @retval None
mbed_official 376:cb4d9db17537 108 */
mbed_official 376:cb4d9db17537 109 void HAL_PWR_EnableBkUpAccess(void)
mbed_official 376:cb4d9db17537 110 {
mbed_official 376:cb4d9db17537 111 /* Enable access to RTC and backup registers */
mbed_official 376:cb4d9db17537 112 PWR->CR |= PWR_CR_DBP;
mbed_official 376:cb4d9db17537 113 }
mbed_official 376:cb4d9db17537 114
mbed_official 376:cb4d9db17537 115 /**
mbed_official 376:cb4d9db17537 116 * @brief Disables access to the backup domain (RTC registers, RTC
mbed_official 376:cb4d9db17537 117 * backup data registers).
mbed_official 376:cb4d9db17537 118 * @note If the HSE divided by 2, 4, 8 or 16 is used as the RTC clock, the
mbed_official 376:cb4d9db17537 119 * Backup Domain Access should be kept enabled.
mbed_official 376:cb4d9db17537 120 * @param None
mbed_official 376:cb4d9db17537 121 * @retval None
mbed_official 376:cb4d9db17537 122 */
mbed_official 376:cb4d9db17537 123 void HAL_PWR_DisableBkUpAccess(void)
mbed_official 376:cb4d9db17537 124 {
mbed_official 376:cb4d9db17537 125 /* Disable access to RTC and backup registers */
mbed_official 376:cb4d9db17537 126 PWR->CR &= (uint32_t)~((uint32_t)PWR_CR_DBP);
mbed_official 376:cb4d9db17537 127 }
mbed_official 376:cb4d9db17537 128
mbed_official 376:cb4d9db17537 129 /**
mbed_official 376:cb4d9db17537 130 * @}
mbed_official 376:cb4d9db17537 131 */
mbed_official 376:cb4d9db17537 132
mbed_official 376:cb4d9db17537 133 /** @defgroup PWR_Group2 Peripheral Control functions
mbed_official 376:cb4d9db17537 134 * @brief Low Power modes configuration functions
mbed_official 376:cb4d9db17537 135 *
mbed_official 376:cb4d9db17537 136 @verbatim
mbed_official 376:cb4d9db17537 137
mbed_official 376:cb4d9db17537 138 ===============================================================================
mbed_official 376:cb4d9db17537 139 ##### Peripheral Control functions #####
mbed_official 376:cb4d9db17537 140 ===============================================================================
mbed_official 376:cb4d9db17537 141
mbed_official 376:cb4d9db17537 142 *** PVD configuration ***
mbed_official 376:cb4d9db17537 143 =========================
mbed_official 376:cb4d9db17537 144 [..]
mbed_official 376:cb4d9db17537 145 (+) The PVD is used to monitor the VDD power supply by comparing it to a
mbed_official 376:cb4d9db17537 146 threshold selected by the PVD Level (PLS[2:0] bits in the PWR_CR).
mbed_official 376:cb4d9db17537 147 (+) The PVD can use an external input analog voltage (PVD_IN) which is compared
mbed_official 376:cb4d9db17537 148 internally to VREFINT. The PVD_IN (PB7) has to be configured in Analog mode
mbed_official 376:cb4d9db17537 149 when PWR_PVDLevel_7 is selected (PLS[2:0] = 111).
mbed_official 376:cb4d9db17537 150
mbed_official 376:cb4d9db17537 151 (+) A PVDO flag is available to indicate if VDD/VDDA is higher or lower
mbed_official 376:cb4d9db17537 152 than the PVD threshold. This event is internally connected to the EXTI
mbed_official 376:cb4d9db17537 153 line16 and can generate an interrupt if enabled. This is done through
mbed_official 376:cb4d9db17537 154 __HAL_PVD_EXTI_ENABLE_IT() macro.
mbed_official 376:cb4d9db17537 155 (+) The PVD is stopped in Standby mode.
mbed_official 376:cb4d9db17537 156
mbed_official 376:cb4d9db17537 157 *** WakeUp pin configuration ***
mbed_official 376:cb4d9db17537 158 ================================
mbed_official 376:cb4d9db17537 159 [..]
mbed_official 376:cb4d9db17537 160 (+) WakeUp pin is used to wake up the system from Standby mode. This pin is
mbed_official 376:cb4d9db17537 161 forced in input pull-down configuration and is active on rising edges.
mbed_official 376:cb4d9db17537 162 (+) There are two WakeUp pins:
mbed_official 376:cb4d9db17537 163 WakeUp Pin 1 on PA.00.
mbed_official 376:cb4d9db17537 164 WakeUp Pin 2 on PC.13.
mbed_official 376:cb4d9db17537 165
mbed_official 376:cb4d9db17537 166 [..]
mbed_official 376:cb4d9db17537 167 *** Main and Backup Regulators configuration ***
mbed_official 376:cb4d9db17537 168 ================================================
mbed_official 376:cb4d9db17537 169
mbed_official 376:cb4d9db17537 170 (+) The main internal regulator can be configured to have a tradeoff between
mbed_official 376:cb4d9db17537 171 performance and power consumption when the device does not operate at
mbed_official 376:cb4d9db17537 172 the maximum frequency. This is done through __HAL_PWR_VOLTAGESCALING_CONFIG()
mbed_official 376:cb4d9db17537 173 macro which configure VOS bit in PWR_CR register:
mbed_official 376:cb4d9db17537 174 (++) When this bit is set (Regulator voltage output Scale 1 mode selected)
mbed_official 376:cb4d9db17537 175 the System frequency can go up to 32 MHz.
mbed_official 376:cb4d9db17537 176 (++) When this bit is reset (Regulator voltage output Scale 2 mode selected)
mbed_official 376:cb4d9db17537 177 the System frequency can go up to 16 MHz.
mbed_official 376:cb4d9db17537 178 (++) When this bit is reset (Regulator voltage output Scale 3 mode selected)
mbed_official 376:cb4d9db17537 179 the System frequency can go up to 4.2 MHz.
mbed_official 376:cb4d9db17537 180
mbed_official 376:cb4d9db17537 181 Refer to the datasheets for more details.
mbed_official 376:cb4d9db17537 182
mbed_official 376:cb4d9db17537 183 *** Low Power modes configuration ***
mbed_official 376:cb4d9db17537 184 =====================================
mbed_official 376:cb4d9db17537 185 [..]
mbed_official 376:cb4d9db17537 186 The device features 5 low-power modes:
mbed_official 376:cb4d9db17537 187 (+) Low power run mode: regulator in low power mode, limited clock frequency,
mbed_official 376:cb4d9db17537 188 limited number of peripherals running.
mbed_official 376:cb4d9db17537 189 (+) Sleep mode: Cortex-M0+ core stopped, peripherals kept running.
mbed_official 376:cb4d9db17537 190 (+) Low power sleep mode: Cortex-M0+ core stopped, limited clock frequency,
mbed_official 376:cb4d9db17537 191 limited number of peripherals running, regulator in low power mode.
mbed_official 376:cb4d9db17537 192 (+) Stop mode: All clocks are stopped, regulator running, regulator in low power mode.
mbed_official 376:cb4d9db17537 193 (+) Standby mode: VCORE domain powered off
mbed_official 376:cb4d9db17537 194
mbed_official 376:cb4d9db17537 195 *** Low power run mode ***
mbed_official 376:cb4d9db17537 196 =========================
mbed_official 376:cb4d9db17537 197 [..]
mbed_official 376:cb4d9db17537 198 To further reduce the consumption when the system is in Run mode, the regulator can be
mbed_official 376:cb4d9db17537 199 configured in low power mode. In this mode, the system frequency should not exceed
mbed_official 376:cb4d9db17537 200 MSI frequency range1.
mbed_official 376:cb4d9db17537 201 In Low power run mode, all I/O pins keep the same state as in Run mode.
mbed_official 376:cb4d9db17537 202
mbed_official 376:cb4d9db17537 203 (+) Entry:
mbed_official 376:cb4d9db17537 204 (++) VCORE in range2
mbed_official 376:cb4d9db17537 205 (++) Decrease the system frequency tonot exceed the frequency of MSI frequency range1.
mbed_official 376:cb4d9db17537 206 (++) The regulator is forced in low power mode using the HAL_PWREx_EnableLowPowerRunMode()
mbed_official 376:cb4d9db17537 207 function.
mbed_official 376:cb4d9db17537 208 (+) Exit:
mbed_official 376:cb4d9db17537 209 (++) The regulator is forced in Main regulator mode using the HAL_PWREx_DisableLowPowerRunMode()
mbed_official 376:cb4d9db17537 210 function.
mbed_official 376:cb4d9db17537 211 (++) Increase the system frequency if needed.
mbed_official 376:cb4d9db17537 212
mbed_official 376:cb4d9db17537 213 *** Sleep mode ***
mbed_official 376:cb4d9db17537 214 ==================
mbed_official 376:cb4d9db17537 215 [..]
mbed_official 376:cb4d9db17537 216 (+) Entry:
mbed_official 376:cb4d9db17537 217 The Sleep mode is entered by using the HAL_PWR_EnterSLEEPMode(PWR_MAINREGULATOR_ON, PWR_SLEEPENTRY_WFx)
mbed_official 376:cb4d9db17537 218 functions with
mbed_official 376:cb4d9db17537 219 (++) PWR_SLEEPENTRY_WFI: enter SLEEP mode with WFI instruction
mbed_official 376:cb4d9db17537 220 (++) PWR_SLEEPENTRY_WFE: enter SLEEP mode with WFE instruction
mbed_official 376:cb4d9db17537 221
mbed_official 376:cb4d9db17537 222 (+) Exit:
mbed_official 376:cb4d9db17537 223 (++) Any peripheral interrupt acknowledged by the nested vectored interrupt
mbed_official 376:cb4d9db17537 224 controller (NVIC) can wake up the device from Sleep mode.
mbed_official 376:cb4d9db17537 225
mbed_official 376:cb4d9db17537 226 *** Low power sleep mode ***
mbed_official 376:cb4d9db17537 227 ============================
mbed_official 376:cb4d9db17537 228 [..]
mbed_official 376:cb4d9db17537 229 (+) Entry:
mbed_official 376:cb4d9db17537 230 The Low power sleep mode is entered by using the HAL_PWR_EnterSLEEPMode(PWR_LOWPOWERREGULATOR_ON, PWR_SLEEPENTRY_WFx)
mbed_official 376:cb4d9db17537 231 functions with
mbed_official 376:cb4d9db17537 232 (++) PWR_SLEEPENTRY_WFI: enter SLEEP mode with WFI instruction
mbed_official 376:cb4d9db17537 233 (++) PWR_SLEEPENTRY_WFE: enter SLEEP mode with WFE instruction
mbed_official 376:cb4d9db17537 234 (+) The Flash memory can be switched off by using the control bits (SLEEP_PD in the FLASH_ACR register.
mbed_official 376:cb4d9db17537 235 This reduces power consumption but increases the wake-up time.
mbed_official 376:cb4d9db17537 236
mbed_official 376:cb4d9db17537 237 (+) Exit:
mbed_official 376:cb4d9db17537 238 (++) If the WFI instruction was used to enter Low power sleep mode, any peripheral interrupt
mbed_official 376:cb4d9db17537 239 acknowledged by the nested vectored interrupt controller (NVIC) can wake up the device
mbed_official 376:cb4d9db17537 240 from Low power sleep mode. If the WFE instruction was used to enter Low power sleep mode,
mbed_official 376:cb4d9db17537 241 the MCU exits Sleep mode as soon as an event occurs.
mbed_official 376:cb4d9db17537 242
mbed_official 376:cb4d9db17537 243 *** Stop mode ***
mbed_official 376:cb4d9db17537 244 =================
mbed_official 376:cb4d9db17537 245 [..]
mbed_official 376:cb4d9db17537 246 The Stop mode is based on the Cortex-M0+ deepsleep mode combined with peripheral
mbed_official 376:cb4d9db17537 247 clock gating. The voltage regulator can be configured either in normal or low-power mode.
mbed_official 376:cb4d9db17537 248 In Stop mode, all clocks in the VCORE domain are stopped, the PLL, the MSI, the HSI and
mbed_official 376:cb4d9db17537 249 the HSE RC oscillators are disabled. Internal SRAM and register contents are preserved.
mbed_official 376:cb4d9db17537 250 To get the lowest consumption in Stop mode, the internal Flash memory also enters low
mbed_official 376:cb4d9db17537 251 power mode. When the Flash memory is in power-down mode, an additional startup delay is
mbed_official 376:cb4d9db17537 252 incurred when waking up from Stop mode.
mbed_official 376:cb4d9db17537 253 To minimize the consumption In Stop mode, VREFINT, the BOR, PVD, and temperature
mbed_official 376:cb4d9db17537 254 sensor can be switched off before entering Stop mode. They can be switched on again by
mbed_official 376:cb4d9db17537 255 software after exiting Stop mode using the ULP bit in the PWR_CR register.
mbed_official 376:cb4d9db17537 256 In Stop mode, all I/O pins keep the same state as in Run mode.
mbed_official 376:cb4d9db17537 257
mbed_official 376:cb4d9db17537 258 (+) Entry:
mbed_official 376:cb4d9db17537 259 The Stop mode is entered using the HAL_PWR_EnterSTOPMode(PWR_MAINREGULATOR_ON, PWR_SLEEPENTRY_WFI )
mbed_official 376:cb4d9db17537 260 function with:
mbed_official 376:cb4d9db17537 261 (++) Main regulator ON.
mbed_official 376:cb4d9db17537 262 (++) Low Power regulator ON.
mbed_official 376:cb4d9db17537 263 (++) PWR_SLEEPENTRY_WFI: enter SLEEP mode with WFI instruction
mbed_official 376:cb4d9db17537 264 (++) PWR_SLEEPENTRY_WFE: enter SLEEP mode with WFE instruction
mbed_official 376:cb4d9db17537 265 (+) Exit:
mbed_official 376:cb4d9db17537 266 (++) By issuing an interrupt or a wakeup event, the MSI or HSI16 RC
mbed_official 376:cb4d9db17537 267 oscillator is selected as system clock depending the bit STOPWUCK in the RCC_CFGR
mbed_official 376:cb4d9db17537 268 register
mbed_official 376:cb4d9db17537 269
mbed_official 376:cb4d9db17537 270 *** Standby mode ***
mbed_official 376:cb4d9db17537 271 ====================
mbed_official 376:cb4d9db17537 272 [..]
mbed_official 376:cb4d9db17537 273 The Standby mode allows to achieve the lowest power consumption. It is based on the
mbed_official 376:cb4d9db17537 274 Cortex-M0+ deepsleep mode, with the voltage regulator disabled. The VCORE domain is
mbed_official 376:cb4d9db17537 275 consequently powered off. The PLL, the MSI, the HSI oscillator and the HSE oscillator are
mbed_official 376:cb4d9db17537 276 also switched off. SRAM and register contents are lost except for the RTC registers, RTC
mbed_official 376:cb4d9db17537 277 backup registers and Standby circuitry.
mbed_official 376:cb4d9db17537 278
mbed_official 376:cb4d9db17537 279 To minimize the consumption In Standby mode, VREFINT, the BOR, PVD, and temperature
mbed_official 376:cb4d9db17537 280 sensor can be switched off before entering the Standby mode. They can be switched
mbed_official 376:cb4d9db17537 281 on again by software after exiting the Standby mode.
mbed_official 376:cb4d9db17537 282 function.
mbed_official 376:cb4d9db17537 283
mbed_official 376:cb4d9db17537 284 (+) Entry:
mbed_official 376:cb4d9db17537 285 (++) The Standby mode is entered using the HAL_PWR_EnterSTANDBYMode() function.
mbed_official 376:cb4d9db17537 286 (+) Exit:
mbed_official 376:cb4d9db17537 287 (++) WKUP pin rising edge, RTC alarm (Alarm A and Alarm B), RTC wakeup,
mbed_official 376:cb4d9db17537 288 tamper event, time-stamp event, external reset in NRST pin, IWDG reset.
mbed_official 376:cb4d9db17537 289
mbed_official 376:cb4d9db17537 290 *** Auto-wakeup (AWU) from low-power mode ***
mbed_official 376:cb4d9db17537 291 =============================================
mbed_official 376:cb4d9db17537 292 [..]
mbed_official 376:cb4d9db17537 293 The MCU can be woken up from low-power mode by an RTC Alarm event, an RTC
mbed_official 376:cb4d9db17537 294 Wakeup event, a tamper event, a time-stamp event, or a comparator event,
mbed_official 376:cb4d9db17537 295 without depending on an external interrupt (Auto-wakeup mode).
mbed_official 376:cb4d9db17537 296
mbed_official 376:cb4d9db17537 297 (+) RTC auto-wakeup (AWU) from the Stop mode
mbed_official 376:cb4d9db17537 298 (++) To wake up from the Stop mode with an RTC alarm event, it is necessary to:
mbed_official 376:cb4d9db17537 299 (+++) Configure the EXTI Line 17 to be sensitive to rising edges (Interrupt
mbed_official 376:cb4d9db17537 300 or Event modes) using the EXTI_Init() function.
mbed_official 376:cb4d9db17537 301 (+++) Enable the RTC Alarm Interrupt using the RTC_ITConfig() function
mbed_official 376:cb4d9db17537 302 (+++) Configure the RTC to generate the RTC alarm using the RTC_SetAlarm()
mbed_official 376:cb4d9db17537 303 and RTC_AlarmCmd() functions.
mbed_official 376:cb4d9db17537 304 (++) To wake up from the Stop mode with an RTC Tamper or time stamp event, it
mbed_official 376:cb4d9db17537 305 is necessary to:
mbed_official 376:cb4d9db17537 306 (+++) Configure the EXTI Line 19 to be sensitive to rising edges (Interrupt
mbed_official 376:cb4d9db17537 307 or Event modes) using the EXTI_Init() function.
mbed_official 376:cb4d9db17537 308 (+++) Enable the RTC Tamper or time stamp Interrupt using the RTC_ITConfig()
mbed_official 376:cb4d9db17537 309 function.
mbed_official 376:cb4d9db17537 310 (+++) Configure the RTC to detect the tamper or time stamp event using the
mbed_official 376:cb4d9db17537 311 RTC_TimeStampConfig(), RTC_TamperTriggerConfig() and RTC_TamperCmd()
mbed_official 376:cb4d9db17537 312 functions.
mbed_official 376:cb4d9db17537 313 (++) To wake up from the Stop mode with an RTC WakeUp event, it is necessary to:
mbed_official 376:cb4d9db17537 314 (+++) Configure the EXTI Line 20 to be sensitive to rising edges (Interrupt
mbed_official 376:cb4d9db17537 315 or Event modes) using the EXTI_Init() function.
mbed_official 376:cb4d9db17537 316 (+++) Enable the RTC WakeUp Interrupt using the RTC_ITConfig() function.
mbed_official 376:cb4d9db17537 317 (+++) Configure the RTC to generate the RTC WakeUp event using the RTC_WakeUpClockConfig(),
mbed_official 376:cb4d9db17537 318 RTC_SetWakeUpCounter() and RTC_WakeUpCmd() functions.
mbed_official 376:cb4d9db17537 319
mbed_official 376:cb4d9db17537 320 (+) RTC auto-wakeup (AWU) from the Standby mode
mbed_official 376:cb4d9db17537 321 (++) To wake up from the Standby mode with an RTC alarm event, it is necessary to:
mbed_official 376:cb4d9db17537 322 (+++) Enable the RTC Alarm Interrupt using the RTC_ITConfig() function.
mbed_official 376:cb4d9db17537 323 (+++) Configure the RTC to generate the RTC alarm using the RTC_SetAlarm()
mbed_official 376:cb4d9db17537 324 and RTC_AlarmCmd() functions.
mbed_official 376:cb4d9db17537 325 (++) To wake up from the Standby mode with an RTC Tamper or time stamp event, it
mbed_official 376:cb4d9db17537 326 is necessary to:
mbed_official 376:cb4d9db17537 327 (+++) Enable the RTC Tamper or time stamp Interrupt using the RTC_ITConfig()
mbed_official 376:cb4d9db17537 328 function.
mbed_official 376:cb4d9db17537 329 (+++) Configure the RTC to detect the tamper or time stamp event using the
mbed_official 376:cb4d9db17537 330 RTC_TimeStampConfig(), RTC_TamperTriggerConfig() and RTC_TamperCmd()
mbed_official 376:cb4d9db17537 331 functions.
mbed_official 376:cb4d9db17537 332 (++) To wake up from the Standby mode with an RTC WakeUp event, it is necessary to:
mbed_official 376:cb4d9db17537 333 (+++) Enable the RTC WakeUp Interrupt using the RTC_ITConfig() function
mbed_official 376:cb4d9db17537 334 (+++) Configure the RTC to generate the RTC WakeUp event using the RTC_WakeUpClockConfig(),
mbed_official 376:cb4d9db17537 335 RTC_SetWakeUpCounter() and RTC_WakeUpCmd() functions.
mbed_official 376:cb4d9db17537 336
mbed_official 376:cb4d9db17537 337 (+) Comparator auto-wakeup (AWU) from the Stop mode
mbed_official 376:cb4d9db17537 338 (++) To wake up from the Stop mode with an comparator 1 or comparator 2 wakeup
mbed_official 376:cb4d9db17537 339 event, it is necessary to:
mbed_official 376:cb4d9db17537 340 (+++) Configure the EXTI Line 21 for comparator 1 or EXTI Line 22 for comparator 2
mbed_official 376:cb4d9db17537 341 to be sensitive to to the selected edges (falling, rising or falling
mbed_official 376:cb4d9db17537 342 and rising) (Interrupt or Event modes) using the EXTI_Init() function.
mbed_official 376:cb4d9db17537 343 (+++) Configure the comparator to generate the event.
mbed_official 376:cb4d9db17537 344
mbed_official 376:cb4d9db17537 345 @endverbatim
mbed_official 376:cb4d9db17537 346 * @{
mbed_official 376:cb4d9db17537 347 */
mbed_official 376:cb4d9db17537 348
mbed_official 376:cb4d9db17537 349 /**
mbed_official 376:cb4d9db17537 350 * @brief Configures the voltage threshold detected by the Power Voltage Detector(PVD).
mbed_official 376:cb4d9db17537 351 * @param sConfigPVD: pointer to an PWR_PVDTypeDef structure that contains the configuration
mbed_official 376:cb4d9db17537 352 * information for the PVD.
mbed_official 376:cb4d9db17537 353 * @note Refer to the electrical characteristics of your device datasheet for
mbed_official 376:cb4d9db17537 354 * more details about the voltage threshold corresponding to each
mbed_official 376:cb4d9db17537 355 * detection level.
mbed_official 376:cb4d9db17537 356 * @retval None
mbed_official 376:cb4d9db17537 357 */
mbed_official 376:cb4d9db17537 358 void HAL_PWR_PVDConfig(PWR_PVDTypeDef *sConfigPVD)
mbed_official 376:cb4d9db17537 359 {
mbed_official 376:cb4d9db17537 360 uint32_t tmpreg = 0;
mbed_official 376:cb4d9db17537 361
mbed_official 376:cb4d9db17537 362 /* Check the parameters */
mbed_official 376:cb4d9db17537 363 assert_param(IS_PWR_PVD_LEVEL(sConfigPVD->PVDLevel));
mbed_official 376:cb4d9db17537 364
mbed_official 376:cb4d9db17537 365 tmpreg = PWR->CR;
mbed_official 376:cb4d9db17537 366
mbed_official 376:cb4d9db17537 367 /* Clear PLS[7:5] bits */
mbed_official 376:cb4d9db17537 368 tmpreg &= ~ (uint32_t)PWR_CR_PLS;
mbed_official 376:cb4d9db17537 369
mbed_official 376:cb4d9db17537 370 /* Set PLS[7:5] bits according to PVDLevel value */
mbed_official 376:cb4d9db17537 371 tmpreg |= sConfigPVD->PVDLevel;
mbed_official 376:cb4d9db17537 372
mbed_official 376:cb4d9db17537 373 /* Store the new value */
mbed_official 376:cb4d9db17537 374 PWR->CR = tmpreg;
mbed_official 376:cb4d9db17537 375
mbed_official 376:cb4d9db17537 376 /* Configure the EXTI 16 interrupt */
mbed_official 376:cb4d9db17537 377 if((sConfigPVD->Mode == PWR_MODE_IT_RISING_FALLING) ||\
mbed_official 376:cb4d9db17537 378 (sConfigPVD->Mode == PWR_MODE_IT_FALLING) ||\
mbed_official 376:cb4d9db17537 379 (sConfigPVD->Mode == PWR_MODE_IT_RISING))
mbed_official 376:cb4d9db17537 380 {
mbed_official 376:cb4d9db17537 381 __HAL_PVD_EXTI_ENABLE_IT(PWR_EXTI_LINE_PVD);
mbed_official 376:cb4d9db17537 382 }
mbed_official 376:cb4d9db17537 383
mbed_official 376:cb4d9db17537 384 /* Clear the edge trigger for the EXTI Line 16 (PVD) */
mbed_official 376:cb4d9db17537 385 EXTI->RTSR &= ~EXTI_RTSR_TR16;
mbed_official 376:cb4d9db17537 386 EXTI->FTSR &= ~EXTI_FTSR_TR16;
mbed_official 376:cb4d9db17537 387
mbed_official 376:cb4d9db17537 388 /* Configure the rising edge */
mbed_official 376:cb4d9db17537 389 if((sConfigPVD->Mode == PWR_MODE_IT_RISING_FALLING) ||\
mbed_official 376:cb4d9db17537 390 (sConfigPVD->Mode == PWR_MODE_IT_RISING))
mbed_official 376:cb4d9db17537 391 {
mbed_official 376:cb4d9db17537 392 EXTI->RTSR |= PWR_EXTI_LINE_PVD;
mbed_official 376:cb4d9db17537 393 }
mbed_official 376:cb4d9db17537 394 /* Configure the falling edge */
mbed_official 376:cb4d9db17537 395 if((sConfigPVD->Mode == PWR_MODE_IT_RISING_FALLING) ||\
mbed_official 376:cb4d9db17537 396 (sConfigPVD->Mode == PWR_MODE_IT_FALLING))
mbed_official 376:cb4d9db17537 397 {
mbed_official 376:cb4d9db17537 398 EXTI->FTSR |= PWR_EXTI_LINE_PVD;
mbed_official 376:cb4d9db17537 399 }
mbed_official 376:cb4d9db17537 400 }
mbed_official 376:cb4d9db17537 401
mbed_official 376:cb4d9db17537 402 /**
mbed_official 376:cb4d9db17537 403 * @brief Enables the Power Voltage Detector(PVD).
mbed_official 376:cb4d9db17537 404 * @param None
mbed_official 376:cb4d9db17537 405 * @retval None
mbed_official 376:cb4d9db17537 406 */
mbed_official 376:cb4d9db17537 407 void HAL_PWR_EnablePVD(void)
mbed_official 376:cb4d9db17537 408 {
mbed_official 376:cb4d9db17537 409 /* Enable the power voltage detector */
mbed_official 376:cb4d9db17537 410 PWR->CR |= PWR_CR_PVDE;
mbed_official 376:cb4d9db17537 411 }
mbed_official 376:cb4d9db17537 412
mbed_official 376:cb4d9db17537 413 /**
mbed_official 376:cb4d9db17537 414 * @brief Disables the Power Voltage Detector(PVD).
mbed_official 376:cb4d9db17537 415 * @param None
mbed_official 376:cb4d9db17537 416 * @retval None
mbed_official 376:cb4d9db17537 417 */
mbed_official 376:cb4d9db17537 418 void HAL_PWR_DisablePVD(void)
mbed_official 376:cb4d9db17537 419 {
mbed_official 376:cb4d9db17537 420 /* Disable the power voltage detector */
mbed_official 376:cb4d9db17537 421 PWR->CR &= (uint32_t)~((uint32_t)PWR_CR_PVDE);
mbed_official 376:cb4d9db17537 422 }
mbed_official 376:cb4d9db17537 423
mbed_official 376:cb4d9db17537 424 /**
mbed_official 376:cb4d9db17537 425 * @brief Enables the WakeUp PINx functionality.
mbed_official 376:cb4d9db17537 426 * @param WakeUpPinx: Specifies the Power Wake-Up pin to enable.
mbed_official 376:cb4d9db17537 427 * This parameter can be one of the following values:
mbed_official 376:cb4d9db17537 428 * @arg PWR_WAKEUP_PIN1
mbed_official 376:cb4d9db17537 429 * @arg PWR_WAKEUP_PIN2
mbed_official 376:cb4d9db17537 430 * @retval None
mbed_official 376:cb4d9db17537 431 */
mbed_official 376:cb4d9db17537 432 void HAL_PWR_EnableWakeUpPin(uint32_t WakeUpPinx)
mbed_official 376:cb4d9db17537 433 {
mbed_official 376:cb4d9db17537 434 /* Check the parameter */
mbed_official 376:cb4d9db17537 435 assert_param(IS_PWR_WAKEUP_PIN(WakeUpPinx));
mbed_official 376:cb4d9db17537 436 /* Enable the EWUPx pin */
mbed_official 376:cb4d9db17537 437 PWR->CSR |= WakeUpPinx;
mbed_official 376:cb4d9db17537 438 }
mbed_official 376:cb4d9db17537 439
mbed_official 376:cb4d9db17537 440 /**
mbed_official 376:cb4d9db17537 441 * @brief Disables the WakeUp PINx functionality.
mbed_official 376:cb4d9db17537 442 * @param WakeUpPinx: Specifies the Power Wake-Up pin to disable.
mbed_official 376:cb4d9db17537 443 * This parameter can be one of the following values:
mbed_official 376:cb4d9db17537 444 * @arg PWR_WAKEUP_PIN1
mbed_official 376:cb4d9db17537 445 * @arg PWR_WAKEUP_PIN2
mbed_official 376:cb4d9db17537 446 * @retval None
mbed_official 376:cb4d9db17537 447 */
mbed_official 376:cb4d9db17537 448 void HAL_PWR_DisableWakeUpPin(uint32_t WakeUpPinx)
mbed_official 376:cb4d9db17537 449 {
mbed_official 376:cb4d9db17537 450 /* Check the parameter */
mbed_official 376:cb4d9db17537 451 assert_param(IS_PWR_WAKEUP_PIN(WakeUpPinx));
mbed_official 376:cb4d9db17537 452 /* Disable the EWUPx pin */
mbed_official 376:cb4d9db17537 453 PWR->CSR &= ~WakeUpPinx;
mbed_official 376:cb4d9db17537 454 }
mbed_official 376:cb4d9db17537 455
mbed_official 376:cb4d9db17537 456 /**
mbed_official 376:cb4d9db17537 457 * @brief Enters Sleep mode.
mbed_official 376:cb4d9db17537 458 * @note In Sleep mode, all I/O pins keep the same state as in Run mode.
mbed_official 376:cb4d9db17537 459 * @param Regulator: Specifies the regulator state in SLEEP mode.
mbed_official 376:cb4d9db17537 460 * This parameter can be one of the following values:
mbed_official 376:cb4d9db17537 461 * @arg PWR_MAINREGULATOR_ON: SLEEP mode with regulator ON
mbed_official 376:cb4d9db17537 462 * @arg PWR_LOWPOWERREGULATOR_ON: SLEEP mode with low power regulator ON
mbed_official 376:cb4d9db17537 463 * @param SLEEPEntry: Specifies if SLEEP mode is entered with WFI or WFE instruction.
mbed_official 376:cb4d9db17537 464 * When WFI entry is used, tick interrupt have to be disabled if not desired as
mbed_official 376:cb4d9db17537 465 * the interrupt wake up source.
mbed_official 376:cb4d9db17537 466 * This parameter can be one of the following values:
mbed_official 376:cb4d9db17537 467 * @arg PWR_SLEEPENTRY_WFI: enter SLEEP mode with WFI instruction
mbed_official 376:cb4d9db17537 468 * @arg PWR_SLEEPENTRY_WFE: enter SLEEP mode with WFE instruction
mbed_official 376:cb4d9db17537 469 * @retval None
mbed_official 376:cb4d9db17537 470 */
mbed_official 376:cb4d9db17537 471 void HAL_PWR_EnterSLEEPMode(uint32_t Regulator, uint8_t SLEEPEntry)
mbed_official 376:cb4d9db17537 472 {
mbed_official 376:cb4d9db17537 473 uint32_t tmpreg = 0;
mbed_official 376:cb4d9db17537 474 /* Check the parameters */
mbed_official 376:cb4d9db17537 475 assert_param(IS_PWR_REGULATOR(Regulator));
mbed_official 376:cb4d9db17537 476 assert_param(IS_PWR_SLEEP_ENTRY(SLEEPEntry));
mbed_official 376:cb4d9db17537 477
mbed_official 376:cb4d9db17537 478 /* Select the regulator state in Sleep mode ---------------------------------*/
mbed_official 376:cb4d9db17537 479 tmpreg = PWR->CR;
mbed_official 376:cb4d9db17537 480 /* Clear PDDS and LPDS bits */
mbed_official 376:cb4d9db17537 481 tmpreg &= (uint32_t)~(PWR_CR_PDDS | PWR_CR_LPSDSR);
mbed_official 376:cb4d9db17537 482
mbed_official 376:cb4d9db17537 483 /* Set LPSDSR bit according to PWR_Regulator value */
mbed_official 376:cb4d9db17537 484 tmpreg |= Regulator;
mbed_official 376:cb4d9db17537 485
mbed_official 376:cb4d9db17537 486 /* Store the new value */
mbed_official 376:cb4d9db17537 487 PWR->CR = tmpreg;
mbed_official 376:cb4d9db17537 488
mbed_official 376:cb4d9db17537 489 /* Clear SLEEPDEEP bit of Cortex System Control Register */
mbed_official 376:cb4d9db17537 490 SCB->SCR &= (uint32_t)~((uint32_t)SCB_SCR_SLEEPDEEP_Msk);
mbed_official 376:cb4d9db17537 491
mbed_official 376:cb4d9db17537 492 /* Select SLEEP mode entry -------------------------------------------------*/
mbed_official 376:cb4d9db17537 493 if(SLEEPEntry == PWR_SLEEPENTRY_WFI)
mbed_official 376:cb4d9db17537 494 {
mbed_official 376:cb4d9db17537 495 /* Request Wait For Interrupt */
mbed_official 376:cb4d9db17537 496 __WFI();
mbed_official 376:cb4d9db17537 497 }
mbed_official 376:cb4d9db17537 498 else
mbed_official 376:cb4d9db17537 499 {
mbed_official 376:cb4d9db17537 500 /* Request Wait For Event */
mbed_official 376:cb4d9db17537 501 __SEV();
mbed_official 376:cb4d9db17537 502 __WFE();
mbed_official 376:cb4d9db17537 503 __WFE();
mbed_official 376:cb4d9db17537 504 }
mbed_official 376:cb4d9db17537 505 }
mbed_official 376:cb4d9db17537 506
mbed_official 376:cb4d9db17537 507 /**
mbed_official 376:cb4d9db17537 508 * @brief Enters Stop mode.
mbed_official 376:cb4d9db17537 509 * @note In Stop mode, all I/O pins keep the same state as in Run mode.
mbed_official 376:cb4d9db17537 510 * @note When exiting Stop mode by issuing an interrupt or a wakeup event,
mbed_official 376:cb4d9db17537 511 * MSI or HSI16 RCoscillator is selected as system clock depending
mbed_official 376:cb4d9db17537 512 * the bit STOPWUCK in the RCC_CFGR register.
mbed_official 376:cb4d9db17537 513 * @note When the voltage regulator operates in low power mode, an additional
mbed_official 376:cb4d9db17537 514 * startup delay is incurred when waking up from Stop mode.
mbed_official 376:cb4d9db17537 515 * By keeping the internal regulator ON during Stop mode, the consumption
mbed_official 376:cb4d9db17537 516 * is higher although the startup time is reduced.
mbed_official 376:cb4d9db17537 517 * @param Regulator: Specifies the regulator state in Stop mode.
mbed_official 376:cb4d9db17537 518 * This parameter can be one of the following values:
mbed_official 376:cb4d9db17537 519 * @arg PWR_MAINREGULATOR_ON: Stop mode with regulator ON
mbed_official 376:cb4d9db17537 520 * @arg PWR_LOWPOWERREGULATOR_ON: Stop mode with low power regulator ON
mbed_official 376:cb4d9db17537 521 * @param STOPEntry: Specifies if Stop mode in entered with WFI or WFE instruction.
mbed_official 376:cb4d9db17537 522 * This parameter can be one of the following values:
mbed_official 376:cb4d9db17537 523 * @arg PWR_STOPENTRY_WFI: Enter Stop mode with WFI instruction
mbed_official 376:cb4d9db17537 524 * @arg PWR_STOPENTRY_WFE: Enter Stop mode with WFE instruction
mbed_official 376:cb4d9db17537 525 * @retval None
mbed_official 376:cb4d9db17537 526 */
mbed_official 376:cb4d9db17537 527 void HAL_PWR_EnterSTOPMode(uint32_t Regulator, uint8_t STOPEntry)
mbed_official 376:cb4d9db17537 528 {
mbed_official 376:cb4d9db17537 529 uint32_t tmpreg = 0;
mbed_official 376:cb4d9db17537 530
mbed_official 376:cb4d9db17537 531 /* Check the parameters */
mbed_official 376:cb4d9db17537 532 assert_param(IS_PWR_REGULATOR(Regulator));
mbed_official 376:cb4d9db17537 533 assert_param(IS_PWR_STOP_ENTRY(STOPEntry));
mbed_official 376:cb4d9db17537 534
mbed_official 376:cb4d9db17537 535 /* Select the regulator state in Stop mode ---------------------------------*/
mbed_official 376:cb4d9db17537 536 tmpreg = PWR->CR;
mbed_official 376:cb4d9db17537 537 /* Clear PDDS and LPDS bits */
mbed_official 376:cb4d9db17537 538 tmpreg &= (uint32_t)~(PWR_CR_PDDS | PWR_CR_LPSDSR);
mbed_official 376:cb4d9db17537 539
mbed_official 376:cb4d9db17537 540 /* Set LPSDSR bit according to PWR_Regulator value */
mbed_official 376:cb4d9db17537 541 tmpreg |= Regulator;
mbed_official 376:cb4d9db17537 542
mbed_official 376:cb4d9db17537 543 /* Store the new value */
mbed_official 376:cb4d9db17537 544 PWR->CR = tmpreg;
mbed_official 376:cb4d9db17537 545
mbed_official 376:cb4d9db17537 546 /* Set SLEEPDEEP bit of Cortex System Control Register */
mbed_official 376:cb4d9db17537 547 SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk;
mbed_official 376:cb4d9db17537 548
mbed_official 376:cb4d9db17537 549 /* Select Stop mode entry --------------------------------------------------*/
mbed_official 376:cb4d9db17537 550 if(STOPEntry == PWR_STOPENTRY_WFI)
mbed_official 376:cb4d9db17537 551 {
mbed_official 376:cb4d9db17537 552 /* Request Wait For Interrupt */
mbed_official 376:cb4d9db17537 553 __WFI();
mbed_official 376:cb4d9db17537 554 }
mbed_official 376:cb4d9db17537 555 else
mbed_official 376:cb4d9db17537 556 {
mbed_official 376:cb4d9db17537 557 /* Request Wait For Event */
mbed_official 376:cb4d9db17537 558 __SEV();
mbed_official 376:cb4d9db17537 559 __WFE();
mbed_official 376:cb4d9db17537 560 __WFE();
mbed_official 376:cb4d9db17537 561 }
mbed_official 376:cb4d9db17537 562
mbed_official 376:cb4d9db17537 563 /* Reset SLEEPDEEP bit of Cortex System Control Register */
mbed_official 376:cb4d9db17537 564 SCB->SCR &= (uint32_t)~((uint32_t)SCB_SCR_SLEEPDEEP_Msk);
mbed_official 376:cb4d9db17537 565 }
mbed_official 376:cb4d9db17537 566
mbed_official 376:cb4d9db17537 567 /**
mbed_official 376:cb4d9db17537 568 * @brief Enters Standby mode.
mbed_official 376:cb4d9db17537 569 * @note In Standby mode, all I/O pins are high impedance except for:
mbed_official 376:cb4d9db17537 570 * - Reset pad (still available)
mbed_official 376:cb4d9db17537 571 * - RTC_AF1 pin (PC13) if configured for tamper, time-stamp, RTC
mbed_official 376:cb4d9db17537 572 * Alarm out, or RTC clock calibration out.
mbed_official 376:cb4d9db17537 573 * - RTC_AF2 pin (PC13) if configured for tamper.
mbed_official 376:cb4d9db17537 574 * - WKUP pin 1 (PA0) if enabled.
mbed_official 376:cb4d9db17537 575 * - WKUP pin 2 (PC13) if enabled.
mbed_official 376:cb4d9db17537 576 * @param None
mbed_official 376:cb4d9db17537 577 * @retval None
mbed_official 376:cb4d9db17537 578 */
mbed_official 376:cb4d9db17537 579 void HAL_PWR_EnterSTANDBYMode(void)
mbed_official 376:cb4d9db17537 580 {
mbed_official 376:cb4d9db17537 581 /* Select Standby mode */
mbed_official 376:cb4d9db17537 582 PWR->CR |= PWR_CR_PDDS;
mbed_official 376:cb4d9db17537 583
mbed_official 376:cb4d9db17537 584 /* Set SLEEPDEEP bit of Cortex System Control Register */
mbed_official 376:cb4d9db17537 585 SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk;
mbed_official 376:cb4d9db17537 586
mbed_official 376:cb4d9db17537 587 /* This option is used to ensure that store operations are completed */
mbed_official 376:cb4d9db17537 588 #if defined ( __CC_ARM)
mbed_official 376:cb4d9db17537 589 __force_stores();
mbed_official 376:cb4d9db17537 590 #endif
mbed_official 376:cb4d9db17537 591 /* Request Wait For Interrupt */
mbed_official 376:cb4d9db17537 592 __WFI();
mbed_official 376:cb4d9db17537 593 }
mbed_official 376:cb4d9db17537 594
mbed_official 376:cb4d9db17537 595 /**
mbed_official 376:cb4d9db17537 596 * @brief This function handles the PWR PVD interrupt request.
mbed_official 376:cb4d9db17537 597 * @note This API should be called under the PVD_IRQHandler().
mbed_official 376:cb4d9db17537 598 * @param None
mbed_official 376:cb4d9db17537 599 * @retval None
mbed_official 376:cb4d9db17537 600 */
mbed_official 376:cb4d9db17537 601 void HAL_PWR_PVD_IRQHandler(void)
mbed_official 376:cb4d9db17537 602 {
mbed_official 376:cb4d9db17537 603 /* Check PWR exti flag */
mbed_official 376:cb4d9db17537 604 if(__HAL_PVD_EXTI_GET_FLAG(PWR_EXTI_LINE_PVD) != RESET)
mbed_official 376:cb4d9db17537 605 {
mbed_official 376:cb4d9db17537 606 /* PWR PVD interrupt user callback */
mbed_official 376:cb4d9db17537 607 HAL_PWR_PVDCallback();
mbed_official 376:cb4d9db17537 608
mbed_official 376:cb4d9db17537 609 /* Clear PWR Exti pending bit */
mbed_official 376:cb4d9db17537 610 __HAL_PVD_EXTI_CLEAR_FLAG(PWR_EXTI_LINE_PVD);
mbed_official 376:cb4d9db17537 611 }
mbed_official 376:cb4d9db17537 612 }
mbed_official 376:cb4d9db17537 613
mbed_official 376:cb4d9db17537 614 /**
mbed_official 376:cb4d9db17537 615 * @brief PWR PVD interrupt callback
mbed_official 376:cb4d9db17537 616 * @param None
mbed_official 376:cb4d9db17537 617 * @retval None
mbed_official 376:cb4d9db17537 618 */
mbed_official 376:cb4d9db17537 619 __weak void HAL_PWR_PVDCallback(void)
mbed_official 376:cb4d9db17537 620 {
mbed_official 376:cb4d9db17537 621 /* NOTE : This function Should not be modified, when the callback is needed,
mbed_official 376:cb4d9db17537 622 the HAL_PWR_PVDCallback could be implemented in the user file
mbed_official 376:cb4d9db17537 623 */
mbed_official 376:cb4d9db17537 624 }
mbed_official 376:cb4d9db17537 625
mbed_official 376:cb4d9db17537 626 /**
mbed_official 376:cb4d9db17537 627 * @}
mbed_official 376:cb4d9db17537 628 */
mbed_official 376:cb4d9db17537 629
mbed_official 376:cb4d9db17537 630 /**
mbed_official 376:cb4d9db17537 631 * @}
mbed_official 376:cb4d9db17537 632 */
mbed_official 376:cb4d9db17537 633
mbed_official 376:cb4d9db17537 634 #endif /* HAL_PWR_MODULE_ENABLED */
mbed_official 376:cb4d9db17537 635 /**
mbed_official 376:cb4d9db17537 636 * @}
mbed_official 376:cb4d9db17537 637 */
mbed_official 376:cb4d9db17537 638
mbed_official 376:cb4d9db17537 639 /**
mbed_official 376:cb4d9db17537 640 * @}
mbed_official 376:cb4d9db17537 641 */
mbed_official 376:cb4d9db17537 642
mbed_official 376:cb4d9db17537 643 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/