mbed library with additional peripherals for ST F401 board
Fork of mbed-src by
This mbed LIB has additional peripherals for ST F401 board
- UART2 : PA_3 rx, PA_2 tx
- UART3 : PC_7 rx, PC_6 tx
- I2C2 : PB_3 SDA, PB_10 SCL
- I2C3 : PB_4 SDA, PA_8 SCL
targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_pwr.c@106:ced8cbb51063, 2014-02-26 (annotated)
- Committer:
- mbed_official
- Date:
- Wed Feb 26 09:45:12 2014 +0000
- Revision:
- 106:ced8cbb51063
- Parent:
- 80:66393a7b209d
Synchronized with git revision 4222735eff5868389433f0e9271976b39c8115cd
Full URL: https://github.com/mbedmicro/mbed/commit/4222735eff5868389433f0e9271976b39c8115cd/
[NUCLEO_xxx] Update STM32CubeF4 driver V1.0.0 + update license
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbed_official | 76:aeb1df146756 | 1 | /** |
mbed_official | 76:aeb1df146756 | 2 | ****************************************************************************** |
mbed_official | 76:aeb1df146756 | 3 | * @file stm32l1xx_pwr.c |
mbed_official | 76:aeb1df146756 | 4 | * @author MCD Application Team |
mbed_official | 80:66393a7b209d | 5 | * @version V1.3.0 |
mbed_official | 80:66393a7b209d | 6 | * @date 31-January-2014 |
mbed_official | 76:aeb1df146756 | 7 | * @brief This file provides firmware functions to manage the following |
mbed_official | 76:aeb1df146756 | 8 | * functionalities of the Power Controller (PWR) peripheral: |
mbed_official | 76:aeb1df146756 | 9 | * + RTC Domain Access |
mbed_official | 76:aeb1df146756 | 10 | * + PVD configuration |
mbed_official | 76:aeb1df146756 | 11 | * + WakeUp pins configuration |
mbed_official | 76:aeb1df146756 | 12 | * + Ultra Low Power mode configuration |
mbed_official | 76:aeb1df146756 | 13 | * + Voltage Scaling configuration |
mbed_official | 76:aeb1df146756 | 14 | * + Low Power modes configuration |
mbed_official | 76:aeb1df146756 | 15 | * + Flags management |
mbed_official | 76:aeb1df146756 | 16 | * |
mbed_official | 76:aeb1df146756 | 17 | ****************************************************************************** |
mbed_official | 76:aeb1df146756 | 18 | * @attention |
mbed_official | 76:aeb1df146756 | 19 | * |
mbed_official | 106:ced8cbb51063 | 20 | * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> |
mbed_official | 76:aeb1df146756 | 21 | * |
mbed_official | 106:ced8cbb51063 | 22 | * Redistribution and use in source and binary forms, with or without modification, |
mbed_official | 106:ced8cbb51063 | 23 | * are permitted provided that the following conditions are met: |
mbed_official | 106:ced8cbb51063 | 24 | * 1. Redistributions of source code must retain the above copyright notice, |
mbed_official | 106:ced8cbb51063 | 25 | * this list of conditions and the following disclaimer. |
mbed_official | 106:ced8cbb51063 | 26 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
mbed_official | 106:ced8cbb51063 | 27 | * this list of conditions and the following disclaimer in the documentation |
mbed_official | 106:ced8cbb51063 | 28 | * and/or other materials provided with the distribution. |
mbed_official | 106:ced8cbb51063 | 29 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
mbed_official | 106:ced8cbb51063 | 30 | * may be used to endorse or promote products derived from this software |
mbed_official | 106:ced8cbb51063 | 31 | * without specific prior written permission. |
mbed_official | 76:aeb1df146756 | 32 | * |
mbed_official | 106:ced8cbb51063 | 33 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
mbed_official | 106:ced8cbb51063 | 34 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
mbed_official | 106:ced8cbb51063 | 35 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
mbed_official | 106:ced8cbb51063 | 36 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
mbed_official | 106:ced8cbb51063 | 37 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
mbed_official | 106:ced8cbb51063 | 38 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
mbed_official | 106:ced8cbb51063 | 39 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
mbed_official | 106:ced8cbb51063 | 40 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
mbed_official | 106:ced8cbb51063 | 41 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
mbed_official | 106:ced8cbb51063 | 42 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
mbed_official | 76:aeb1df146756 | 43 | * |
mbed_official | 76:aeb1df146756 | 44 | ****************************************************************************** |
mbed_official | 76:aeb1df146756 | 45 | */ |
mbed_official | 76:aeb1df146756 | 46 | |
mbed_official | 76:aeb1df146756 | 47 | /* Includes ------------------------------------------------------------------*/ |
mbed_official | 76:aeb1df146756 | 48 | #include "stm32l1xx_pwr.h" |
mbed_official | 76:aeb1df146756 | 49 | #include "stm32l1xx_rcc.h" |
mbed_official | 76:aeb1df146756 | 50 | |
mbed_official | 76:aeb1df146756 | 51 | /** @addtogroup STM32L1xx_StdPeriph_Driver |
mbed_official | 76:aeb1df146756 | 52 | * @{ |
mbed_official | 76:aeb1df146756 | 53 | */ |
mbed_official | 76:aeb1df146756 | 54 | |
mbed_official | 76:aeb1df146756 | 55 | /** @defgroup PWR |
mbed_official | 76:aeb1df146756 | 56 | * @brief PWR driver modules |
mbed_official | 76:aeb1df146756 | 57 | * @{ |
mbed_official | 76:aeb1df146756 | 58 | */ |
mbed_official | 76:aeb1df146756 | 59 | |
mbed_official | 76:aeb1df146756 | 60 | /* Private typedef -----------------------------------------------------------*/ |
mbed_official | 76:aeb1df146756 | 61 | /* Private define ------------------------------------------------------------*/ |
mbed_official | 76:aeb1df146756 | 62 | /* --------- PWR registers bit address in the alias region ---------- */ |
mbed_official | 76:aeb1df146756 | 63 | #define PWR_OFFSET (PWR_BASE - PERIPH_BASE) |
mbed_official | 76:aeb1df146756 | 64 | |
mbed_official | 76:aeb1df146756 | 65 | /* --- CR Register ---*/ |
mbed_official | 76:aeb1df146756 | 66 | |
mbed_official | 76:aeb1df146756 | 67 | /* Alias word address of DBP bit */ |
mbed_official | 76:aeb1df146756 | 68 | #define CR_OFFSET (PWR_OFFSET + 0x00) |
mbed_official | 76:aeb1df146756 | 69 | #define DBP_BitNumber 0x08 |
mbed_official | 76:aeb1df146756 | 70 | #define CR_DBP_BB (PERIPH_BB_BASE + (CR_OFFSET * 32) + (DBP_BitNumber * 4)) |
mbed_official | 76:aeb1df146756 | 71 | |
mbed_official | 76:aeb1df146756 | 72 | /* Alias word address of PVDE bit */ |
mbed_official | 76:aeb1df146756 | 73 | #define PVDE_BitNumber 0x04 |
mbed_official | 76:aeb1df146756 | 74 | #define CR_PVDE_BB (PERIPH_BB_BASE + (CR_OFFSET * 32) + (PVDE_BitNumber * 4)) |
mbed_official | 76:aeb1df146756 | 75 | |
mbed_official | 76:aeb1df146756 | 76 | /* Alias word address of ULP bit */ |
mbed_official | 76:aeb1df146756 | 77 | #define ULP_BitNumber 0x09 |
mbed_official | 76:aeb1df146756 | 78 | #define CR_ULP_BB (PERIPH_BB_BASE + (CR_OFFSET * 32) + (ULP_BitNumber * 4)) |
mbed_official | 76:aeb1df146756 | 79 | |
mbed_official | 76:aeb1df146756 | 80 | /* Alias word address of FWU bit */ |
mbed_official | 76:aeb1df146756 | 81 | #define FWU_BitNumber 0x0A |
mbed_official | 76:aeb1df146756 | 82 | #define CR_FWU_BB (PERIPH_BB_BASE + (CR_OFFSET * 32) + (FWU_BitNumber * 4)) |
mbed_official | 76:aeb1df146756 | 83 | |
mbed_official | 76:aeb1df146756 | 84 | /* --- CSR Register ---*/ |
mbed_official | 76:aeb1df146756 | 85 | |
mbed_official | 76:aeb1df146756 | 86 | /* Alias word address of EWUP bit */ |
mbed_official | 76:aeb1df146756 | 87 | #define CSR_OFFSET (PWR_OFFSET + 0x04) |
mbed_official | 76:aeb1df146756 | 88 | #define EWUP_BitNumber 0x08 |
mbed_official | 76:aeb1df146756 | 89 | #define CSR_EWUP_BB (PERIPH_BB_BASE + (CSR_OFFSET * 32) + (EWUP_BitNumber * 4)) |
mbed_official | 76:aeb1df146756 | 90 | |
mbed_official | 76:aeb1df146756 | 91 | /* ------------------ PWR registers bit mask ------------------------ */ |
mbed_official | 76:aeb1df146756 | 92 | |
mbed_official | 76:aeb1df146756 | 93 | /* CR register bit mask */ |
mbed_official | 76:aeb1df146756 | 94 | #define CR_DS_MASK ((uint32_t)0xFFFFFFFC) |
mbed_official | 76:aeb1df146756 | 95 | #define CR_PLS_MASK ((uint32_t)0xFFFFFF1F) |
mbed_official | 76:aeb1df146756 | 96 | #define CR_VOS_MASK ((uint32_t)0xFFFFE7FF) |
mbed_official | 76:aeb1df146756 | 97 | |
mbed_official | 76:aeb1df146756 | 98 | /* Private macro -------------------------------------------------------------*/ |
mbed_official | 76:aeb1df146756 | 99 | /* Private variables ---------------------------------------------------------*/ |
mbed_official | 76:aeb1df146756 | 100 | /* Private function prototypes -----------------------------------------------*/ |
mbed_official | 76:aeb1df146756 | 101 | /* Private functions ---------------------------------------------------------*/ |
mbed_official | 76:aeb1df146756 | 102 | |
mbed_official | 76:aeb1df146756 | 103 | /** @defgroup PWR_Private_Functions |
mbed_official | 76:aeb1df146756 | 104 | * @{ |
mbed_official | 76:aeb1df146756 | 105 | */ |
mbed_official | 76:aeb1df146756 | 106 | |
mbed_official | 76:aeb1df146756 | 107 | /** @defgroup PWR_Group1 RTC Domain Access function |
mbed_official | 76:aeb1df146756 | 108 | * @brief RTC Domain Access function |
mbed_official | 76:aeb1df146756 | 109 | * |
mbed_official | 76:aeb1df146756 | 110 | @verbatim |
mbed_official | 76:aeb1df146756 | 111 | ============================================================================== |
mbed_official | 76:aeb1df146756 | 112 | ##### RTC Domain Access function ##### |
mbed_official | 76:aeb1df146756 | 113 | ============================================================================== |
mbed_official | 76:aeb1df146756 | 114 | |
mbed_official | 76:aeb1df146756 | 115 | [..] After reset, the RTC Registers (RCC CSR Register, RTC registers and RTC backup |
mbed_official | 76:aeb1df146756 | 116 | registers) are protected against possible stray write accesses. |
mbed_official | 76:aeb1df146756 | 117 | [..] To enable access to RTC domain use the PWR_RTCAccessCmd(ENABLE) function. |
mbed_official | 76:aeb1df146756 | 118 | |
mbed_official | 76:aeb1df146756 | 119 | @endverbatim |
mbed_official | 76:aeb1df146756 | 120 | * @{ |
mbed_official | 76:aeb1df146756 | 121 | */ |
mbed_official | 76:aeb1df146756 | 122 | |
mbed_official | 76:aeb1df146756 | 123 | /** |
mbed_official | 76:aeb1df146756 | 124 | * @brief Deinitializes the PWR peripheral registers to their default reset values. |
mbed_official | 76:aeb1df146756 | 125 | * @note Before calling this function, the VOS[1:0] bits should be configured |
mbed_official | 76:aeb1df146756 | 126 | * to "10" and the system frequency has to be configured accordingly. |
mbed_official | 76:aeb1df146756 | 127 | * To configure the VOS[1:0] bits, use the PWR_VoltageScalingConfig() |
mbed_official | 76:aeb1df146756 | 128 | * function. |
mbed_official | 76:aeb1df146756 | 129 | * @note ULP and FWU bits are not reset by this function. |
mbed_official | 76:aeb1df146756 | 130 | * @param None |
mbed_official | 76:aeb1df146756 | 131 | * @retval None |
mbed_official | 76:aeb1df146756 | 132 | */ |
mbed_official | 76:aeb1df146756 | 133 | void PWR_DeInit(void) |
mbed_official | 76:aeb1df146756 | 134 | { |
mbed_official | 76:aeb1df146756 | 135 | RCC_APB1PeriphResetCmd(RCC_APB1Periph_PWR, ENABLE); |
mbed_official | 76:aeb1df146756 | 136 | RCC_APB1PeriphResetCmd(RCC_APB1Periph_PWR, DISABLE); |
mbed_official | 76:aeb1df146756 | 137 | } |
mbed_official | 76:aeb1df146756 | 138 | |
mbed_official | 76:aeb1df146756 | 139 | /** |
mbed_official | 76:aeb1df146756 | 140 | * @brief Enables or disables access to the RTC and backup registers. |
mbed_official | 76:aeb1df146756 | 141 | * @note If the HSE divided by 2, 4, 8 or 16 is used as the RTC clock, the |
mbed_official | 76:aeb1df146756 | 142 | * RTC Domain Access should be kept enabled. |
mbed_official | 76:aeb1df146756 | 143 | * @param NewState: new state of the access to the RTC and backup registers. |
mbed_official | 76:aeb1df146756 | 144 | * This parameter can be: ENABLE or DISABLE. |
mbed_official | 76:aeb1df146756 | 145 | * @retval None |
mbed_official | 76:aeb1df146756 | 146 | */ |
mbed_official | 76:aeb1df146756 | 147 | void PWR_RTCAccessCmd(FunctionalState NewState) |
mbed_official | 76:aeb1df146756 | 148 | { |
mbed_official | 76:aeb1df146756 | 149 | /* Check the parameters */ |
mbed_official | 76:aeb1df146756 | 150 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 76:aeb1df146756 | 151 | |
mbed_official | 76:aeb1df146756 | 152 | *(__IO uint32_t *) CR_DBP_BB = (uint32_t)NewState; |
mbed_official | 76:aeb1df146756 | 153 | } |
mbed_official | 76:aeb1df146756 | 154 | |
mbed_official | 76:aeb1df146756 | 155 | /** |
mbed_official | 76:aeb1df146756 | 156 | * @} |
mbed_official | 76:aeb1df146756 | 157 | */ |
mbed_official | 76:aeb1df146756 | 158 | |
mbed_official | 76:aeb1df146756 | 159 | /** @defgroup PWR_Group2 PVD configuration functions |
mbed_official | 76:aeb1df146756 | 160 | * @brief PVD configuration functions |
mbed_official | 76:aeb1df146756 | 161 | * |
mbed_official | 76:aeb1df146756 | 162 | @verbatim |
mbed_official | 76:aeb1df146756 | 163 | ============================================================================== |
mbed_official | 76:aeb1df146756 | 164 | ##### PVD configuration functions ##### |
mbed_official | 76:aeb1df146756 | 165 | ============================================================================== |
mbed_official | 76:aeb1df146756 | 166 | [..] |
mbed_official | 76:aeb1df146756 | 167 | (+) The PVD is used to monitor the VDD power supply by comparing it to a threshold |
mbed_official | 76:aeb1df146756 | 168 | selected by the PVD Level (PLS[2:0] bits in the PWR_CR). |
mbed_official | 76:aeb1df146756 | 169 | (+) The PVD can use an external input analog voltage (PVD_IN) which is compared |
mbed_official | 76:aeb1df146756 | 170 | internally to VREFINT. The PVD_IN (PB7) has to be configured in Analog mode |
mbed_official | 76:aeb1df146756 | 171 | when PWR_PVDLevel_7 is selected (PLS[2:0] = 111). |
mbed_official | 76:aeb1df146756 | 172 | (+) A PVDO flag is available to indicate if VDD/VDDA is higher or lower than the |
mbed_official | 76:aeb1df146756 | 173 | PVD threshold. This event is internally connected to the EXTI line16 |
mbed_official | 76:aeb1df146756 | 174 | and can generate an interrupt if enabled through the EXTI registers. |
mbed_official | 76:aeb1df146756 | 175 | (+) The PVD is stopped in Standby mode. |
mbed_official | 76:aeb1df146756 | 176 | |
mbed_official | 76:aeb1df146756 | 177 | @endverbatim |
mbed_official | 76:aeb1df146756 | 178 | * @{ |
mbed_official | 76:aeb1df146756 | 179 | */ |
mbed_official | 76:aeb1df146756 | 180 | |
mbed_official | 76:aeb1df146756 | 181 | /** |
mbed_official | 76:aeb1df146756 | 182 | * @brief Configures the voltage threshold detected by the Power Voltage Detector(PVD). |
mbed_official | 76:aeb1df146756 | 183 | * @param PWR_PVDLevel: specifies the PVD detection level. |
mbed_official | 76:aeb1df146756 | 184 | * This parameter can be one of the following values: |
mbed_official | 76:aeb1df146756 | 185 | * @arg PWR_PVDLevel_0: PVD detection level set to 1.9V. |
mbed_official | 76:aeb1df146756 | 186 | * @arg PWR_PVDLevel_1: PVD detection level set to 2.1V. |
mbed_official | 76:aeb1df146756 | 187 | * @arg PWR_PVDLevel_2: PVD detection level set to 2.3V. |
mbed_official | 76:aeb1df146756 | 188 | * @arg PWR_PVDLevel_3: PVD detection level set to 2.5V. |
mbed_official | 76:aeb1df146756 | 189 | * @arg PWR_PVDLevel_4: PVD detection level set to 2.7V. |
mbed_official | 76:aeb1df146756 | 190 | * @arg PWR_PVDLevel_5: PVD detection level set to 2.9V. |
mbed_official | 76:aeb1df146756 | 191 | * @arg PWR_PVDLevel_6: PVD detection level set to 3.1V. |
mbed_official | 76:aeb1df146756 | 192 | * @arg PWR_PVDLevel_7: External input analog voltage (Compare internally to VREFINT). |
mbed_official | 76:aeb1df146756 | 193 | * @retval None |
mbed_official | 76:aeb1df146756 | 194 | */ |
mbed_official | 76:aeb1df146756 | 195 | void PWR_PVDLevelConfig(uint32_t PWR_PVDLevel) |
mbed_official | 76:aeb1df146756 | 196 | { |
mbed_official | 76:aeb1df146756 | 197 | uint32_t tmpreg = 0; |
mbed_official | 76:aeb1df146756 | 198 | |
mbed_official | 76:aeb1df146756 | 199 | /* Check the parameters */ |
mbed_official | 76:aeb1df146756 | 200 | assert_param(IS_PWR_PVD_LEVEL(PWR_PVDLevel)); |
mbed_official | 76:aeb1df146756 | 201 | |
mbed_official | 76:aeb1df146756 | 202 | tmpreg = PWR->CR; |
mbed_official | 76:aeb1df146756 | 203 | |
mbed_official | 76:aeb1df146756 | 204 | /* Clear PLS[7:5] bits */ |
mbed_official | 76:aeb1df146756 | 205 | tmpreg &= CR_PLS_MASK; |
mbed_official | 76:aeb1df146756 | 206 | |
mbed_official | 76:aeb1df146756 | 207 | /* Set PLS[7:5] bits according to PWR_PVDLevel value */ |
mbed_official | 76:aeb1df146756 | 208 | tmpreg |= PWR_PVDLevel; |
mbed_official | 76:aeb1df146756 | 209 | |
mbed_official | 76:aeb1df146756 | 210 | /* Store the new value */ |
mbed_official | 76:aeb1df146756 | 211 | PWR->CR = tmpreg; |
mbed_official | 76:aeb1df146756 | 212 | } |
mbed_official | 76:aeb1df146756 | 213 | |
mbed_official | 76:aeb1df146756 | 214 | /** |
mbed_official | 76:aeb1df146756 | 215 | * @brief Enables or disables the Power Voltage Detector(PVD). |
mbed_official | 76:aeb1df146756 | 216 | * @param NewState: new state of the PVD. |
mbed_official | 76:aeb1df146756 | 217 | * This parameter can be: ENABLE or DISABLE. |
mbed_official | 76:aeb1df146756 | 218 | * @retval None |
mbed_official | 76:aeb1df146756 | 219 | */ |
mbed_official | 76:aeb1df146756 | 220 | void PWR_PVDCmd(FunctionalState NewState) |
mbed_official | 76:aeb1df146756 | 221 | { |
mbed_official | 76:aeb1df146756 | 222 | /* Check the parameters */ |
mbed_official | 76:aeb1df146756 | 223 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 76:aeb1df146756 | 224 | |
mbed_official | 76:aeb1df146756 | 225 | *(__IO uint32_t *) CR_PVDE_BB = (uint32_t)NewState; |
mbed_official | 76:aeb1df146756 | 226 | } |
mbed_official | 76:aeb1df146756 | 227 | |
mbed_official | 76:aeb1df146756 | 228 | /** |
mbed_official | 76:aeb1df146756 | 229 | * @} |
mbed_official | 76:aeb1df146756 | 230 | */ |
mbed_official | 76:aeb1df146756 | 231 | |
mbed_official | 76:aeb1df146756 | 232 | /** @defgroup PWR_Group3 WakeUp pins configuration functions |
mbed_official | 76:aeb1df146756 | 233 | * @brief WakeUp pins configuration functions |
mbed_official | 76:aeb1df146756 | 234 | * |
mbed_official | 76:aeb1df146756 | 235 | @verbatim |
mbed_official | 76:aeb1df146756 | 236 | ============================================================================== |
mbed_official | 76:aeb1df146756 | 237 | ##### WakeUp pin configuration functions ##### |
mbed_official | 76:aeb1df146756 | 238 | ============================================================================== |
mbed_official | 76:aeb1df146756 | 239 | |
mbed_official | 76:aeb1df146756 | 240 | (+) WakeUp pins are used to wakeup the system from Standby mode. These pins are |
mbed_official | 76:aeb1df146756 | 241 | forced in input pull down configuration and are active on rising edges. |
mbed_official | 76:aeb1df146756 | 242 | (+) There are three WakeUp pins: WakeUp Pin 1 on PA.00, WakeUp Pin 2 on PC.13 and |
mbed_official | 76:aeb1df146756 | 243 | WakeUp Pin 3 on PE.06. |
mbed_official | 76:aeb1df146756 | 244 | |
mbed_official | 76:aeb1df146756 | 245 | @endverbatim |
mbed_official | 76:aeb1df146756 | 246 | * @{ |
mbed_official | 76:aeb1df146756 | 247 | */ |
mbed_official | 76:aeb1df146756 | 248 | |
mbed_official | 76:aeb1df146756 | 249 | /** |
mbed_official | 76:aeb1df146756 | 250 | * @brief Enables or disables the WakeUp Pin functionality. |
mbed_official | 76:aeb1df146756 | 251 | * @param PWR_WakeUpPin: specifies the WakeUpPin. |
mbed_official | 76:aeb1df146756 | 252 | * This parameter can be: PWR_WakeUpPin_1, PWR_WakeUpPin_2 or PWR_WakeUpPin_3. |
mbed_official | 76:aeb1df146756 | 253 | * @param NewState: new state of the WakeUp Pin functionality. |
mbed_official | 76:aeb1df146756 | 254 | * This parameter can be: ENABLE or DISABLE. |
mbed_official | 76:aeb1df146756 | 255 | * @retval None |
mbed_official | 76:aeb1df146756 | 256 | */ |
mbed_official | 76:aeb1df146756 | 257 | void PWR_WakeUpPinCmd(uint32_t PWR_WakeUpPin, FunctionalState NewState) |
mbed_official | 76:aeb1df146756 | 258 | { |
mbed_official | 76:aeb1df146756 | 259 | __IO uint32_t tmp = 0; |
mbed_official | 76:aeb1df146756 | 260 | |
mbed_official | 76:aeb1df146756 | 261 | /* Check the parameters */ |
mbed_official | 76:aeb1df146756 | 262 | assert_param(IS_PWR_WAKEUP_PIN(PWR_WakeUpPin)); |
mbed_official | 76:aeb1df146756 | 263 | |
mbed_official | 76:aeb1df146756 | 264 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 76:aeb1df146756 | 265 | |
mbed_official | 76:aeb1df146756 | 266 | tmp = CSR_EWUP_BB + PWR_WakeUpPin; |
mbed_official | 76:aeb1df146756 | 267 | |
mbed_official | 76:aeb1df146756 | 268 | *(__IO uint32_t *) (tmp) = (uint32_t)NewState; |
mbed_official | 76:aeb1df146756 | 269 | } |
mbed_official | 76:aeb1df146756 | 270 | |
mbed_official | 76:aeb1df146756 | 271 | /** |
mbed_official | 76:aeb1df146756 | 272 | * @} |
mbed_official | 76:aeb1df146756 | 273 | */ |
mbed_official | 76:aeb1df146756 | 274 | |
mbed_official | 76:aeb1df146756 | 275 | /** @defgroup PWR_Group4 Ultra Low Power mode configuration functions |
mbed_official | 76:aeb1df146756 | 276 | * @brief Ultra Low Power mode configuration functions |
mbed_official | 76:aeb1df146756 | 277 | * |
mbed_official | 76:aeb1df146756 | 278 | @verbatim |
mbed_official | 76:aeb1df146756 | 279 | ============================================================================== |
mbed_official | 76:aeb1df146756 | 280 | ##### Ultra Low Power mode configuration functions ##### |
mbed_official | 76:aeb1df146756 | 281 | ============================================================================== |
mbed_official | 76:aeb1df146756 | 282 | [..] |
mbed_official | 76:aeb1df146756 | 283 | (+) The internal voltage reference consumption is not negligible, in particular |
mbed_official | 76:aeb1df146756 | 284 | in Stop and Standby mode. To reduce power consumption, use the PWR_UltraLowPowerCmd() |
mbed_official | 76:aeb1df146756 | 285 | function (ULP bit (Ultra low power) in the PWR_CR register) to disable the |
mbed_official | 76:aeb1df146756 | 286 | internal voltage reference. However, in this case, when exiting from the |
mbed_official | 76:aeb1df146756 | 287 | Stop/Standby mode, the functions managed through the internal voltage reference |
mbed_official | 76:aeb1df146756 | 288 | are not reliable during the internal voltage reference startup time (up to 3 ms). |
mbed_official | 76:aeb1df146756 | 289 | To reduce the wakeup time, the device can exit from Stop/Standby mode without |
mbed_official | 76:aeb1df146756 | 290 | waiting for the internal voltage reference startup time. This is performed |
mbed_official | 76:aeb1df146756 | 291 | by using the PWR_FastWakeUpCmd() function (setting the FWU bit (Fast |
mbed_official | 76:aeb1df146756 | 292 | wakeup) in the PWR_CR register) before entering Stop/Standby mode. |
mbed_official | 76:aeb1df146756 | 293 | |
mbed_official | 76:aeb1df146756 | 294 | @endverbatim |
mbed_official | 76:aeb1df146756 | 295 | * @{ |
mbed_official | 76:aeb1df146756 | 296 | */ |
mbed_official | 76:aeb1df146756 | 297 | |
mbed_official | 76:aeb1df146756 | 298 | /** |
mbed_official | 76:aeb1df146756 | 299 | * @brief Enables or disables the Fast WakeUp from Ultra Low Power mode. |
mbed_official | 76:aeb1df146756 | 300 | * @param NewState: new state of the Fast WakeUp functionality. |
mbed_official | 76:aeb1df146756 | 301 | * This parameter can be: ENABLE or DISABLE. |
mbed_official | 76:aeb1df146756 | 302 | * @retval None |
mbed_official | 76:aeb1df146756 | 303 | */ |
mbed_official | 76:aeb1df146756 | 304 | void PWR_FastWakeUpCmd(FunctionalState NewState) |
mbed_official | 76:aeb1df146756 | 305 | { |
mbed_official | 76:aeb1df146756 | 306 | /* Check the parameters */ |
mbed_official | 76:aeb1df146756 | 307 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 76:aeb1df146756 | 308 | |
mbed_official | 76:aeb1df146756 | 309 | *(__IO uint32_t *) CR_FWU_BB = (uint32_t)NewState; |
mbed_official | 76:aeb1df146756 | 310 | } |
mbed_official | 76:aeb1df146756 | 311 | |
mbed_official | 76:aeb1df146756 | 312 | /** |
mbed_official | 76:aeb1df146756 | 313 | * @brief Enables or disables the Ultra Low Power mode. |
mbed_official | 76:aeb1df146756 | 314 | * @param NewState: new state of the Ultra Low Power mode. |
mbed_official | 76:aeb1df146756 | 315 | * This parameter can be: ENABLE or DISABLE. |
mbed_official | 76:aeb1df146756 | 316 | * @retval None |
mbed_official | 76:aeb1df146756 | 317 | */ |
mbed_official | 76:aeb1df146756 | 318 | void PWR_UltraLowPowerCmd(FunctionalState NewState) |
mbed_official | 76:aeb1df146756 | 319 | { |
mbed_official | 76:aeb1df146756 | 320 | /* Check the parameters */ |
mbed_official | 76:aeb1df146756 | 321 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 76:aeb1df146756 | 322 | |
mbed_official | 76:aeb1df146756 | 323 | *(__IO uint32_t *) CR_ULP_BB = (uint32_t)NewState; |
mbed_official | 76:aeb1df146756 | 324 | } |
mbed_official | 76:aeb1df146756 | 325 | |
mbed_official | 76:aeb1df146756 | 326 | /** |
mbed_official | 76:aeb1df146756 | 327 | * @} |
mbed_official | 76:aeb1df146756 | 328 | */ |
mbed_official | 76:aeb1df146756 | 329 | |
mbed_official | 76:aeb1df146756 | 330 | /** @defgroup PWR_Group5 Voltage Scaling configuration functions |
mbed_official | 76:aeb1df146756 | 331 | * @brief Voltage Scaling configuration functions |
mbed_official | 76:aeb1df146756 | 332 | * |
mbed_official | 76:aeb1df146756 | 333 | @verbatim |
mbed_official | 76:aeb1df146756 | 334 | ============================================================================== |
mbed_official | 76:aeb1df146756 | 335 | ##### Voltage Scaling configuration functions ##### |
mbed_official | 76:aeb1df146756 | 336 | ============================================================================== |
mbed_official | 76:aeb1df146756 | 337 | |
mbed_official | 76:aeb1df146756 | 338 | (+) The dynamic voltage scaling is a power management technique which consists in |
mbed_official | 76:aeb1df146756 | 339 | increasing or decreasing the voltage used for the digital peripherals (VCORE), |
mbed_official | 76:aeb1df146756 | 340 | according to the circumstances. |
mbed_official | 76:aeb1df146756 | 341 | |
mbed_official | 76:aeb1df146756 | 342 | [..] Depending on the device voltage range, the maximum frequency and FLASH wait |
mbed_official | 76:aeb1df146756 | 343 | state should be adapted accordingly: |
mbed_official | 76:aeb1df146756 | 344 | [..] |
mbed_official | 76:aeb1df146756 | 345 | +------------------------------------------------------------------+ |
mbed_official | 76:aeb1df146756 | 346 | | Wait states | HCLK clock frequency (MHz) | |
mbed_official | 76:aeb1df146756 | 347 | | |------------------------------------------------| |
mbed_official | 76:aeb1df146756 | 348 | | (Latency) | voltage range | voltage range | |
mbed_official | 76:aeb1df146756 | 349 | | | 1.65 V - 3.6 V | 2.0 V - 3.6 V | |
mbed_official | 76:aeb1df146756 | 350 | | |----------------|---------------|---------------| |
mbed_official | 76:aeb1df146756 | 351 | | | Range 3 | Range 2 | Range 1 | |
mbed_official | 76:aeb1df146756 | 352 | | | VCORE = 1.2 V | VCORE = 1.5 V | VCORE = 1.8 V | |
mbed_official | 76:aeb1df146756 | 353 | |---------------- |----------------|---------------|---------------| |
mbed_official | 76:aeb1df146756 | 354 | | 0WS(1CPU cycle) |0 < HCLK <= 2 |0 < HCLK <= 8 |0 < HCLK <= 16 | |
mbed_official | 76:aeb1df146756 | 355 | |-----------------|----------------|---------------|---------------| |
mbed_official | 76:aeb1df146756 | 356 | | 1WS(2CPU cycle) |2 < HCLK <= 4 |8 < HCLK <= 16 |16 < HCLK <= 32| |
mbed_official | 76:aeb1df146756 | 357 | |-----------------|----------------|---------------|---------------| |
mbed_official | 76:aeb1df146756 | 358 | | CPU Performance | Low | Medium | High | |
mbed_official | 76:aeb1df146756 | 359 | |-----__----------|----------------|---------------|---------------| |
mbed_official | 76:aeb1df146756 | 360 | |Power Performance| High | Medium | Low | |
mbed_official | 76:aeb1df146756 | 361 | +------------------------------------------------------------------+ |
mbed_official | 76:aeb1df146756 | 362 | |
mbed_official | 76:aeb1df146756 | 363 | (+) To modify the Product voltage range, user application has to: |
mbed_official | 76:aeb1df146756 | 364 | (++) Check VDD to identify which ranges are allowed (see table above). |
mbed_official | 76:aeb1df146756 | 365 | (++) Check the PWR_FLAG_VOSF (Voltage Scaling update ongoing) using the PWR_GetFlagStatus() |
mbed_official | 76:aeb1df146756 | 366 | function and wait until it is reset. |
mbed_official | 76:aeb1df146756 | 367 | (++) Configure the Voltage range using the PWR_VoltageScalingConfig() function. |
mbed_official | 76:aeb1df146756 | 368 | |
mbed_official | 76:aeb1df146756 | 369 | (+) When VCORE range 1 is selected and VDD drops below 2.0 V, the application must |
mbed_official | 76:aeb1df146756 | 370 | reconfigure the system: |
mbed_official | 76:aeb1df146756 | 371 | (++) Detect that VDD drops below 2.0 V using the PVD Level 1. |
mbed_official | 76:aeb1df146756 | 372 | (++) Adapt the clock frequency to the voltage range that will be selected at next step. |
mbed_official | 76:aeb1df146756 | 373 | (++) Select the required voltage range. |
mbed_official | 76:aeb1df146756 | 374 | (++) When VCORE range 2 or range 3 is selected and VDD drops below 2.0 V, no system |
mbed_official | 76:aeb1df146756 | 375 | reconfiguration is required. |
mbed_official | 76:aeb1df146756 | 376 | |
mbed_official | 76:aeb1df146756 | 377 | (+) When VDD is above 2.0 V, any of the 3 voltage ranges can be selected. |
mbed_official | 76:aeb1df146756 | 378 | (++) When the voltage range is above the targeted voltage range (e.g. from range |
mbed_official | 76:aeb1df146756 | 379 | 1 to 2). |
mbed_official | 76:aeb1df146756 | 380 | (++) Adapt the clock frequency to the lower voltage range that will be selected |
mbed_official | 76:aeb1df146756 | 381 | at next step. |
mbed_official | 76:aeb1df146756 | 382 | (++) Select the required voltage range. |
mbed_official | 76:aeb1df146756 | 383 | (++) When the voltage range is below the targeted voltage range (e.g. from range |
mbed_official | 76:aeb1df146756 | 384 | 3 to 1). |
mbed_official | 76:aeb1df146756 | 385 | (++) Select the required voltage range. |
mbed_official | 76:aeb1df146756 | 386 | (++) Tune the clock frequency if needed. |
mbed_official | 76:aeb1df146756 | 387 | |
mbed_official | 76:aeb1df146756 | 388 | (+) When VDD is below 2.0 V, only range 2 and 3 can be selected: |
mbed_official | 76:aeb1df146756 | 389 | (++) From range 2 to range 3. |
mbed_official | 76:aeb1df146756 | 390 | (+++) Adapt the clock frequency to voltage range 3. |
mbed_official | 76:aeb1df146756 | 391 | (+++) Select voltage range 3. |
mbed_official | 76:aeb1df146756 | 392 | (++) From range 3 to range 2. |
mbed_official | 76:aeb1df146756 | 393 | (+++) Select the voltage range 2. |
mbed_official | 76:aeb1df146756 | 394 | (+++) Tune the clock frequency if needed. |
mbed_official | 76:aeb1df146756 | 395 | |
mbed_official | 76:aeb1df146756 | 396 | @endverbatim |
mbed_official | 76:aeb1df146756 | 397 | * @{ |
mbed_official | 76:aeb1df146756 | 398 | */ |
mbed_official | 76:aeb1df146756 | 399 | |
mbed_official | 76:aeb1df146756 | 400 | /** |
mbed_official | 76:aeb1df146756 | 401 | * @brief Configures the voltage scaling range. |
mbed_official | 76:aeb1df146756 | 402 | * @note During voltage scaling configuration, the system clock is stopped |
mbed_official | 76:aeb1df146756 | 403 | * until the regulator is stabilized (VOSF = 0). This must be taken |
mbed_official | 76:aeb1df146756 | 404 | * into account during application developement, in case a critical |
mbed_official | 76:aeb1df146756 | 405 | * reaction time to interrupt is needed, and depending on peripheral |
mbed_official | 76:aeb1df146756 | 406 | * used (timer, communication,...). |
mbed_official | 76:aeb1df146756 | 407 | * |
mbed_official | 76:aeb1df146756 | 408 | * @param PWR_VoltageScaling: specifies the voltage scaling range. |
mbed_official | 76:aeb1df146756 | 409 | * This parameter can be: |
mbed_official | 76:aeb1df146756 | 410 | * @arg PWR_VoltageScaling_Range1: Voltage Scaling Range 1 (VCORE = 1.8V). |
mbed_official | 76:aeb1df146756 | 411 | * @arg PWR_VoltageScaling_Range2: Voltage Scaling Range 2 (VCORE = 1.5V). |
mbed_official | 76:aeb1df146756 | 412 | * @arg PWR_VoltageScaling_Range3: Voltage Scaling Range 3 (VCORE = 1.2V) |
mbed_official | 76:aeb1df146756 | 413 | * @retval None |
mbed_official | 76:aeb1df146756 | 414 | */ |
mbed_official | 76:aeb1df146756 | 415 | void PWR_VoltageScalingConfig(uint32_t PWR_VoltageScaling) |
mbed_official | 76:aeb1df146756 | 416 | { |
mbed_official | 76:aeb1df146756 | 417 | uint32_t tmp = 0; |
mbed_official | 76:aeb1df146756 | 418 | |
mbed_official | 76:aeb1df146756 | 419 | /* Check the parameters */ |
mbed_official | 76:aeb1df146756 | 420 | assert_param(IS_PWR_VOLTAGE_SCALING_RANGE(PWR_VoltageScaling)); |
mbed_official | 76:aeb1df146756 | 421 | |
mbed_official | 76:aeb1df146756 | 422 | tmp = PWR->CR; |
mbed_official | 76:aeb1df146756 | 423 | |
mbed_official | 76:aeb1df146756 | 424 | tmp &= CR_VOS_MASK; |
mbed_official | 76:aeb1df146756 | 425 | tmp |= PWR_VoltageScaling; |
mbed_official | 76:aeb1df146756 | 426 | |
mbed_official | 76:aeb1df146756 | 427 | PWR->CR = tmp & 0xFFFFFFF3; |
mbed_official | 76:aeb1df146756 | 428 | |
mbed_official | 76:aeb1df146756 | 429 | } |
mbed_official | 76:aeb1df146756 | 430 | |
mbed_official | 76:aeb1df146756 | 431 | /** |
mbed_official | 76:aeb1df146756 | 432 | * @} |
mbed_official | 76:aeb1df146756 | 433 | */ |
mbed_official | 76:aeb1df146756 | 434 | |
mbed_official | 76:aeb1df146756 | 435 | /** @defgroup PWR_Group6 Low Power modes configuration functions |
mbed_official | 76:aeb1df146756 | 436 | * @brief Low Power modes configuration functions |
mbed_official | 76:aeb1df146756 | 437 | * |
mbed_official | 76:aeb1df146756 | 438 | @verbatim |
mbed_official | 76:aeb1df146756 | 439 | ============================================================================== |
mbed_official | 76:aeb1df146756 | 440 | ##### Low Power modes configuration functions ##### |
mbed_official | 76:aeb1df146756 | 441 | ============================================================================== |
mbed_official | 76:aeb1df146756 | 442 | |
mbed_official | 76:aeb1df146756 | 443 | [..] The devices feature five low-power modes: |
mbed_official | 76:aeb1df146756 | 444 | (+) Low power run mode: regulator in low power mode, limited clock frequency, |
mbed_official | 76:aeb1df146756 | 445 | limited number of peripherals running. |
mbed_official | 76:aeb1df146756 | 446 | (+) Sleep mode: Cortex-M3 core stopped, peripherals kept running. |
mbed_official | 76:aeb1df146756 | 447 | (+) Low power sleep mode: Cortex-M3 core stopped, limited clock frequency, |
mbed_official | 76:aeb1df146756 | 448 | limited number of peripherals running, regulator in low power mode. |
mbed_official | 76:aeb1df146756 | 449 | (+) Stop mode: all clocks are stopped, regulator running, regulator in low power mode. |
mbed_official | 76:aeb1df146756 | 450 | (+) Standby mode: VCORE domain powered off. |
mbed_official | 76:aeb1df146756 | 451 | |
mbed_official | 76:aeb1df146756 | 452 | *** Low power run mode (LP run) *** |
mbed_official | 76:aeb1df146756 | 453 | =================================== |
mbed_official | 76:aeb1df146756 | 454 | [..] |
mbed_official | 76:aeb1df146756 | 455 | (+) Entry: |
mbed_official | 76:aeb1df146756 | 456 | (++) Decrease the system frequency. |
mbed_official | 76:aeb1df146756 | 457 | (++) The regulator is forced in low power mode using the PWR_EnterLowPowerRunMode() |
mbed_official | 76:aeb1df146756 | 458 | function. |
mbed_official | 76:aeb1df146756 | 459 | (+) Exit: |
mbed_official | 76:aeb1df146756 | 460 | (++) The regulator is forced in Main regulator mode sing the PWR_EnterLowPowerRunMode() |
mbed_official | 76:aeb1df146756 | 461 | function. |
mbed_official | 76:aeb1df146756 | 462 | (++) Increase the system frequency if needed. |
mbed_official | 76:aeb1df146756 | 463 | |
mbed_official | 76:aeb1df146756 | 464 | *** Sleep mode *** |
mbed_official | 76:aeb1df146756 | 465 | ================== |
mbed_official | 76:aeb1df146756 | 466 | [..] |
mbed_official | 76:aeb1df146756 | 467 | (+) Entry: |
mbed_official | 76:aeb1df146756 | 468 | (++) The Sleep mode is entered by using the PWR_EnterSleepMode(PWR_Regulator_ON,) |
mbed_official | 76:aeb1df146756 | 469 | function with regulator ON. |
mbed_official | 76:aeb1df146756 | 470 | (+) Exit: |
mbed_official | 76:aeb1df146756 | 471 | (++) Any peripheral interrupt acknowledged by the nested vectored interrupt |
mbed_official | 76:aeb1df146756 | 472 | controller (NVIC) can wake up the device from Sleep mode. |
mbed_official | 76:aeb1df146756 | 473 | |
mbed_official | 76:aeb1df146756 | 474 | *** Low power sleep mode (LP sleep) *** |
mbed_official | 76:aeb1df146756 | 475 | ======================================= |
mbed_official | 76:aeb1df146756 | 476 | [..] |
mbed_official | 76:aeb1df146756 | 477 | (+) Entry: |
mbed_official | 76:aeb1df146756 | 478 | (++) The Flash memory must be switched off by using the FLASH_SLEEPPowerDownCmd() |
mbed_official | 76:aeb1df146756 | 479 | function. |
mbed_official | 76:aeb1df146756 | 480 | (++) Decrease the system frequency. |
mbed_official | 76:aeb1df146756 | 481 | (++) The regulator is forced in low power mode and the WFI or WFE instructions |
mbed_official | 76:aeb1df146756 | 482 | are executed using the PWR_EnterSleepMode(PWR_Regulator_LowPower,) function |
mbed_official | 76:aeb1df146756 | 483 | with regulator in LowPower. |
mbed_official | 76:aeb1df146756 | 484 | (+) Exit: |
mbed_official | 76:aeb1df146756 | 485 | (++) Any peripheral interrupt acknowledged by the nested vectored interrupt |
mbed_official | 76:aeb1df146756 | 486 | controller (NVIC) can wake up the device from Sleep LP mode. |
mbed_official | 76:aeb1df146756 | 487 | |
mbed_official | 76:aeb1df146756 | 488 | *** Stop mode *** |
mbed_official | 76:aeb1df146756 | 489 | ================= |
mbed_official | 76:aeb1df146756 | 490 | [..] In Stop mode, all clocks in the VCORE domain are stopped, the PLL, the MSI, |
mbed_official | 76:aeb1df146756 | 491 | the HSI and the HSE RC oscillators are disabled. Internal SRAM and register |
mbed_official | 76:aeb1df146756 | 492 | contents are preserved. |
mbed_official | 76:aeb1df146756 | 493 | The voltage regulator can be configured either in normal or low-power mode. |
mbed_official | 76:aeb1df146756 | 494 | To minimize the consumption In Stop mode, VREFINT, the BOR, PVD, and temperature |
mbed_official | 76:aeb1df146756 | 495 | sensor can be switched off before entering the Stop mode. They can be switched |
mbed_official | 76:aeb1df146756 | 496 | on again by software after exiting the Stop mode using the PWR_UltraLowPowerCmd() |
mbed_official | 76:aeb1df146756 | 497 | function. |
mbed_official | 76:aeb1df146756 | 498 | |
mbed_official | 76:aeb1df146756 | 499 | (+) Entry: |
mbed_official | 76:aeb1df146756 | 500 | (++) The Stop mode is entered using the PWR_EnterSTOPMode(PWR_Regulator_LowPower,) |
mbed_official | 76:aeb1df146756 | 501 | function with regulator in LowPower or with Regulator ON. |
mbed_official | 76:aeb1df146756 | 502 | (+) Exit: |
mbed_official | 76:aeb1df146756 | 503 | (++) Any EXTI Line (Internal or External) configured in Interrupt/Event mode. |
mbed_official | 76:aeb1df146756 | 504 | |
mbed_official | 76:aeb1df146756 | 505 | *** Standby mode *** |
mbed_official | 76:aeb1df146756 | 506 | ==================== |
mbed_official | 76:aeb1df146756 | 507 | [..] The Standby mode allows to achieve the lowest power consumption. It is based |
mbed_official | 76:aeb1df146756 | 508 | on the Cortex-M3 deepsleep mode, with the voltage regulator disabled. |
mbed_official | 76:aeb1df146756 | 509 | The VCORE domain is consequently powered off. The PLL, the MSI, the HSI |
mbed_official | 76:aeb1df146756 | 510 | oscillator and the HSE oscillator are also switched off. SRAM and register |
mbed_official | 76:aeb1df146756 | 511 | contents are lost except for the RTC registers, RTC backup registers and |
mbed_official | 76:aeb1df146756 | 512 | Standby circuitry. |
mbed_official | 76:aeb1df146756 | 513 | |
mbed_official | 76:aeb1df146756 | 514 | [..] The voltage regulator is OFF. |
mbed_official | 76:aeb1df146756 | 515 | |
mbed_official | 76:aeb1df146756 | 516 | [..] To minimize the consumption In Standby mode, VREFINT, the BOR, PVD, and temperature |
mbed_official | 76:aeb1df146756 | 517 | sensor can be switched off before entering the Standby mode. They can be switched |
mbed_official | 76:aeb1df146756 | 518 | on again by software after exiting the Standby mode using the PWR_UltraLowPowerCmd() |
mbed_official | 76:aeb1df146756 | 519 | function. |
mbed_official | 76:aeb1df146756 | 520 | |
mbed_official | 76:aeb1df146756 | 521 | (+) Entry: |
mbed_official | 76:aeb1df146756 | 522 | (++) The Standby mode is entered using the PWR_EnterSTANDBYMode() function. |
mbed_official | 76:aeb1df146756 | 523 | (+) Exit: |
mbed_official | 76:aeb1df146756 | 524 | (++) WKUP pin rising edge, RTC alarm (Alarm A and Alarm B), RTC wakeup, |
mbed_official | 76:aeb1df146756 | 525 | tamper event, time-stamp event, external reset in NRST pin, IWDG reset. |
mbed_official | 76:aeb1df146756 | 526 | |
mbed_official | 76:aeb1df146756 | 527 | *** Auto-wakeup (AWU) from low-power mode *** |
mbed_official | 76:aeb1df146756 | 528 | ============================================= |
mbed_official | 76:aeb1df146756 | 529 | [..]The MCU can be woken up from low-power mode by an RTC Alarm event, an RTC |
mbed_official | 76:aeb1df146756 | 530 | Wakeup event, a tamper event, a time-stamp event, or a comparator event, |
mbed_official | 76:aeb1df146756 | 531 | without depending on an external interrupt (Auto-wakeup mode). |
mbed_official | 76:aeb1df146756 | 532 | |
mbed_official | 76:aeb1df146756 | 533 | (+) RTC auto-wakeup (AWU) from the Stop mode |
mbed_official | 76:aeb1df146756 | 534 | (++) To wake up from the Stop mode with an RTC alarm event, it is necessary to: |
mbed_official | 76:aeb1df146756 | 535 | (+++) Configure the EXTI Line 17 to be sensitive to rising edges (Interrupt |
mbed_official | 76:aeb1df146756 | 536 | or Event modes) using the EXTI_Init() function. |
mbed_official | 76:aeb1df146756 | 537 | (+++) Enable the RTC Alarm Interrupt using the RTC_ITConfig() function |
mbed_official | 76:aeb1df146756 | 538 | (+++) Configure the RTC to generate the RTC alarm using the RTC_SetAlarm() |
mbed_official | 76:aeb1df146756 | 539 | and RTC_AlarmCmd() functions. |
mbed_official | 76:aeb1df146756 | 540 | (++) To wake up from the Stop mode with an RTC Tamper or time stamp event, it |
mbed_official | 76:aeb1df146756 | 541 | is necessary to: |
mbed_official | 76:aeb1df146756 | 542 | (+++) Configure the EXTI Line 19 to be sensitive to rising edges (Interrupt |
mbed_official | 76:aeb1df146756 | 543 | or Event modes) using the EXTI_Init() function. |
mbed_official | 76:aeb1df146756 | 544 | (+++) Enable the RTC Tamper or time stamp Interrupt using the RTC_ITConfig() |
mbed_official | 76:aeb1df146756 | 545 | function. |
mbed_official | 76:aeb1df146756 | 546 | (+++) Configure the RTC to detect the tamper or time stamp event using the |
mbed_official | 76:aeb1df146756 | 547 | RTC_TimeStampConfig(), RTC_TamperTriggerConfig() and RTC_TamperCmd() |
mbed_official | 76:aeb1df146756 | 548 | functions. |
mbed_official | 76:aeb1df146756 | 549 | (++) To wake up from the Stop mode with an RTC WakeUp event, it is necessary to: |
mbed_official | 76:aeb1df146756 | 550 | (+++) Configure the EXTI Line 20 to be sensitive to rising edges (Interrupt |
mbed_official | 76:aeb1df146756 | 551 | or Event modes) using the EXTI_Init() function. |
mbed_official | 76:aeb1df146756 | 552 | (+++) Enable the RTC WakeUp Interrupt using the RTC_ITConfig() function. |
mbed_official | 76:aeb1df146756 | 553 | (+++) Configure the RTC to generate the RTC WakeUp event using the RTC_WakeUpClockConfig(), |
mbed_official | 76:aeb1df146756 | 554 | RTC_SetWakeUpCounter() and RTC_WakeUpCmd() functions. |
mbed_official | 76:aeb1df146756 | 555 | |
mbed_official | 76:aeb1df146756 | 556 | (+) RTC auto-wakeup (AWU) from the Standby mode |
mbed_official | 76:aeb1df146756 | 557 | (++) To wake up from the Standby mode with an RTC alarm event, it is necessary to: |
mbed_official | 76:aeb1df146756 | 558 | (+++) Enable the RTC Alarm Interrupt using the RTC_ITConfig() function. |
mbed_official | 76:aeb1df146756 | 559 | (+++) Configure the RTC to generate the RTC alarm using the RTC_SetAlarm() |
mbed_official | 76:aeb1df146756 | 560 | and RTC_AlarmCmd() functions. |
mbed_official | 76:aeb1df146756 | 561 | (++) To wake up from the Standby mode with an RTC Tamper or time stamp event, it |
mbed_official | 76:aeb1df146756 | 562 | is necessary to: |
mbed_official | 76:aeb1df146756 | 563 | (+++) Enable the RTC Tamper or time stamp Interrupt using the RTC_ITConfig() |
mbed_official | 76:aeb1df146756 | 564 | function. |
mbed_official | 76:aeb1df146756 | 565 | (+++) Configure the RTC to detect the tamper or time stamp event using the |
mbed_official | 76:aeb1df146756 | 566 | RTC_TimeStampConfig(), RTC_TamperTriggerConfig() and RTC_TamperCmd() |
mbed_official | 76:aeb1df146756 | 567 | functions. |
mbed_official | 76:aeb1df146756 | 568 | (++) To wake up from the Standby mode with an RTC WakeUp event, it is necessary to: |
mbed_official | 76:aeb1df146756 | 569 | (+++) Enable the RTC WakeUp Interrupt using the RTC_ITConfig() function |
mbed_official | 76:aeb1df146756 | 570 | (+++) Configure the RTC to generate the RTC WakeUp event using the RTC_WakeUpClockConfig(), |
mbed_official | 76:aeb1df146756 | 571 | RTC_SetWakeUpCounter() and RTC_WakeUpCmd() functions. |
mbed_official | 76:aeb1df146756 | 572 | |
mbed_official | 76:aeb1df146756 | 573 | (+) Comparator auto-wakeup (AWU) from the Stop mode |
mbed_official | 76:aeb1df146756 | 574 | (++) To wake up from the Stop mode with an comparator 1 or comparator 2 wakeup |
mbed_official | 76:aeb1df146756 | 575 | event, it is necessary to: |
mbed_official | 76:aeb1df146756 | 576 | (+++) Configure the EXTI Line 21 for comparator 1 or EXTI Line 22 for comparator 2 |
mbed_official | 76:aeb1df146756 | 577 | to be sensitive to to the selected edges (falling, rising or falling |
mbed_official | 76:aeb1df146756 | 578 | and rising) (Interrupt or Event modes) using the EXTI_Init() function. |
mbed_official | 76:aeb1df146756 | 579 | (+++) Configure the comparator to generate the event. |
mbed_official | 76:aeb1df146756 | 580 | |
mbed_official | 76:aeb1df146756 | 581 | @endverbatim |
mbed_official | 76:aeb1df146756 | 582 | * @{ |
mbed_official | 76:aeb1df146756 | 583 | */ |
mbed_official | 76:aeb1df146756 | 584 | |
mbed_official | 76:aeb1df146756 | 585 | /** |
mbed_official | 76:aeb1df146756 | 586 | * @brief Enters/Exits the Low Power Run mode. |
mbed_official | 76:aeb1df146756 | 587 | * @note Low power run mode can only be entered when VCORE is in range 2. |
mbed_official | 76:aeb1df146756 | 588 | * In addition, the dynamic voltage scaling must not be used when Low |
mbed_official | 76:aeb1df146756 | 589 | * power run mode is selected. Only Stop and Sleep modes with regulator |
mbed_official | 76:aeb1df146756 | 590 | * configured in Low power mode is allowed when Low power run mode is |
mbed_official | 76:aeb1df146756 | 591 | * selected. |
mbed_official | 76:aeb1df146756 | 592 | * @note In Low power run mode, all I/O pins keep the same state as in Run mode. |
mbed_official | 76:aeb1df146756 | 593 | * @param NewState: new state of the Low Power Run mode. |
mbed_official | 76:aeb1df146756 | 594 | * This parameter can be: ENABLE or DISABLE. |
mbed_official | 76:aeb1df146756 | 595 | * @retval None |
mbed_official | 76:aeb1df146756 | 596 | */ |
mbed_official | 76:aeb1df146756 | 597 | void PWR_EnterLowPowerRunMode(FunctionalState NewState) |
mbed_official | 76:aeb1df146756 | 598 | { |
mbed_official | 76:aeb1df146756 | 599 | /* Check the parameters */ |
mbed_official | 76:aeb1df146756 | 600 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 76:aeb1df146756 | 601 | |
mbed_official | 76:aeb1df146756 | 602 | if (NewState != DISABLE) |
mbed_official | 76:aeb1df146756 | 603 | { |
mbed_official | 76:aeb1df146756 | 604 | PWR->CR |= PWR_CR_LPSDSR; |
mbed_official | 76:aeb1df146756 | 605 | PWR->CR |= PWR_CR_LPRUN; |
mbed_official | 76:aeb1df146756 | 606 | } |
mbed_official | 76:aeb1df146756 | 607 | else |
mbed_official | 76:aeb1df146756 | 608 | { |
mbed_official | 76:aeb1df146756 | 609 | PWR->CR &= (uint32_t)~((uint32_t)PWR_CR_LPRUN); |
mbed_official | 76:aeb1df146756 | 610 | PWR->CR &= (uint32_t)~((uint32_t)PWR_CR_LPSDSR); |
mbed_official | 76:aeb1df146756 | 611 | } |
mbed_official | 76:aeb1df146756 | 612 | } |
mbed_official | 76:aeb1df146756 | 613 | |
mbed_official | 76:aeb1df146756 | 614 | /** |
mbed_official | 76:aeb1df146756 | 615 | * @brief Enters Sleep mode. |
mbed_official | 76:aeb1df146756 | 616 | * @note In Sleep mode, all I/O pins keep the same state as in Run mode. |
mbed_official | 76:aeb1df146756 | 617 | * @param PWR_Regulator: specifies the regulator state in Sleep mode. |
mbed_official | 76:aeb1df146756 | 618 | * This parameter can be one of the following values: |
mbed_official | 76:aeb1df146756 | 619 | * @arg PWR_Regulator_ON: Sleep mode with regulator ON |
mbed_official | 76:aeb1df146756 | 620 | * @arg PWR_Regulator_LowPower: Sleep mode with regulator in low power mode |
mbed_official | 76:aeb1df146756 | 621 | * @note Low power sleep mode can only be entered when VCORE is in range 2. |
mbed_official | 76:aeb1df146756 | 622 | * @note When the voltage regulator operates in low power mode, an additional |
mbed_official | 76:aeb1df146756 | 623 | * startup delay is incurred when waking up from Low power sleep mode. |
mbed_official | 76:aeb1df146756 | 624 | * @param PWR_SLEEPEntry: specifies if SLEEP mode in entered with WFI or WFE instruction. |
mbed_official | 76:aeb1df146756 | 625 | * This parameter can be one of the following values: |
mbed_official | 76:aeb1df146756 | 626 | * @arg PWR_SLEEPEntry_WFI: enter SLEEP mode with WFI instruction |
mbed_official | 76:aeb1df146756 | 627 | * @arg PWR_SLEEPEntry_WFE: enter SLEEP mode with WFE instruction |
mbed_official | 76:aeb1df146756 | 628 | * @retval None |
mbed_official | 76:aeb1df146756 | 629 | */ |
mbed_official | 76:aeb1df146756 | 630 | void PWR_EnterSleepMode(uint32_t PWR_Regulator, uint8_t PWR_SLEEPEntry) |
mbed_official | 76:aeb1df146756 | 631 | { |
mbed_official | 76:aeb1df146756 | 632 | uint32_t tmpreg = 0; |
mbed_official | 76:aeb1df146756 | 633 | |
mbed_official | 76:aeb1df146756 | 634 | /* Check the parameters */ |
mbed_official | 76:aeb1df146756 | 635 | assert_param(IS_PWR_REGULATOR(PWR_Regulator)); |
mbed_official | 76:aeb1df146756 | 636 | |
mbed_official | 76:aeb1df146756 | 637 | assert_param(IS_PWR_SLEEP_ENTRY(PWR_SLEEPEntry)); |
mbed_official | 76:aeb1df146756 | 638 | |
mbed_official | 76:aeb1df146756 | 639 | /* Select the regulator state in Sleep mode ---------------------------------*/ |
mbed_official | 76:aeb1df146756 | 640 | tmpreg = PWR->CR; |
mbed_official | 76:aeb1df146756 | 641 | |
mbed_official | 76:aeb1df146756 | 642 | /* Clear PDDS and LPDSR bits */ |
mbed_official | 76:aeb1df146756 | 643 | tmpreg &= CR_DS_MASK; |
mbed_official | 76:aeb1df146756 | 644 | |
mbed_official | 76:aeb1df146756 | 645 | /* Set LPDSR bit according to PWR_Regulator value */ |
mbed_official | 76:aeb1df146756 | 646 | tmpreg |= PWR_Regulator; |
mbed_official | 76:aeb1df146756 | 647 | |
mbed_official | 76:aeb1df146756 | 648 | /* Store the new value */ |
mbed_official | 76:aeb1df146756 | 649 | PWR->CR = tmpreg; |
mbed_official | 76:aeb1df146756 | 650 | |
mbed_official | 76:aeb1df146756 | 651 | /* Clear SLEEPDEEP bit of Cortex System Control Register */ |
mbed_official | 76:aeb1df146756 | 652 | SCB->SCR &= (uint32_t)~((uint32_t)SCB_SCR_SLEEPDEEP); |
mbed_official | 76:aeb1df146756 | 653 | |
mbed_official | 76:aeb1df146756 | 654 | /* Select SLEEP mode entry -------------------------------------------------*/ |
mbed_official | 76:aeb1df146756 | 655 | if(PWR_SLEEPEntry == PWR_SLEEPEntry_WFI) |
mbed_official | 76:aeb1df146756 | 656 | { |
mbed_official | 76:aeb1df146756 | 657 | /* Request Wait For Interrupt */ |
mbed_official | 76:aeb1df146756 | 658 | __WFI(); |
mbed_official | 76:aeb1df146756 | 659 | } |
mbed_official | 76:aeb1df146756 | 660 | else |
mbed_official | 76:aeb1df146756 | 661 | { |
mbed_official | 76:aeb1df146756 | 662 | /* Request Wait For Event */ |
mbed_official | 76:aeb1df146756 | 663 | __WFE(); |
mbed_official | 76:aeb1df146756 | 664 | } |
mbed_official | 76:aeb1df146756 | 665 | } |
mbed_official | 76:aeb1df146756 | 666 | |
mbed_official | 76:aeb1df146756 | 667 | /** |
mbed_official | 76:aeb1df146756 | 668 | * @brief Enters STOP mode. |
mbed_official | 76:aeb1df146756 | 669 | * @note In Stop mode, all I/O pins keep the same state as in Run mode. |
mbed_official | 76:aeb1df146756 | 670 | * @note When exiting Stop mode by issuing an interrupt or a wakeup event, |
mbed_official | 76:aeb1df146756 | 671 | * the MSI RC oscillator is selected as system clock. |
mbed_official | 76:aeb1df146756 | 672 | * @note When the voltage regulator operates in low power mode, an additional |
mbed_official | 76:aeb1df146756 | 673 | * startup delay is incurred when waking up from Stop mode. |
mbed_official | 76:aeb1df146756 | 674 | * By keeping the internal regulator ON during Stop mode, the consumption |
mbed_official | 76:aeb1df146756 | 675 | * is higher although the startup time is reduced. |
mbed_official | 76:aeb1df146756 | 676 | * @param PWR_Regulator: specifies the regulator state in STOP mode. |
mbed_official | 76:aeb1df146756 | 677 | * This parameter can be one of the following values: |
mbed_official | 76:aeb1df146756 | 678 | * @arg PWR_Regulator_ON: STOP mode with regulator ON. |
mbed_official | 76:aeb1df146756 | 679 | * @arg PWR_Regulator_LowPower: STOP mode with regulator in low power mode. |
mbed_official | 76:aeb1df146756 | 680 | * @param PWR_STOPEntry: specifies if STOP mode in entered with WFI or WFE instruction. |
mbed_official | 76:aeb1df146756 | 681 | * This parameter can be one of the following values: |
mbed_official | 76:aeb1df146756 | 682 | * @arg PWR_STOPEntry_WFI: enter STOP mode with WFI instruction. |
mbed_official | 76:aeb1df146756 | 683 | * @arg PWR_STOPEntry_WFE: enter STOP mode with WFE instruction. |
mbed_official | 76:aeb1df146756 | 684 | * @retval None |
mbed_official | 76:aeb1df146756 | 685 | */ |
mbed_official | 76:aeb1df146756 | 686 | void PWR_EnterSTOPMode(uint32_t PWR_Regulator, uint8_t PWR_STOPEntry) |
mbed_official | 76:aeb1df146756 | 687 | { |
mbed_official | 76:aeb1df146756 | 688 | uint32_t tmpreg = 0; |
mbed_official | 76:aeb1df146756 | 689 | |
mbed_official | 76:aeb1df146756 | 690 | /* Check the parameters */ |
mbed_official | 76:aeb1df146756 | 691 | assert_param(IS_PWR_REGULATOR(PWR_Regulator)); |
mbed_official | 76:aeb1df146756 | 692 | assert_param(IS_PWR_STOP_ENTRY(PWR_STOPEntry)); |
mbed_official | 76:aeb1df146756 | 693 | |
mbed_official | 76:aeb1df146756 | 694 | /* Select the regulator state in STOP mode ---------------------------------*/ |
mbed_official | 76:aeb1df146756 | 695 | tmpreg = PWR->CR; |
mbed_official | 76:aeb1df146756 | 696 | /* Clear PDDS and LPDSR bits */ |
mbed_official | 76:aeb1df146756 | 697 | tmpreg &= CR_DS_MASK; |
mbed_official | 76:aeb1df146756 | 698 | |
mbed_official | 76:aeb1df146756 | 699 | /* Set LPDSR bit according to PWR_Regulator value */ |
mbed_official | 76:aeb1df146756 | 700 | tmpreg |= PWR_Regulator; |
mbed_official | 76:aeb1df146756 | 701 | |
mbed_official | 76:aeb1df146756 | 702 | /* Store the new value */ |
mbed_official | 76:aeb1df146756 | 703 | PWR->CR = tmpreg; |
mbed_official | 76:aeb1df146756 | 704 | |
mbed_official | 76:aeb1df146756 | 705 | /* Set SLEEPDEEP bit of Cortex System Control Register */ |
mbed_official | 76:aeb1df146756 | 706 | SCB->SCR |= SCB_SCR_SLEEPDEEP; |
mbed_official | 76:aeb1df146756 | 707 | |
mbed_official | 76:aeb1df146756 | 708 | /* Select STOP mode entry --------------------------------------------------*/ |
mbed_official | 76:aeb1df146756 | 709 | if(PWR_STOPEntry == PWR_STOPEntry_WFI) |
mbed_official | 76:aeb1df146756 | 710 | { |
mbed_official | 76:aeb1df146756 | 711 | /* Request Wait For Interrupt */ |
mbed_official | 76:aeb1df146756 | 712 | __WFI(); |
mbed_official | 76:aeb1df146756 | 713 | } |
mbed_official | 76:aeb1df146756 | 714 | else |
mbed_official | 76:aeb1df146756 | 715 | { |
mbed_official | 76:aeb1df146756 | 716 | /* Request Wait For Event */ |
mbed_official | 76:aeb1df146756 | 717 | __WFE(); |
mbed_official | 76:aeb1df146756 | 718 | } |
mbed_official | 76:aeb1df146756 | 719 | /* Reset SLEEPDEEP bit of Cortex System Control Register */ |
mbed_official | 76:aeb1df146756 | 720 | SCB->SCR &= (uint32_t)~((uint32_t)SCB_SCR_SLEEPDEEP); |
mbed_official | 76:aeb1df146756 | 721 | } |
mbed_official | 76:aeb1df146756 | 722 | |
mbed_official | 76:aeb1df146756 | 723 | /** |
mbed_official | 76:aeb1df146756 | 724 | * @brief Enters STANDBY mode. |
mbed_official | 76:aeb1df146756 | 725 | * @note In Standby mode, all I/O pins are high impedance except for: |
mbed_official | 76:aeb1df146756 | 726 | * Reset pad (still available) |
mbed_official | 76:aeb1df146756 | 727 | * RTC_AF1 pin (PC13) if configured for Wakeup pin 2 (WKUP2), tamper, |
mbed_official | 76:aeb1df146756 | 728 | * time-stamp, RTC Alarm out, or RTC clock calibration out. |
mbed_official | 76:aeb1df146756 | 729 | * WKUP pin 1 (PA0) and WKUP pin 3 (PE6), if enabled. |
mbed_official | 76:aeb1df146756 | 730 | * @param None |
mbed_official | 76:aeb1df146756 | 731 | * @retval None |
mbed_official | 76:aeb1df146756 | 732 | */ |
mbed_official | 76:aeb1df146756 | 733 | void PWR_EnterSTANDBYMode(void) |
mbed_official | 76:aeb1df146756 | 734 | { |
mbed_official | 76:aeb1df146756 | 735 | /* Clear Wakeup flag */ |
mbed_official | 76:aeb1df146756 | 736 | PWR->CR |= PWR_CR_CWUF; |
mbed_official | 76:aeb1df146756 | 737 | |
mbed_official | 76:aeb1df146756 | 738 | /* Select STANDBY mode */ |
mbed_official | 76:aeb1df146756 | 739 | PWR->CR |= PWR_CR_PDDS; |
mbed_official | 76:aeb1df146756 | 740 | |
mbed_official | 76:aeb1df146756 | 741 | /* Set SLEEPDEEP bit of Cortex System Control Register */ |
mbed_official | 76:aeb1df146756 | 742 | SCB->SCR |= SCB_SCR_SLEEPDEEP; |
mbed_official | 76:aeb1df146756 | 743 | |
mbed_official | 76:aeb1df146756 | 744 | /* This option is used to ensure that store operations are completed */ |
mbed_official | 76:aeb1df146756 | 745 | #if defined ( __CC_ARM ) |
mbed_official | 76:aeb1df146756 | 746 | __force_stores(); |
mbed_official | 76:aeb1df146756 | 747 | #endif |
mbed_official | 76:aeb1df146756 | 748 | /* Request Wait For Interrupt */ |
mbed_official | 76:aeb1df146756 | 749 | __WFI(); |
mbed_official | 76:aeb1df146756 | 750 | } |
mbed_official | 76:aeb1df146756 | 751 | |
mbed_official | 76:aeb1df146756 | 752 | /** |
mbed_official | 76:aeb1df146756 | 753 | * @} |
mbed_official | 76:aeb1df146756 | 754 | */ |
mbed_official | 76:aeb1df146756 | 755 | |
mbed_official | 76:aeb1df146756 | 756 | /** @defgroup PWR_Group7 Flags management functions |
mbed_official | 76:aeb1df146756 | 757 | * @brief Flags management functions |
mbed_official | 76:aeb1df146756 | 758 | * |
mbed_official | 76:aeb1df146756 | 759 | @verbatim |
mbed_official | 76:aeb1df146756 | 760 | ============================================================================== |
mbed_official | 76:aeb1df146756 | 761 | ##### Flags management functions ##### |
mbed_official | 76:aeb1df146756 | 762 | ============================================================================== |
mbed_official | 76:aeb1df146756 | 763 | |
mbed_official | 76:aeb1df146756 | 764 | @endverbatim |
mbed_official | 76:aeb1df146756 | 765 | * @{ |
mbed_official | 76:aeb1df146756 | 766 | */ |
mbed_official | 76:aeb1df146756 | 767 | |
mbed_official | 76:aeb1df146756 | 768 | /** |
mbed_official | 76:aeb1df146756 | 769 | * @brief Checks whether the specified PWR flag is set or not. |
mbed_official | 76:aeb1df146756 | 770 | * @param PWR_FLAG: specifies the flag to check. |
mbed_official | 76:aeb1df146756 | 771 | * This parameter can be one of the following values: |
mbed_official | 76:aeb1df146756 | 772 | * @arg PWR_FLAG_WU: Wake Up flag. This flag indicates that a wakeup event |
mbed_official | 76:aeb1df146756 | 773 | * was received from the WKUP pin or from the RTC alarm (Alarm A or Alarm B), |
mbed_official | 76:aeb1df146756 | 774 | * RTC Tamper event, RTC TimeStamp event or RTC Wakeup. |
mbed_official | 76:aeb1df146756 | 775 | * @arg PWR_FLAG_SB: StandBy flag. This flag indicates that the system was |
mbed_official | 76:aeb1df146756 | 776 | * resumed from StandBy mode. |
mbed_official | 76:aeb1df146756 | 777 | * @arg PWR_FLAG_PVDO: PVD Output. This flag is valid only if PVD is enabled |
mbed_official | 76:aeb1df146756 | 778 | * by the PWR_PVDCmd() function. |
mbed_official | 76:aeb1df146756 | 779 | * @arg PWR_FLAG_VREFINTRDY: Internal Voltage Reference Ready flag. This |
mbed_official | 76:aeb1df146756 | 780 | * flag indicates the state of the internal voltage reference, VREFINT. |
mbed_official | 76:aeb1df146756 | 781 | * @arg PWR_FLAG_VOS: Voltage Scaling select flag. A delay is required for |
mbed_official | 76:aeb1df146756 | 782 | * the internal regulator to be ready after the voltage range is changed. |
mbed_official | 76:aeb1df146756 | 783 | * The VOSF flag indicates that the regulator has reached the voltage level |
mbed_official | 76:aeb1df146756 | 784 | * defined with bits VOS[1:0] of PWR_CR register. |
mbed_official | 76:aeb1df146756 | 785 | * @arg PWR_FLAG_REGLP: Regulator LP flag. This flag is set by hardware |
mbed_official | 76:aeb1df146756 | 786 | * when the MCU is in Low power run mode. |
mbed_official | 76:aeb1df146756 | 787 | * When the MCU exits from Low power run mode, this flag stays SET until |
mbed_official | 76:aeb1df146756 | 788 | * the regulator is ready in main mode. A polling on this flag is |
mbed_official | 76:aeb1df146756 | 789 | * recommended to wait for the regulator main mode. |
mbed_official | 76:aeb1df146756 | 790 | * This flag is RESET by hardware when the regulator is ready. |
mbed_official | 76:aeb1df146756 | 791 | * @retval The new state of PWR_FLAG (SET or RESET). |
mbed_official | 76:aeb1df146756 | 792 | */ |
mbed_official | 76:aeb1df146756 | 793 | FlagStatus PWR_GetFlagStatus(uint32_t PWR_FLAG) |
mbed_official | 76:aeb1df146756 | 794 | { |
mbed_official | 76:aeb1df146756 | 795 | FlagStatus bitstatus = RESET; |
mbed_official | 76:aeb1df146756 | 796 | /* Check the parameters */ |
mbed_official | 76:aeb1df146756 | 797 | assert_param(IS_PWR_GET_FLAG(PWR_FLAG)); |
mbed_official | 76:aeb1df146756 | 798 | |
mbed_official | 76:aeb1df146756 | 799 | if ((PWR->CSR & PWR_FLAG) != (uint32_t)RESET) |
mbed_official | 76:aeb1df146756 | 800 | { |
mbed_official | 76:aeb1df146756 | 801 | bitstatus = SET; |
mbed_official | 76:aeb1df146756 | 802 | } |
mbed_official | 76:aeb1df146756 | 803 | else |
mbed_official | 76:aeb1df146756 | 804 | { |
mbed_official | 76:aeb1df146756 | 805 | bitstatus = RESET; |
mbed_official | 76:aeb1df146756 | 806 | } |
mbed_official | 76:aeb1df146756 | 807 | /* Return the flag status */ |
mbed_official | 76:aeb1df146756 | 808 | return bitstatus; |
mbed_official | 76:aeb1df146756 | 809 | } |
mbed_official | 76:aeb1df146756 | 810 | |
mbed_official | 76:aeb1df146756 | 811 | /** |
mbed_official | 76:aeb1df146756 | 812 | * @brief Clears the PWR's pending flags. |
mbed_official | 76:aeb1df146756 | 813 | * @param PWR_FLAG: specifies the flag to clear. |
mbed_official | 76:aeb1df146756 | 814 | * This parameter can be one of the following values: |
mbed_official | 76:aeb1df146756 | 815 | * @arg PWR_FLAG_WU: Wake Up flag |
mbed_official | 76:aeb1df146756 | 816 | * @arg PWR_FLAG_SB: StandBy flag |
mbed_official | 76:aeb1df146756 | 817 | * @retval None |
mbed_official | 76:aeb1df146756 | 818 | */ |
mbed_official | 76:aeb1df146756 | 819 | void PWR_ClearFlag(uint32_t PWR_FLAG) |
mbed_official | 76:aeb1df146756 | 820 | { |
mbed_official | 76:aeb1df146756 | 821 | /* Check the parameters */ |
mbed_official | 76:aeb1df146756 | 822 | assert_param(IS_PWR_CLEAR_FLAG(PWR_FLAG)); |
mbed_official | 76:aeb1df146756 | 823 | |
mbed_official | 76:aeb1df146756 | 824 | PWR->CR |= PWR_FLAG << 2; |
mbed_official | 76:aeb1df146756 | 825 | } |
mbed_official | 76:aeb1df146756 | 826 | |
mbed_official | 76:aeb1df146756 | 827 | /** |
mbed_official | 76:aeb1df146756 | 828 | * @} |
mbed_official | 76:aeb1df146756 | 829 | */ |
mbed_official | 76:aeb1df146756 | 830 | |
mbed_official | 76:aeb1df146756 | 831 | /** |
mbed_official | 76:aeb1df146756 | 832 | * @} |
mbed_official | 76:aeb1df146756 | 833 | */ |
mbed_official | 76:aeb1df146756 | 834 | |
mbed_official | 76:aeb1df146756 | 835 | /** |
mbed_official | 76:aeb1df146756 | 836 | * @} |
mbed_official | 76:aeb1df146756 | 837 | */ |
mbed_official | 76:aeb1df146756 | 838 | |
mbed_official | 76:aeb1df146756 | 839 | /** |
mbed_official | 76:aeb1df146756 | 840 | * @} |
mbed_official | 76:aeb1df146756 | 841 | */ |
mbed_official | 76:aeb1df146756 | 842 | |
mbed_official | 76:aeb1df146756 | 843 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |