mbed library sources modified for open wear
Dependents: openwear-lifelogger-example
Fork of mbed-src by
targets/cmsis/TARGET_STM/TARGET_DISCO_F303VC/stm32f30x_pwr.c@157:90e3acc479a2, 2014-04-11 (annotated)
- Committer:
- mbed_official
- Date:
- Fri Apr 11 17:15:06 2014 +0100
- Revision:
- 157:90e3acc479a2
Synchronized with git revision 6e20ca17847dceb62132bf3d8519876411e175bf
Full URL: https://github.com/mbedmicro/mbed/commit/6e20ca17847dceb62132bf3d8519876411e175bf/
[STM32F3-Discovery][DISCO_F303VC] initial port.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbed_official | 157:90e3acc479a2 | 1 | /** |
mbed_official | 157:90e3acc479a2 | 2 | ****************************************************************************** |
mbed_official | 157:90e3acc479a2 | 3 | * @file stm32f30x_pwr.c |
mbed_official | 157:90e3acc479a2 | 4 | * @author MCD Application Team |
mbed_official | 157:90e3acc479a2 | 5 | * @version V1.1.0 |
mbed_official | 157:90e3acc479a2 | 6 | * @date 27-February-2014 |
mbed_official | 157:90e3acc479a2 | 7 | * @brief This file provides firmware functions to manage the following |
mbed_official | 157:90e3acc479a2 | 8 | * functionalities of the Power Controller (PWR) peripheral: |
mbed_official | 157:90e3acc479a2 | 9 | * + Backup Domain Access |
mbed_official | 157:90e3acc479a2 | 10 | * + PVD configuration |
mbed_official | 157:90e3acc479a2 | 11 | * + WakeUp pins configuration |
mbed_official | 157:90e3acc479a2 | 12 | * + Low Power modes configuration |
mbed_official | 157:90e3acc479a2 | 13 | * + Flags management |
mbed_official | 157:90e3acc479a2 | 14 | * |
mbed_official | 157:90e3acc479a2 | 15 | ****************************************************************************** |
mbed_official | 157:90e3acc479a2 | 16 | * @attention |
mbed_official | 157:90e3acc479a2 | 17 | * |
mbed_official | 157:90e3acc479a2 | 18 | * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> |
mbed_official | 157:90e3acc479a2 | 19 | * |
mbed_official | 157:90e3acc479a2 | 20 | * Redistribution and use in source and binary forms, with or without modification, |
mbed_official | 157:90e3acc479a2 | 21 | * are permitted provided that the following conditions are met: |
mbed_official | 157:90e3acc479a2 | 22 | * 1. Redistributions of source code must retain the above copyright notice, |
mbed_official | 157:90e3acc479a2 | 23 | * this list of conditions and the following disclaimer. |
mbed_official | 157:90e3acc479a2 | 24 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
mbed_official | 157:90e3acc479a2 | 25 | * this list of conditions and the following disclaimer in the documentation |
mbed_official | 157:90e3acc479a2 | 26 | * and/or other materials provided with the distribution. |
mbed_official | 157:90e3acc479a2 | 27 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
mbed_official | 157:90e3acc479a2 | 28 | * may be used to endorse or promote products derived from this software |
mbed_official | 157:90e3acc479a2 | 29 | * without specific prior written permission. |
mbed_official | 157:90e3acc479a2 | 30 | * |
mbed_official | 157:90e3acc479a2 | 31 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
mbed_official | 157:90e3acc479a2 | 32 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
mbed_official | 157:90e3acc479a2 | 33 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
mbed_official | 157:90e3acc479a2 | 34 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
mbed_official | 157:90e3acc479a2 | 35 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
mbed_official | 157:90e3acc479a2 | 36 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
mbed_official | 157:90e3acc479a2 | 37 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
mbed_official | 157:90e3acc479a2 | 38 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
mbed_official | 157:90e3acc479a2 | 39 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
mbed_official | 157:90e3acc479a2 | 40 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
mbed_official | 157:90e3acc479a2 | 41 | * |
mbed_official | 157:90e3acc479a2 | 42 | ****************************************************************************** |
mbed_official | 157:90e3acc479a2 | 43 | */ |
mbed_official | 157:90e3acc479a2 | 44 | |
mbed_official | 157:90e3acc479a2 | 45 | /* Includes ------------------------------------------------------------------*/ |
mbed_official | 157:90e3acc479a2 | 46 | #include "stm32f30x_pwr.h" |
mbed_official | 157:90e3acc479a2 | 47 | #include "stm32f30x_rcc.h" |
mbed_official | 157:90e3acc479a2 | 48 | |
mbed_official | 157:90e3acc479a2 | 49 | /** @addtogroup STM32F30x_StdPeriph_Driver |
mbed_official | 157:90e3acc479a2 | 50 | * @{ |
mbed_official | 157:90e3acc479a2 | 51 | */ |
mbed_official | 157:90e3acc479a2 | 52 | |
mbed_official | 157:90e3acc479a2 | 53 | /** @defgroup PWR |
mbed_official | 157:90e3acc479a2 | 54 | * @brief PWR driver modules |
mbed_official | 157:90e3acc479a2 | 55 | * @{ |
mbed_official | 157:90e3acc479a2 | 56 | */ |
mbed_official | 157:90e3acc479a2 | 57 | |
mbed_official | 157:90e3acc479a2 | 58 | /* Private typedef -----------------------------------------------------------*/ |
mbed_official | 157:90e3acc479a2 | 59 | /* Private define ------------------------------------------------------------*/ |
mbed_official | 157:90e3acc479a2 | 60 | /* --------- PWR registers bit address in the alias region ---------- */ |
mbed_official | 157:90e3acc479a2 | 61 | #define PWR_OFFSET (PWR_BASE - PERIPH_BASE) |
mbed_official | 157:90e3acc479a2 | 62 | |
mbed_official | 157:90e3acc479a2 | 63 | /* --- CR Register ---*/ |
mbed_official | 157:90e3acc479a2 | 64 | |
mbed_official | 157:90e3acc479a2 | 65 | /* Alias word address of DBP bit */ |
mbed_official | 157:90e3acc479a2 | 66 | #define CR_OFFSET (PWR_OFFSET + 0x00) |
mbed_official | 157:90e3acc479a2 | 67 | #define DBP_BitNumber 0x08 |
mbed_official | 157:90e3acc479a2 | 68 | #define CR_DBP_BB (PERIPH_BB_BASE + (CR_OFFSET * 32) + (DBP_BitNumber * 4)) |
mbed_official | 157:90e3acc479a2 | 69 | |
mbed_official | 157:90e3acc479a2 | 70 | /* Alias word address of PVDE bit */ |
mbed_official | 157:90e3acc479a2 | 71 | #define PVDE_BitNumber 0x04 |
mbed_official | 157:90e3acc479a2 | 72 | #define CR_PVDE_BB (PERIPH_BB_BASE + (CR_OFFSET * 32) + (PVDE_BitNumber * 4)) |
mbed_official | 157:90e3acc479a2 | 73 | |
mbed_official | 157:90e3acc479a2 | 74 | /* ------------------ PWR registers bit mask ------------------------ */ |
mbed_official | 157:90e3acc479a2 | 75 | |
mbed_official | 157:90e3acc479a2 | 76 | /* CR register bit mask */ |
mbed_official | 157:90e3acc479a2 | 77 | #define CR_DS_MASK ((uint32_t)0xFFFFFFFC) |
mbed_official | 157:90e3acc479a2 | 78 | #define CR_PLS_MASK ((uint32_t)0xFFFFFF1F) |
mbed_official | 157:90e3acc479a2 | 79 | |
mbed_official | 157:90e3acc479a2 | 80 | /* Private macro -------------------------------------------------------------*/ |
mbed_official | 157:90e3acc479a2 | 81 | /* Private variables ---------------------------------------------------------*/ |
mbed_official | 157:90e3acc479a2 | 82 | /* Private function prototypes -----------------------------------------------*/ |
mbed_official | 157:90e3acc479a2 | 83 | /* Private functions ---------------------------------------------------------*/ |
mbed_official | 157:90e3acc479a2 | 84 | |
mbed_official | 157:90e3acc479a2 | 85 | /** @defgroup PWR_Private_Functions |
mbed_official | 157:90e3acc479a2 | 86 | * @{ |
mbed_official | 157:90e3acc479a2 | 87 | */ |
mbed_official | 157:90e3acc479a2 | 88 | |
mbed_official | 157:90e3acc479a2 | 89 | /** @defgroup PWR_Group1 Backup Domain Access function |
mbed_official | 157:90e3acc479a2 | 90 | * @brief Backup Domain Access function |
mbed_official | 157:90e3acc479a2 | 91 | * |
mbed_official | 157:90e3acc479a2 | 92 | @verbatim |
mbed_official | 157:90e3acc479a2 | 93 | ============================================================================== |
mbed_official | 157:90e3acc479a2 | 94 | ##### Backup Domain Access function ##### |
mbed_official | 157:90e3acc479a2 | 95 | ============================================================================== |
mbed_official | 157:90e3acc479a2 | 96 | |
mbed_official | 157:90e3acc479a2 | 97 | [..] After reset, the Backup Domain Registers (RCC BDCR Register, RTC registers |
mbed_official | 157:90e3acc479a2 | 98 | and RTC backup registers) are protected against possible stray write accesses. |
mbed_official | 157:90e3acc479a2 | 99 | [..] To enable access to Backup domain use the PWR_BackupAccessCmd(ENABLE) function. |
mbed_official | 157:90e3acc479a2 | 100 | |
mbed_official | 157:90e3acc479a2 | 101 | @endverbatim |
mbed_official | 157:90e3acc479a2 | 102 | * @{ |
mbed_official | 157:90e3acc479a2 | 103 | */ |
mbed_official | 157:90e3acc479a2 | 104 | |
mbed_official | 157:90e3acc479a2 | 105 | /** |
mbed_official | 157:90e3acc479a2 | 106 | * @brief Deinitializes the PWR peripheral registers to their default reset values. |
mbed_official | 157:90e3acc479a2 | 107 | * @param None |
mbed_official | 157:90e3acc479a2 | 108 | * @retval None |
mbed_official | 157:90e3acc479a2 | 109 | */ |
mbed_official | 157:90e3acc479a2 | 110 | void PWR_DeInit(void) |
mbed_official | 157:90e3acc479a2 | 111 | { |
mbed_official | 157:90e3acc479a2 | 112 | RCC_APB1PeriphResetCmd(RCC_APB1Periph_PWR, ENABLE); |
mbed_official | 157:90e3acc479a2 | 113 | RCC_APB1PeriphResetCmd(RCC_APB1Periph_PWR, DISABLE); |
mbed_official | 157:90e3acc479a2 | 114 | } |
mbed_official | 157:90e3acc479a2 | 115 | |
mbed_official | 157:90e3acc479a2 | 116 | /** |
mbed_official | 157:90e3acc479a2 | 117 | * @brief Enables or disables access to the RTC and backup registers. |
mbed_official | 157:90e3acc479a2 | 118 | * @note If the HSE divided by 32 is used as the RTC clock, the |
mbed_official | 157:90e3acc479a2 | 119 | * Backup Domain Access should be kept enabled. |
mbed_official | 157:90e3acc479a2 | 120 | * @param NewState: new state of the access to the RTC and backup registers. |
mbed_official | 157:90e3acc479a2 | 121 | * This parameter can be: ENABLE or DISABLE. |
mbed_official | 157:90e3acc479a2 | 122 | * @retval None |
mbed_official | 157:90e3acc479a2 | 123 | */ |
mbed_official | 157:90e3acc479a2 | 124 | void PWR_BackupAccessCmd(FunctionalState NewState) |
mbed_official | 157:90e3acc479a2 | 125 | { |
mbed_official | 157:90e3acc479a2 | 126 | /* Check the parameters */ |
mbed_official | 157:90e3acc479a2 | 127 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 157:90e3acc479a2 | 128 | *(__IO uint32_t *) CR_DBP_BB = (uint32_t)NewState; |
mbed_official | 157:90e3acc479a2 | 129 | } |
mbed_official | 157:90e3acc479a2 | 130 | |
mbed_official | 157:90e3acc479a2 | 131 | /** |
mbed_official | 157:90e3acc479a2 | 132 | * @} |
mbed_official | 157:90e3acc479a2 | 133 | */ |
mbed_official | 157:90e3acc479a2 | 134 | |
mbed_official | 157:90e3acc479a2 | 135 | /** @defgroup PWR_Group2 PVD configuration functions |
mbed_official | 157:90e3acc479a2 | 136 | * @brief PVD configuration functions |
mbed_official | 157:90e3acc479a2 | 137 | * |
mbed_official | 157:90e3acc479a2 | 138 | @verbatim |
mbed_official | 157:90e3acc479a2 | 139 | =============================================================================== |
mbed_official | 157:90e3acc479a2 | 140 | ##### PVD configuration functions ##### |
mbed_official | 157:90e3acc479a2 | 141 | ============================================================================== |
mbed_official | 157:90e3acc479a2 | 142 | [..] |
mbed_official | 157:90e3acc479a2 | 143 | (+) The PVD is used to monitor the VDD power supply by comparing it to a threshold |
mbed_official | 157:90e3acc479a2 | 144 | selected by the PVD Level (PLS[2:0] bits in the PWR_CR). |
mbed_official | 157:90e3acc479a2 | 145 | (+) A PVDO flag is available to indicate if VDD/VDDA is higher or lower than the |
mbed_official | 157:90e3acc479a2 | 146 | PVD threshold. This event is internally connected to the EXTI line16 |
mbed_official | 157:90e3acc479a2 | 147 | and can generate an interrupt if enabled through the EXTI registers. |
mbed_official | 157:90e3acc479a2 | 148 | (+) The PVD is stopped in Standby mode. |
mbed_official | 157:90e3acc479a2 | 149 | |
mbed_official | 157:90e3acc479a2 | 150 | @endverbatim |
mbed_official | 157:90e3acc479a2 | 151 | * @{ |
mbed_official | 157:90e3acc479a2 | 152 | */ |
mbed_official | 157:90e3acc479a2 | 153 | |
mbed_official | 157:90e3acc479a2 | 154 | /** |
mbed_official | 157:90e3acc479a2 | 155 | * @brief Configures the voltage threshold detected by the Power Voltage Detector(PVD). |
mbed_official | 157:90e3acc479a2 | 156 | * @param PWR_PVDLevel: specifies the PVD detection level |
mbed_official | 157:90e3acc479a2 | 157 | * This parameter can be one of the following values: |
mbed_official | 157:90e3acc479a2 | 158 | * @arg PWR_PVDLevel_0: PVD detection level set to 2.18V |
mbed_official | 157:90e3acc479a2 | 159 | * @arg PWR_PVDLevel_1: PVD detection level set to 2.28V |
mbed_official | 157:90e3acc479a2 | 160 | * @arg PWR_PVDLevel_2: PVD detection level set to 2.38V |
mbed_official | 157:90e3acc479a2 | 161 | * @arg PWR_PVDLevel_3: PVD detection level set to 2.48V |
mbed_official | 157:90e3acc479a2 | 162 | * @arg PWR_PVDLevel_4: PVD detection level set to 2.58V |
mbed_official | 157:90e3acc479a2 | 163 | * @arg PWR_PVDLevel_5: PVD detection level set to 2.68V |
mbed_official | 157:90e3acc479a2 | 164 | * @arg PWR_PVDLevel_6: PVD detection level set to 2.78V |
mbed_official | 157:90e3acc479a2 | 165 | * @arg PWR_PVDLevel_7: PVD detection level set to 2.88V |
mbed_official | 157:90e3acc479a2 | 166 | * @retval None |
mbed_official | 157:90e3acc479a2 | 167 | */ |
mbed_official | 157:90e3acc479a2 | 168 | void PWR_PVDLevelConfig(uint32_t PWR_PVDLevel) |
mbed_official | 157:90e3acc479a2 | 169 | { |
mbed_official | 157:90e3acc479a2 | 170 | uint32_t tmpreg = 0; |
mbed_official | 157:90e3acc479a2 | 171 | |
mbed_official | 157:90e3acc479a2 | 172 | /* Check the parameters */ |
mbed_official | 157:90e3acc479a2 | 173 | assert_param(IS_PWR_PVD_LEVEL(PWR_PVDLevel)); |
mbed_official | 157:90e3acc479a2 | 174 | |
mbed_official | 157:90e3acc479a2 | 175 | tmpreg = PWR->CR; |
mbed_official | 157:90e3acc479a2 | 176 | |
mbed_official | 157:90e3acc479a2 | 177 | /* Clear PLS[7:5] bits */ |
mbed_official | 157:90e3acc479a2 | 178 | tmpreg &= CR_PLS_MASK; |
mbed_official | 157:90e3acc479a2 | 179 | |
mbed_official | 157:90e3acc479a2 | 180 | /* Set PLS[7:5] bits according to PWR_PVDLevel value */ |
mbed_official | 157:90e3acc479a2 | 181 | tmpreg |= PWR_PVDLevel; |
mbed_official | 157:90e3acc479a2 | 182 | |
mbed_official | 157:90e3acc479a2 | 183 | /* Store the new value */ |
mbed_official | 157:90e3acc479a2 | 184 | PWR->CR = tmpreg; |
mbed_official | 157:90e3acc479a2 | 185 | } |
mbed_official | 157:90e3acc479a2 | 186 | |
mbed_official | 157:90e3acc479a2 | 187 | /** |
mbed_official | 157:90e3acc479a2 | 188 | * @brief Enables or disables the Power Voltage Detector(PVD). |
mbed_official | 157:90e3acc479a2 | 189 | * @param NewState: new state of the PVD. |
mbed_official | 157:90e3acc479a2 | 190 | * This parameter can be: ENABLE or DISABLE. |
mbed_official | 157:90e3acc479a2 | 191 | * @retval None |
mbed_official | 157:90e3acc479a2 | 192 | */ |
mbed_official | 157:90e3acc479a2 | 193 | void PWR_PVDCmd(FunctionalState NewState) |
mbed_official | 157:90e3acc479a2 | 194 | { |
mbed_official | 157:90e3acc479a2 | 195 | /* Check the parameters */ |
mbed_official | 157:90e3acc479a2 | 196 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 157:90e3acc479a2 | 197 | *(__IO uint32_t *) CR_PVDE_BB = (uint32_t)NewState; |
mbed_official | 157:90e3acc479a2 | 198 | } |
mbed_official | 157:90e3acc479a2 | 199 | |
mbed_official | 157:90e3acc479a2 | 200 | /** |
mbed_official | 157:90e3acc479a2 | 201 | * @} |
mbed_official | 157:90e3acc479a2 | 202 | */ |
mbed_official | 157:90e3acc479a2 | 203 | |
mbed_official | 157:90e3acc479a2 | 204 | /** @defgroup PWR_Group3 WakeUp pins configuration functions |
mbed_official | 157:90e3acc479a2 | 205 | * @brief WakeUp pins configuration functions |
mbed_official | 157:90e3acc479a2 | 206 | * |
mbed_official | 157:90e3acc479a2 | 207 | @verbatim |
mbed_official | 157:90e3acc479a2 | 208 | =============================================================================== |
mbed_official | 157:90e3acc479a2 | 209 | ##### WakeUp pins configuration functions ##### |
mbed_official | 157:90e3acc479a2 | 210 | =============================================================================== |
mbed_official | 157:90e3acc479a2 | 211 | [..] |
mbed_official | 157:90e3acc479a2 | 212 | (+) WakeUp pins are used to wakeup the system from Standby mode. These pins are |
mbed_official | 157:90e3acc479a2 | 213 | forced in input pull down configuration and are active on rising edges. |
mbed_official | 157:90e3acc479a2 | 214 | (+) There are three WakeUp pins: WakeUp Pin 1 on PA.00, WakeUp Pin 2 on PC.13 and |
mbed_official | 157:90e3acc479a2 | 215 | WakeUp Pin 3 on PE.06. |
mbed_official | 157:90e3acc479a2 | 216 | |
mbed_official | 157:90e3acc479a2 | 217 | @endverbatim |
mbed_official | 157:90e3acc479a2 | 218 | * @{ |
mbed_official | 157:90e3acc479a2 | 219 | */ |
mbed_official | 157:90e3acc479a2 | 220 | |
mbed_official | 157:90e3acc479a2 | 221 | /** |
mbed_official | 157:90e3acc479a2 | 222 | * @brief Enables or disables the WakeUp Pin functionality. |
mbed_official | 157:90e3acc479a2 | 223 | * @param PWR_WakeUpPin: specifies the WakeUpPin. |
mbed_official | 157:90e3acc479a2 | 224 | * This parameter can be: PWR_WakeUpPin_1, PWR_WakeUpPin_2 or PWR_WakeUpPin_3. |
mbed_official | 157:90e3acc479a2 | 225 | * @param NewState: new state of the WakeUp Pin functionality. |
mbed_official | 157:90e3acc479a2 | 226 | * This parameter can be: ENABLE or DISABLE. |
mbed_official | 157:90e3acc479a2 | 227 | * @retval None |
mbed_official | 157:90e3acc479a2 | 228 | */ |
mbed_official | 157:90e3acc479a2 | 229 | void PWR_WakeUpPinCmd(uint32_t PWR_WakeUpPin, FunctionalState NewState) |
mbed_official | 157:90e3acc479a2 | 230 | { |
mbed_official | 157:90e3acc479a2 | 231 | /* Check the parameters */ |
mbed_official | 157:90e3acc479a2 | 232 | assert_param(IS_PWR_WAKEUP_PIN(PWR_WakeUpPin)); |
mbed_official | 157:90e3acc479a2 | 233 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 157:90e3acc479a2 | 234 | |
mbed_official | 157:90e3acc479a2 | 235 | if (NewState != DISABLE) |
mbed_official | 157:90e3acc479a2 | 236 | { |
mbed_official | 157:90e3acc479a2 | 237 | /* Enable the EWUPx pin */ |
mbed_official | 157:90e3acc479a2 | 238 | PWR->CSR |= PWR_WakeUpPin; |
mbed_official | 157:90e3acc479a2 | 239 | } |
mbed_official | 157:90e3acc479a2 | 240 | else |
mbed_official | 157:90e3acc479a2 | 241 | { |
mbed_official | 157:90e3acc479a2 | 242 | /* Disable the EWUPx pin */ |
mbed_official | 157:90e3acc479a2 | 243 | PWR->CSR &= ~PWR_WakeUpPin; |
mbed_official | 157:90e3acc479a2 | 244 | } |
mbed_official | 157:90e3acc479a2 | 245 | } |
mbed_official | 157:90e3acc479a2 | 246 | |
mbed_official | 157:90e3acc479a2 | 247 | /** |
mbed_official | 157:90e3acc479a2 | 248 | * @} |
mbed_official | 157:90e3acc479a2 | 249 | */ |
mbed_official | 157:90e3acc479a2 | 250 | |
mbed_official | 157:90e3acc479a2 | 251 | |
mbed_official | 157:90e3acc479a2 | 252 | /** @defgroup PWR_Group4 Low Power modes configuration functions |
mbed_official | 157:90e3acc479a2 | 253 | * @brief Low Power modes configuration functions |
mbed_official | 157:90e3acc479a2 | 254 | * |
mbed_official | 157:90e3acc479a2 | 255 | @verbatim |
mbed_official | 157:90e3acc479a2 | 256 | =============================================================================== |
mbed_official | 157:90e3acc479a2 | 257 | ##### Low Power modes configuration functions ##### |
mbed_official | 157:90e3acc479a2 | 258 | ============================================================================== |
mbed_official | 157:90e3acc479a2 | 259 | |
mbed_official | 157:90e3acc479a2 | 260 | [..] The devices feature three low-power modes: |
mbed_official | 157:90e3acc479a2 | 261 | (+) Sleep mode: Cortex-M4 core stopped, peripherals kept running. |
mbed_official | 157:90e3acc479a2 | 262 | (+) Stop mode: all clocks are stopped, regulator running, regulator in low power mode |
mbed_official | 157:90e3acc479a2 | 263 | (+) Standby mode: VCORE domain powered off |
mbed_official | 157:90e3acc479a2 | 264 | |
mbed_official | 157:90e3acc479a2 | 265 | *** Sleep mode *** |
mbed_official | 157:90e3acc479a2 | 266 | ================== |
mbed_official | 157:90e3acc479a2 | 267 | [..] |
mbed_official | 157:90e3acc479a2 | 268 | (+) Entry: |
mbed_official | 157:90e3acc479a2 | 269 | (++) The Sleep mode is entered by executing the WFE() or WFI() instructions. |
mbed_official | 157:90e3acc479a2 | 270 | (+) Exit: |
mbed_official | 157:90e3acc479a2 | 271 | (++) Any peripheral interrupt acknowledged by the nested vectored interrupt |
mbed_official | 157:90e3acc479a2 | 272 | controller (NVIC) can wake up the device from Sleep mode. |
mbed_official | 157:90e3acc479a2 | 273 | |
mbed_official | 157:90e3acc479a2 | 274 | *** Stop mode *** |
mbed_official | 157:90e3acc479a2 | 275 | ================= |
mbed_official | 157:90e3acc479a2 | 276 | [..] In Stop mode, all clocks in the VCORE domain are stopped, the PLL, the HSI, |
mbed_official | 157:90e3acc479a2 | 277 | and the HSE RC oscillators are disabled. Internal SRAM and register |
mbed_official | 157:90e3acc479a2 | 278 | contents are preserved. |
mbed_official | 157:90e3acc479a2 | 279 | The voltage regulator can be configured either in normal or low-power mode. |
mbed_official | 157:90e3acc479a2 | 280 | |
mbed_official | 157:90e3acc479a2 | 281 | (+) Entry: |
mbed_official | 157:90e3acc479a2 | 282 | (++) The Stop mode is entered using the PWR_EnterSTOPMode(PWR_Regulator_LowPower,) |
mbed_official | 157:90e3acc479a2 | 283 | function with regulator in LowPower or with Regulator ON. |
mbed_official | 157:90e3acc479a2 | 284 | (+) Exit: |
mbed_official | 157:90e3acc479a2 | 285 | (++) Any EXTI Line (Internal or External) configured in Interrupt/Event mode |
mbed_official | 157:90e3acc479a2 | 286 | or any internal IPs (I2C or UASRT) wakeup event. |
mbed_official | 157:90e3acc479a2 | 287 | |
mbed_official | 157:90e3acc479a2 | 288 | *** Standby mode *** |
mbed_official | 157:90e3acc479a2 | 289 | ==================== |
mbed_official | 157:90e3acc479a2 | 290 | [..] The Standby mode allows to achieve the lowest power consumption. It is based |
mbed_official | 157:90e3acc479a2 | 291 | on the Cortex-M4 deepsleep mode, with the voltage regulator disabled. |
mbed_official | 157:90e3acc479a2 | 292 | The VCORE domain is consequently powered off. The PLL, the HSI, and the HSE |
mbed_official | 157:90e3acc479a2 | 293 | oscillator are also switched off. SRAM and register |
mbed_official | 157:90e3acc479a2 | 294 | contents are lost except for the Backup domain (RTC registers, RTC backup |
mbed_official | 157:90e3acc479a2 | 295 | registers and Standby circuitry). |
mbed_official | 157:90e3acc479a2 | 296 | |
mbed_official | 157:90e3acc479a2 | 297 | [..] The voltage regulator is OFF. |
mbed_official | 157:90e3acc479a2 | 298 | |
mbed_official | 157:90e3acc479a2 | 299 | (+) Entry: |
mbed_official | 157:90e3acc479a2 | 300 | (++) The Standby mode is entered using the PWR_EnterSTANDBYMode() function. |
mbed_official | 157:90e3acc479a2 | 301 | (+) Exit: |
mbed_official | 157:90e3acc479a2 | 302 | (++) WKUP pin rising edge, RTC alarm (Alarm A and Alarm B), RTC wakeup, |
mbed_official | 157:90e3acc479a2 | 303 | tamper event, time-stamp event, external reset in NRST pin, IWDG reset. |
mbed_official | 157:90e3acc479a2 | 304 | |
mbed_official | 157:90e3acc479a2 | 305 | *** Auto-wakeup (AWU) from low-power mode *** |
mbed_official | 157:90e3acc479a2 | 306 | ============================================= |
mbed_official | 157:90e3acc479a2 | 307 | [..] The MCU can be woken up from low-power mode by an RTC Alarm event, a tamper |
mbed_official | 157:90e3acc479a2 | 308 | event, a time-stamp event, or a comparator event, without depending on an |
mbed_official | 157:90e3acc479a2 | 309 | external interrupt (Auto-wakeup mode). |
mbed_official | 157:90e3acc479a2 | 310 | |
mbed_official | 157:90e3acc479a2 | 311 | (+) RTC auto-wakeup (AWU) from the Stop mode |
mbed_official | 157:90e3acc479a2 | 312 | (++) To wake up from the Stop mode with an RTC alarm event, it is necessary to: |
mbed_official | 157:90e3acc479a2 | 313 | (+++) Configure the EXTI Line 17 to be sensitive to rising edges (Interrupt |
mbed_official | 157:90e3acc479a2 | 314 | or Event modes) using the EXTI_Init() function. |
mbed_official | 157:90e3acc479a2 | 315 | (+++) Enable the RTC Alarm Interrupt using the RTC_ITConfig() function |
mbed_official | 157:90e3acc479a2 | 316 | (+++) Configure the RTC to generate the RTC alarm using the RTC_SetAlarm() |
mbed_official | 157:90e3acc479a2 | 317 | and RTC_AlarmCmd() functions. |
mbed_official | 157:90e3acc479a2 | 318 | (++) To wake up from the Stop mode with an RTC Tamper or time stamp event, it |
mbed_official | 157:90e3acc479a2 | 319 | is necessary to: |
mbed_official | 157:90e3acc479a2 | 320 | (+++) Configure the EXTI Line 19 to be sensitive to rising edges (Interrupt |
mbed_official | 157:90e3acc479a2 | 321 | or Event modes) using the EXTI_Init() function. |
mbed_official | 157:90e3acc479a2 | 322 | (+++) Enable the RTC Tamper or time stamp Interrupt using the RTC_ITConfig() |
mbed_official | 157:90e3acc479a2 | 323 | function. |
mbed_official | 157:90e3acc479a2 | 324 | (+++) Configure the RTC to detect the tamper or time stamp event using the |
mbed_official | 157:90e3acc479a2 | 325 | RTC_TimeStampConfig(), RTC_TamperTriggerConfig() and RTC_TamperCmd() |
mbed_official | 157:90e3acc479a2 | 326 | functions. |
mbed_official | 157:90e3acc479a2 | 327 | |
mbed_official | 157:90e3acc479a2 | 328 | (+) RTC auto-wakeup (AWU) from the Standby mode |
mbed_official | 157:90e3acc479a2 | 329 | (++) To wake up from the Standby mode with an RTC alarm event, it is necessary to: |
mbed_official | 157:90e3acc479a2 | 330 | (+++) Enable the RTC Alarm Interrupt using the RTC_ITConfig() function. |
mbed_official | 157:90e3acc479a2 | 331 | (+++) Configure the RTC to generate the RTC alarm using the RTC_SetAlarm() |
mbed_official | 157:90e3acc479a2 | 332 | and RTC_AlarmCmd() functions. |
mbed_official | 157:90e3acc479a2 | 333 | (++) To wake up from the Standby mode with an RTC Tamper or time stamp event, it |
mbed_official | 157:90e3acc479a2 | 334 | is necessary to: |
mbed_official | 157:90e3acc479a2 | 335 | (+++) Enable the RTC Tamper or time stamp Interrupt using the RTC_ITConfig() |
mbed_official | 157:90e3acc479a2 | 336 | function. |
mbed_official | 157:90e3acc479a2 | 337 | (+++) Configure the RTC to detect the tamper or time stamp event using the |
mbed_official | 157:90e3acc479a2 | 338 | RTC_TimeStampConfig(), RTC_TamperTriggerConfig() and RTC_TamperCmd() |
mbed_official | 157:90e3acc479a2 | 339 | functions. |
mbed_official | 157:90e3acc479a2 | 340 | |
mbed_official | 157:90e3acc479a2 | 341 | (+) Comparator auto-wakeup (AWU) from the Stop mode |
mbed_official | 157:90e3acc479a2 | 342 | (++) To wake up from the Stop mode with a comparator wakeup event, it is necessary to: |
mbed_official | 157:90e3acc479a2 | 343 | (+++) Configure the correspondant comparator EXTI Line to be sensitive to |
mbed_official | 157:90e3acc479a2 | 344 | the selected edges (falling, rising or falling and rising) |
mbed_official | 157:90e3acc479a2 | 345 | (Interrupt or Event modes) using the EXTI_Init() function. |
mbed_official | 157:90e3acc479a2 | 346 | (+++) Configure the comparator to generate the event. |
mbed_official | 157:90e3acc479a2 | 347 | |
mbed_official | 157:90e3acc479a2 | 348 | @endverbatim |
mbed_official | 157:90e3acc479a2 | 349 | * @{ |
mbed_official | 157:90e3acc479a2 | 350 | */ |
mbed_official | 157:90e3acc479a2 | 351 | |
mbed_official | 157:90e3acc479a2 | 352 | /** |
mbed_official | 157:90e3acc479a2 | 353 | * @brief Enters Sleep mode. |
mbed_official | 157:90e3acc479a2 | 354 | * @note In Sleep mode, all I/O pins keep the same state as in Run mode. |
mbed_official | 157:90e3acc479a2 | 355 | * @param PWR_SLEEPEntry: specifies if SLEEP mode in entered with WFI or WFE instruction. |
mbed_official | 157:90e3acc479a2 | 356 | * This parameter can be one of the following values: |
mbed_official | 157:90e3acc479a2 | 357 | * @arg PWR_SLEEPEntry_WFI: enter SLEEP mode with WFI instruction |
mbed_official | 157:90e3acc479a2 | 358 | * @arg PWR_SLEEPEntry_WFE: enter SLEEP mode with WFE instruction |
mbed_official | 157:90e3acc479a2 | 359 | * @retval None |
mbed_official | 157:90e3acc479a2 | 360 | */ |
mbed_official | 157:90e3acc479a2 | 361 | void PWR_EnterSleepMode(uint8_t PWR_SLEEPEntry) |
mbed_official | 157:90e3acc479a2 | 362 | { |
mbed_official | 157:90e3acc479a2 | 363 | /* Check the parameters */ |
mbed_official | 157:90e3acc479a2 | 364 | assert_param(IS_PWR_SLEEP_ENTRY(PWR_SLEEPEntry)); |
mbed_official | 157:90e3acc479a2 | 365 | |
mbed_official | 157:90e3acc479a2 | 366 | /* Clear SLEEPDEEP bit of Cortex System Control Register */ |
mbed_official | 157:90e3acc479a2 | 367 | SCB->SCR &= (uint32_t)~((uint32_t)SCB_SCR_SLEEPDEEP_Msk); |
mbed_official | 157:90e3acc479a2 | 368 | |
mbed_official | 157:90e3acc479a2 | 369 | /* Select SLEEP mode entry -------------------------------------------------*/ |
mbed_official | 157:90e3acc479a2 | 370 | if(PWR_SLEEPEntry == PWR_SLEEPEntry_WFI) |
mbed_official | 157:90e3acc479a2 | 371 | { |
mbed_official | 157:90e3acc479a2 | 372 | /* Request Wait For Interrupt */ |
mbed_official | 157:90e3acc479a2 | 373 | __WFI(); |
mbed_official | 157:90e3acc479a2 | 374 | } |
mbed_official | 157:90e3acc479a2 | 375 | else |
mbed_official | 157:90e3acc479a2 | 376 | { |
mbed_official | 157:90e3acc479a2 | 377 | /* Request Wait For Event */ |
mbed_official | 157:90e3acc479a2 | 378 | __WFE(); |
mbed_official | 157:90e3acc479a2 | 379 | } |
mbed_official | 157:90e3acc479a2 | 380 | } |
mbed_official | 157:90e3acc479a2 | 381 | |
mbed_official | 157:90e3acc479a2 | 382 | /** |
mbed_official | 157:90e3acc479a2 | 383 | * @brief Enters STOP mode. |
mbed_official | 157:90e3acc479a2 | 384 | * @note In Stop mode, all I/O pins keep the same state as in Run mode. |
mbed_official | 157:90e3acc479a2 | 385 | * @note When exiting Stop mode by issuing an interrupt or a wakeup event, |
mbed_official | 157:90e3acc479a2 | 386 | * the HSI RC oscillator is selected as system clock. |
mbed_official | 157:90e3acc479a2 | 387 | * @note When the voltage regulator operates in low power mode, an additional |
mbed_official | 157:90e3acc479a2 | 388 | * startup delay is incurred when waking up from Stop mode. |
mbed_official | 157:90e3acc479a2 | 389 | * By keeping the internal regulator ON during Stop mode, the consumption |
mbed_official | 157:90e3acc479a2 | 390 | * is higher although the startup time is reduced. |
mbed_official | 157:90e3acc479a2 | 391 | * @param PWR_Regulator: specifies the regulator state in STOP mode. |
mbed_official | 157:90e3acc479a2 | 392 | * This parameter can be one of the following values: |
mbed_official | 157:90e3acc479a2 | 393 | * @arg PWR_Regulator_ON: STOP mode with regulator ON |
mbed_official | 157:90e3acc479a2 | 394 | * @arg PWR_Regulator_LowPower: STOP mode with regulator in low power mode |
mbed_official | 157:90e3acc479a2 | 395 | * @param PWR_STOPEntry: specifies if STOP mode in entered with WFI or WFE instruction. |
mbed_official | 157:90e3acc479a2 | 396 | * This parameter can be one of the following values: |
mbed_official | 157:90e3acc479a2 | 397 | * @arg PWR_STOPEntry_WFI: enter STOP mode with WFI instruction |
mbed_official | 157:90e3acc479a2 | 398 | * @arg PWR_STOPEntry_WFE: enter STOP mode with WFE instruction |
mbed_official | 157:90e3acc479a2 | 399 | * @retval None |
mbed_official | 157:90e3acc479a2 | 400 | */ |
mbed_official | 157:90e3acc479a2 | 401 | void PWR_EnterSTOPMode(uint32_t PWR_Regulator, uint8_t PWR_STOPEntry) |
mbed_official | 157:90e3acc479a2 | 402 | { |
mbed_official | 157:90e3acc479a2 | 403 | uint32_t tmpreg = 0; |
mbed_official | 157:90e3acc479a2 | 404 | |
mbed_official | 157:90e3acc479a2 | 405 | /* Check the parameters */ |
mbed_official | 157:90e3acc479a2 | 406 | assert_param(IS_PWR_REGULATOR(PWR_Regulator)); |
mbed_official | 157:90e3acc479a2 | 407 | assert_param(IS_PWR_STOP_ENTRY(PWR_STOPEntry)); |
mbed_official | 157:90e3acc479a2 | 408 | |
mbed_official | 157:90e3acc479a2 | 409 | /* Select the regulator state in STOP mode ---------------------------------*/ |
mbed_official | 157:90e3acc479a2 | 410 | tmpreg = PWR->CR; |
mbed_official | 157:90e3acc479a2 | 411 | /* Clear PDDS and LPDSR bits */ |
mbed_official | 157:90e3acc479a2 | 412 | tmpreg &= CR_DS_MASK; |
mbed_official | 157:90e3acc479a2 | 413 | |
mbed_official | 157:90e3acc479a2 | 414 | /* Set LPDSR bit according to PWR_Regulator value */ |
mbed_official | 157:90e3acc479a2 | 415 | tmpreg |= PWR_Regulator; |
mbed_official | 157:90e3acc479a2 | 416 | |
mbed_official | 157:90e3acc479a2 | 417 | /* Store the new value */ |
mbed_official | 157:90e3acc479a2 | 418 | PWR->CR = tmpreg; |
mbed_official | 157:90e3acc479a2 | 419 | |
mbed_official | 157:90e3acc479a2 | 420 | /* Set SLEEPDEEP bit of Cortex System Control Register */ |
mbed_official | 157:90e3acc479a2 | 421 | SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk; |
mbed_official | 157:90e3acc479a2 | 422 | |
mbed_official | 157:90e3acc479a2 | 423 | /* Select STOP mode entry --------------------------------------------------*/ |
mbed_official | 157:90e3acc479a2 | 424 | if(PWR_STOPEntry == PWR_STOPEntry_WFI) |
mbed_official | 157:90e3acc479a2 | 425 | { |
mbed_official | 157:90e3acc479a2 | 426 | /* Request Wait For Interrupt */ |
mbed_official | 157:90e3acc479a2 | 427 | __WFI(); |
mbed_official | 157:90e3acc479a2 | 428 | } |
mbed_official | 157:90e3acc479a2 | 429 | else |
mbed_official | 157:90e3acc479a2 | 430 | { |
mbed_official | 157:90e3acc479a2 | 431 | /* Request Wait For Event */ |
mbed_official | 157:90e3acc479a2 | 432 | __WFE(); |
mbed_official | 157:90e3acc479a2 | 433 | } |
mbed_official | 157:90e3acc479a2 | 434 | /* Reset SLEEPDEEP bit of Cortex System Control Register */ |
mbed_official | 157:90e3acc479a2 | 435 | SCB->SCR &= (uint32_t)~((uint32_t)SCB_SCR_SLEEPDEEP_Msk); |
mbed_official | 157:90e3acc479a2 | 436 | } |
mbed_official | 157:90e3acc479a2 | 437 | |
mbed_official | 157:90e3acc479a2 | 438 | /** |
mbed_official | 157:90e3acc479a2 | 439 | * @brief Enters STANDBY mode. |
mbed_official | 157:90e3acc479a2 | 440 | * @note In Standby mode, all I/O pins are high impedance except for: |
mbed_official | 157:90e3acc479a2 | 441 | * @note Reset pad (still available) |
mbed_official | 157:90e3acc479a2 | 442 | * @note RTC_AF1 pin (PC13) if configured for Wakeup pin 2 (WKUP2), tamper, |
mbed_official | 157:90e3acc479a2 | 443 | * time-stamp, RTC Alarm out, or RTC clock calibration out. |
mbed_official | 157:90e3acc479a2 | 444 | * @note WKUP pin 1 (PA0) and WKUP pin 3 (PE6), if enabled. |
mbed_official | 157:90e3acc479a2 | 445 | * @param None |
mbed_official | 157:90e3acc479a2 | 446 | * @retval None |
mbed_official | 157:90e3acc479a2 | 447 | */ |
mbed_official | 157:90e3acc479a2 | 448 | void PWR_EnterSTANDBYMode(void) |
mbed_official | 157:90e3acc479a2 | 449 | { |
mbed_official | 157:90e3acc479a2 | 450 | /* Clear Wakeup flag */ |
mbed_official | 157:90e3acc479a2 | 451 | PWR->CR |= PWR_CR_CWUF; |
mbed_official | 157:90e3acc479a2 | 452 | |
mbed_official | 157:90e3acc479a2 | 453 | /* Select STANDBY mode */ |
mbed_official | 157:90e3acc479a2 | 454 | PWR->CR |= PWR_CR_PDDS; |
mbed_official | 157:90e3acc479a2 | 455 | |
mbed_official | 157:90e3acc479a2 | 456 | /* Set SLEEPDEEP bit of Cortex System Control Register */ |
mbed_official | 157:90e3acc479a2 | 457 | SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk; |
mbed_official | 157:90e3acc479a2 | 458 | |
mbed_official | 157:90e3acc479a2 | 459 | /* This option is used to ensure that store operations are completed */ |
mbed_official | 157:90e3acc479a2 | 460 | #if defined ( __CC_ARM ) |
mbed_official | 157:90e3acc479a2 | 461 | __force_stores(); |
mbed_official | 157:90e3acc479a2 | 462 | #endif |
mbed_official | 157:90e3acc479a2 | 463 | /* Request Wait For Interrupt */ |
mbed_official | 157:90e3acc479a2 | 464 | __WFI(); |
mbed_official | 157:90e3acc479a2 | 465 | } |
mbed_official | 157:90e3acc479a2 | 466 | |
mbed_official | 157:90e3acc479a2 | 467 | /** |
mbed_official | 157:90e3acc479a2 | 468 | * @} |
mbed_official | 157:90e3acc479a2 | 469 | */ |
mbed_official | 157:90e3acc479a2 | 470 | |
mbed_official | 157:90e3acc479a2 | 471 | /** @defgroup PWR_Group5 Flags management functions |
mbed_official | 157:90e3acc479a2 | 472 | * @brief Flags management functions |
mbed_official | 157:90e3acc479a2 | 473 | * |
mbed_official | 157:90e3acc479a2 | 474 | @verbatim |
mbed_official | 157:90e3acc479a2 | 475 | =============================================================================== |
mbed_official | 157:90e3acc479a2 | 476 | ##### Flags management functions ##### |
mbed_official | 157:90e3acc479a2 | 477 | =============================================================================== |
mbed_official | 157:90e3acc479a2 | 478 | |
mbed_official | 157:90e3acc479a2 | 479 | @endverbatim |
mbed_official | 157:90e3acc479a2 | 480 | * @{ |
mbed_official | 157:90e3acc479a2 | 481 | */ |
mbed_official | 157:90e3acc479a2 | 482 | |
mbed_official | 157:90e3acc479a2 | 483 | /** |
mbed_official | 157:90e3acc479a2 | 484 | * @brief Checks whether the specified PWR flag is set or not. |
mbed_official | 157:90e3acc479a2 | 485 | * @param PWR_FLAG: specifies the flag to check. |
mbed_official | 157:90e3acc479a2 | 486 | * This parameter can be one of the following values: |
mbed_official | 157:90e3acc479a2 | 487 | * @arg PWR_FLAG_WU: Wake Up flag. This flag indicates that a wakeup event |
mbed_official | 157:90e3acc479a2 | 488 | * was received from the WKUP pin or from the RTC alarm (Alarm A or Alarm B), |
mbed_official | 157:90e3acc479a2 | 489 | * RTC Tamper event, RTC TimeStamp event or RTC Wakeup. |
mbed_official | 157:90e3acc479a2 | 490 | * @arg PWR_FLAG_SB: StandBy flag. This flag indicates that the system was |
mbed_official | 157:90e3acc479a2 | 491 | * resumed from StandBy mode. |
mbed_official | 157:90e3acc479a2 | 492 | * @arg PWR_FLAG_PVDO: PVD Output. This flag is valid only if PVD is enabled |
mbed_official | 157:90e3acc479a2 | 493 | * by the PWR_PVDCmd() function. |
mbed_official | 157:90e3acc479a2 | 494 | * @arg PWR_FLAG_VREFINTRDY: Internal Voltage Reference Ready flag. This |
mbed_official | 157:90e3acc479a2 | 495 | * flag indicates the state of the internal voltage reference, VREFINT. |
mbed_official | 157:90e3acc479a2 | 496 | * @retval The new state of PWR_FLAG (SET or RESET). |
mbed_official | 157:90e3acc479a2 | 497 | */ |
mbed_official | 157:90e3acc479a2 | 498 | FlagStatus PWR_GetFlagStatus(uint32_t PWR_FLAG) |
mbed_official | 157:90e3acc479a2 | 499 | { |
mbed_official | 157:90e3acc479a2 | 500 | FlagStatus bitstatus = RESET; |
mbed_official | 157:90e3acc479a2 | 501 | /* Check the parameters */ |
mbed_official | 157:90e3acc479a2 | 502 | assert_param(IS_PWR_GET_FLAG(PWR_FLAG)); |
mbed_official | 157:90e3acc479a2 | 503 | |
mbed_official | 157:90e3acc479a2 | 504 | if ((PWR->CSR & PWR_FLAG) != (uint32_t)RESET) |
mbed_official | 157:90e3acc479a2 | 505 | { |
mbed_official | 157:90e3acc479a2 | 506 | bitstatus = SET; |
mbed_official | 157:90e3acc479a2 | 507 | } |
mbed_official | 157:90e3acc479a2 | 508 | else |
mbed_official | 157:90e3acc479a2 | 509 | { |
mbed_official | 157:90e3acc479a2 | 510 | bitstatus = RESET; |
mbed_official | 157:90e3acc479a2 | 511 | } |
mbed_official | 157:90e3acc479a2 | 512 | /* Return the flag status */ |
mbed_official | 157:90e3acc479a2 | 513 | return bitstatus; |
mbed_official | 157:90e3acc479a2 | 514 | } |
mbed_official | 157:90e3acc479a2 | 515 | |
mbed_official | 157:90e3acc479a2 | 516 | /** |
mbed_official | 157:90e3acc479a2 | 517 | * @brief Clears the PWR's pending flags. |
mbed_official | 157:90e3acc479a2 | 518 | * @param PWR_FLAG: specifies the flag to clear. |
mbed_official | 157:90e3acc479a2 | 519 | * This parameter can be one of the following values: |
mbed_official | 157:90e3acc479a2 | 520 | * @arg PWR_FLAG_WU: Wake Up flag |
mbed_official | 157:90e3acc479a2 | 521 | * @arg PWR_FLAG_SB: StandBy flag |
mbed_official | 157:90e3acc479a2 | 522 | * @retval None |
mbed_official | 157:90e3acc479a2 | 523 | */ |
mbed_official | 157:90e3acc479a2 | 524 | void PWR_ClearFlag(uint32_t PWR_FLAG) |
mbed_official | 157:90e3acc479a2 | 525 | { |
mbed_official | 157:90e3acc479a2 | 526 | /* Check the parameters */ |
mbed_official | 157:90e3acc479a2 | 527 | assert_param(IS_PWR_CLEAR_FLAG(PWR_FLAG)); |
mbed_official | 157:90e3acc479a2 | 528 | |
mbed_official | 157:90e3acc479a2 | 529 | PWR->CR |= PWR_FLAG << 2; |
mbed_official | 157:90e3acc479a2 | 530 | } |
mbed_official | 157:90e3acc479a2 | 531 | |
mbed_official | 157:90e3acc479a2 | 532 | /** |
mbed_official | 157:90e3acc479a2 | 533 | * @} |
mbed_official | 157:90e3acc479a2 | 534 | */ |
mbed_official | 157:90e3acc479a2 | 535 | |
mbed_official | 157:90e3acc479a2 | 536 | /** |
mbed_official | 157:90e3acc479a2 | 537 | * @} |
mbed_official | 157:90e3acc479a2 | 538 | */ |
mbed_official | 157:90e3acc479a2 | 539 | |
mbed_official | 157:90e3acc479a2 | 540 | /** |
mbed_official | 157:90e3acc479a2 | 541 | * @} |
mbed_official | 157:90e3acc479a2 | 542 | */ |
mbed_official | 157:90e3acc479a2 | 543 | |
mbed_official | 157:90e3acc479a2 | 544 | /** |
mbed_official | 157:90e3acc479a2 | 545 | * @} |
mbed_official | 157:90e3acc479a2 | 546 | */ |
mbed_official | 157:90e3acc479a2 | 547 | |
mbed_official | 157:90e3acc479a2 | 548 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |