mbed library sources modified for open wear
Dependents: openwear-lifelogger-example
Fork of mbed-src by
targets/cmsis/TARGET_STM/TARGET_DISCO_F100RB/stm32f10x_pwr.c@310:6188e0254baa, 2014-09-16 (annotated)
- Committer:
- janekm
- Date:
- Tue Sep 16 22:42:01 2014 +0000
- Revision:
- 310:6188e0254baa
- Parent:
- 126:549ba18ddd81
N/A
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbed_official | 126:549ba18ddd81 | 1 | /** |
mbed_official | 126:549ba18ddd81 | 2 | ****************************************************************************** |
mbed_official | 126:549ba18ddd81 | 3 | * @file stm32f10x_pwr.c |
mbed_official | 126:549ba18ddd81 | 4 | * @author MCD Application Team |
mbed_official | 126:549ba18ddd81 | 5 | * @version V3.6.1 |
mbed_official | 126:549ba18ddd81 | 6 | * @date 05-March-2012 |
mbed_official | 126:549ba18ddd81 | 7 | * @brief This file provides all the PWR firmware functions. |
mbed_official | 126:549ba18ddd81 | 8 | ******************************************************************************* |
mbed_official | 126:549ba18ddd81 | 9 | * Copyright (c) 2014, STMicroelectronics |
mbed_official | 126:549ba18ddd81 | 10 | * All rights reserved. |
mbed_official | 126:549ba18ddd81 | 11 | * |
mbed_official | 126:549ba18ddd81 | 12 | * Redistribution and use in source and binary forms, with or without |
mbed_official | 126:549ba18ddd81 | 13 | * modification, are permitted provided that the following conditions are met: |
mbed_official | 126:549ba18ddd81 | 14 | * |
mbed_official | 126:549ba18ddd81 | 15 | * 1. Redistributions of source code must retain the above copyright notice, |
mbed_official | 126:549ba18ddd81 | 16 | * this list of conditions and the following disclaimer. |
mbed_official | 126:549ba18ddd81 | 17 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
mbed_official | 126:549ba18ddd81 | 18 | * this list of conditions and the following disclaimer in the documentation |
mbed_official | 126:549ba18ddd81 | 19 | * and/or other materials provided with the distribution. |
mbed_official | 126:549ba18ddd81 | 20 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
mbed_official | 126:549ba18ddd81 | 21 | * may be used to endorse or promote products derived from this software |
mbed_official | 126:549ba18ddd81 | 22 | * without specific prior written permission. |
mbed_official | 126:549ba18ddd81 | 23 | * |
mbed_official | 126:549ba18ddd81 | 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
mbed_official | 126:549ba18ddd81 | 25 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
mbed_official | 126:549ba18ddd81 | 26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
mbed_official | 126:549ba18ddd81 | 27 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
mbed_official | 126:549ba18ddd81 | 28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
mbed_official | 126:549ba18ddd81 | 29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
mbed_official | 126:549ba18ddd81 | 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
mbed_official | 126:549ba18ddd81 | 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
mbed_official | 126:549ba18ddd81 | 32 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
mbed_official | 126:549ba18ddd81 | 33 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
mbed_official | 126:549ba18ddd81 | 34 | ******************************************************************************* |
mbed_official | 126:549ba18ddd81 | 35 | */ |
mbed_official | 126:549ba18ddd81 | 36 | |
mbed_official | 126:549ba18ddd81 | 37 | /* Includes ------------------------------------------------------------------*/ |
mbed_official | 126:549ba18ddd81 | 38 | #include "stm32f10x_pwr.h" |
mbed_official | 126:549ba18ddd81 | 39 | #include "stm32f10x_rcc.h" |
mbed_official | 126:549ba18ddd81 | 40 | |
mbed_official | 126:549ba18ddd81 | 41 | /** @addtogroup STM32F10x_StdPeriph_Driver |
mbed_official | 126:549ba18ddd81 | 42 | * @{ |
mbed_official | 126:549ba18ddd81 | 43 | */ |
mbed_official | 126:549ba18ddd81 | 44 | |
mbed_official | 126:549ba18ddd81 | 45 | /** @defgroup PWR |
mbed_official | 126:549ba18ddd81 | 46 | * @brief PWR driver modules |
mbed_official | 126:549ba18ddd81 | 47 | * @{ |
mbed_official | 126:549ba18ddd81 | 48 | */ |
mbed_official | 126:549ba18ddd81 | 49 | |
mbed_official | 126:549ba18ddd81 | 50 | /** @defgroup PWR_Private_TypesDefinitions |
mbed_official | 126:549ba18ddd81 | 51 | * @{ |
mbed_official | 126:549ba18ddd81 | 52 | */ |
mbed_official | 126:549ba18ddd81 | 53 | |
mbed_official | 126:549ba18ddd81 | 54 | /** |
mbed_official | 126:549ba18ddd81 | 55 | * @} |
mbed_official | 126:549ba18ddd81 | 56 | */ |
mbed_official | 126:549ba18ddd81 | 57 | |
mbed_official | 126:549ba18ddd81 | 58 | /** @defgroup PWR_Private_Defines |
mbed_official | 126:549ba18ddd81 | 59 | * @{ |
mbed_official | 126:549ba18ddd81 | 60 | */ |
mbed_official | 126:549ba18ddd81 | 61 | |
mbed_official | 126:549ba18ddd81 | 62 | /* --------- PWR registers bit address in the alias region ---------- */ |
mbed_official | 126:549ba18ddd81 | 63 | #define PWR_OFFSET (PWR_BASE - PERIPH_BASE) |
mbed_official | 126:549ba18ddd81 | 64 | |
mbed_official | 126:549ba18ddd81 | 65 | /* --- CR Register ---*/ |
mbed_official | 126:549ba18ddd81 | 66 | |
mbed_official | 126:549ba18ddd81 | 67 | /* Alias word address of DBP bit */ |
mbed_official | 126:549ba18ddd81 | 68 | #define CR_OFFSET (PWR_OFFSET + 0x00) |
mbed_official | 126:549ba18ddd81 | 69 | #define DBP_BitNumber 0x08 |
mbed_official | 126:549ba18ddd81 | 70 | #define CR_DBP_BB (PERIPH_BB_BASE + (CR_OFFSET * 32) + (DBP_BitNumber * 4)) |
mbed_official | 126:549ba18ddd81 | 71 | |
mbed_official | 126:549ba18ddd81 | 72 | /* Alias word address of PVDE bit */ |
mbed_official | 126:549ba18ddd81 | 73 | #define PVDE_BitNumber 0x04 |
mbed_official | 126:549ba18ddd81 | 74 | #define CR_PVDE_BB (PERIPH_BB_BASE + (CR_OFFSET * 32) + (PVDE_BitNumber * 4)) |
mbed_official | 126:549ba18ddd81 | 75 | |
mbed_official | 126:549ba18ddd81 | 76 | /* --- CSR Register ---*/ |
mbed_official | 126:549ba18ddd81 | 77 | |
mbed_official | 126:549ba18ddd81 | 78 | /* Alias word address of EWUP bit */ |
mbed_official | 126:549ba18ddd81 | 79 | #define CSR_OFFSET (PWR_OFFSET + 0x04) |
mbed_official | 126:549ba18ddd81 | 80 | #define EWUP_BitNumber 0x08 |
mbed_official | 126:549ba18ddd81 | 81 | #define CSR_EWUP_BB (PERIPH_BB_BASE + (CSR_OFFSET * 32) + (EWUP_BitNumber * 4)) |
mbed_official | 126:549ba18ddd81 | 82 | |
mbed_official | 126:549ba18ddd81 | 83 | /* ------------------ PWR registers bit mask ------------------------ */ |
mbed_official | 126:549ba18ddd81 | 84 | |
mbed_official | 126:549ba18ddd81 | 85 | /* CR register bit mask */ |
mbed_official | 126:549ba18ddd81 | 86 | #define CR_DS_MASK ((uint32_t)0xFFFFFFFC) |
mbed_official | 126:549ba18ddd81 | 87 | #define CR_PLS_MASK ((uint32_t)0xFFFFFF1F) |
mbed_official | 126:549ba18ddd81 | 88 | |
mbed_official | 126:549ba18ddd81 | 89 | |
mbed_official | 126:549ba18ddd81 | 90 | /** |
mbed_official | 126:549ba18ddd81 | 91 | * @} |
mbed_official | 126:549ba18ddd81 | 92 | */ |
mbed_official | 126:549ba18ddd81 | 93 | |
mbed_official | 126:549ba18ddd81 | 94 | /** @defgroup PWR_Private_Macros |
mbed_official | 126:549ba18ddd81 | 95 | * @{ |
mbed_official | 126:549ba18ddd81 | 96 | */ |
mbed_official | 126:549ba18ddd81 | 97 | |
mbed_official | 126:549ba18ddd81 | 98 | /** |
mbed_official | 126:549ba18ddd81 | 99 | * @} |
mbed_official | 126:549ba18ddd81 | 100 | */ |
mbed_official | 126:549ba18ddd81 | 101 | |
mbed_official | 126:549ba18ddd81 | 102 | /** @defgroup PWR_Private_Variables |
mbed_official | 126:549ba18ddd81 | 103 | * @{ |
mbed_official | 126:549ba18ddd81 | 104 | */ |
mbed_official | 126:549ba18ddd81 | 105 | |
mbed_official | 126:549ba18ddd81 | 106 | /** |
mbed_official | 126:549ba18ddd81 | 107 | * @} |
mbed_official | 126:549ba18ddd81 | 108 | */ |
mbed_official | 126:549ba18ddd81 | 109 | |
mbed_official | 126:549ba18ddd81 | 110 | /** @defgroup PWR_Private_FunctionPrototypes |
mbed_official | 126:549ba18ddd81 | 111 | * @{ |
mbed_official | 126:549ba18ddd81 | 112 | */ |
mbed_official | 126:549ba18ddd81 | 113 | |
mbed_official | 126:549ba18ddd81 | 114 | /** |
mbed_official | 126:549ba18ddd81 | 115 | * @} |
mbed_official | 126:549ba18ddd81 | 116 | */ |
mbed_official | 126:549ba18ddd81 | 117 | |
mbed_official | 126:549ba18ddd81 | 118 | /** @defgroup PWR_Private_Functions |
mbed_official | 126:549ba18ddd81 | 119 | * @{ |
mbed_official | 126:549ba18ddd81 | 120 | */ |
mbed_official | 126:549ba18ddd81 | 121 | |
mbed_official | 126:549ba18ddd81 | 122 | /** |
mbed_official | 126:549ba18ddd81 | 123 | * @brief Deinitializes the PWR peripheral registers to their default reset values. |
mbed_official | 126:549ba18ddd81 | 124 | * @param None |
mbed_official | 126:549ba18ddd81 | 125 | * @retval None |
mbed_official | 126:549ba18ddd81 | 126 | */ |
mbed_official | 126:549ba18ddd81 | 127 | void PWR_DeInit(void) |
mbed_official | 126:549ba18ddd81 | 128 | { |
mbed_official | 126:549ba18ddd81 | 129 | RCC_APB1PeriphResetCmd(RCC_APB1Periph_PWR, ENABLE); |
mbed_official | 126:549ba18ddd81 | 130 | RCC_APB1PeriphResetCmd(RCC_APB1Periph_PWR, DISABLE); |
mbed_official | 126:549ba18ddd81 | 131 | } |
mbed_official | 126:549ba18ddd81 | 132 | |
mbed_official | 126:549ba18ddd81 | 133 | /** |
mbed_official | 126:549ba18ddd81 | 134 | * @brief Enables or disables access to the RTC and backup registers. |
mbed_official | 126:549ba18ddd81 | 135 | * @param NewState: new state of the access to the RTC and backup registers. |
mbed_official | 126:549ba18ddd81 | 136 | * This parameter can be: ENABLE or DISABLE. |
mbed_official | 126:549ba18ddd81 | 137 | * @retval None |
mbed_official | 126:549ba18ddd81 | 138 | */ |
mbed_official | 126:549ba18ddd81 | 139 | void PWR_BackupAccessCmd(FunctionalState NewState) |
mbed_official | 126:549ba18ddd81 | 140 | { |
mbed_official | 126:549ba18ddd81 | 141 | /* Check the parameters */ |
mbed_official | 126:549ba18ddd81 | 142 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 126:549ba18ddd81 | 143 | *(__IO uint32_t *) CR_DBP_BB = (uint32_t)NewState; |
mbed_official | 126:549ba18ddd81 | 144 | } |
mbed_official | 126:549ba18ddd81 | 145 | |
mbed_official | 126:549ba18ddd81 | 146 | /** |
mbed_official | 126:549ba18ddd81 | 147 | * @brief Enables or disables the Power Voltage Detector(PVD). |
mbed_official | 126:549ba18ddd81 | 148 | * @param NewState: new state of the PVD. |
mbed_official | 126:549ba18ddd81 | 149 | * This parameter can be: ENABLE or DISABLE. |
mbed_official | 126:549ba18ddd81 | 150 | * @retval None |
mbed_official | 126:549ba18ddd81 | 151 | */ |
mbed_official | 126:549ba18ddd81 | 152 | void PWR_PVDCmd(FunctionalState NewState) |
mbed_official | 126:549ba18ddd81 | 153 | { |
mbed_official | 126:549ba18ddd81 | 154 | /* Check the parameters */ |
mbed_official | 126:549ba18ddd81 | 155 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 126:549ba18ddd81 | 156 | *(__IO uint32_t *) CR_PVDE_BB = (uint32_t)NewState; |
mbed_official | 126:549ba18ddd81 | 157 | } |
mbed_official | 126:549ba18ddd81 | 158 | |
mbed_official | 126:549ba18ddd81 | 159 | /** |
mbed_official | 126:549ba18ddd81 | 160 | * @brief Configures the voltage threshold detected by the Power Voltage Detector(PVD). |
mbed_official | 126:549ba18ddd81 | 161 | * @param PWR_PVDLevel: specifies the PVD detection level |
mbed_official | 126:549ba18ddd81 | 162 | * This parameter can be one of the following values: |
mbed_official | 126:549ba18ddd81 | 163 | * @arg PWR_PVDLevel_2V2: PVD detection level set to 2.2V |
mbed_official | 126:549ba18ddd81 | 164 | * @arg PWR_PVDLevel_2V3: PVD detection level set to 2.3V |
mbed_official | 126:549ba18ddd81 | 165 | * @arg PWR_PVDLevel_2V4: PVD detection level set to 2.4V |
mbed_official | 126:549ba18ddd81 | 166 | * @arg PWR_PVDLevel_2V5: PVD detection level set to 2.5V |
mbed_official | 126:549ba18ddd81 | 167 | * @arg PWR_PVDLevel_2V6: PVD detection level set to 2.6V |
mbed_official | 126:549ba18ddd81 | 168 | * @arg PWR_PVDLevel_2V7: PVD detection level set to 2.7V |
mbed_official | 126:549ba18ddd81 | 169 | * @arg PWR_PVDLevel_2V8: PVD detection level set to 2.8V |
mbed_official | 126:549ba18ddd81 | 170 | * @arg PWR_PVDLevel_2V9: PVD detection level set to 2.9V |
mbed_official | 126:549ba18ddd81 | 171 | * @retval None |
mbed_official | 126:549ba18ddd81 | 172 | */ |
mbed_official | 126:549ba18ddd81 | 173 | void PWR_PVDLevelConfig(uint32_t PWR_PVDLevel) |
mbed_official | 126:549ba18ddd81 | 174 | { |
mbed_official | 126:549ba18ddd81 | 175 | uint32_t tmpreg = 0; |
mbed_official | 126:549ba18ddd81 | 176 | /* Check the parameters */ |
mbed_official | 126:549ba18ddd81 | 177 | assert_param(IS_PWR_PVD_LEVEL(PWR_PVDLevel)); |
mbed_official | 126:549ba18ddd81 | 178 | tmpreg = PWR->CR; |
mbed_official | 126:549ba18ddd81 | 179 | /* Clear PLS[7:5] bits */ |
mbed_official | 126:549ba18ddd81 | 180 | tmpreg &= CR_PLS_MASK; |
mbed_official | 126:549ba18ddd81 | 181 | /* Set PLS[7:5] bits according to PWR_PVDLevel value */ |
mbed_official | 126:549ba18ddd81 | 182 | tmpreg |= PWR_PVDLevel; |
mbed_official | 126:549ba18ddd81 | 183 | /* Store the new value */ |
mbed_official | 126:549ba18ddd81 | 184 | PWR->CR = tmpreg; |
mbed_official | 126:549ba18ddd81 | 185 | } |
mbed_official | 126:549ba18ddd81 | 186 | |
mbed_official | 126:549ba18ddd81 | 187 | /** |
mbed_official | 126:549ba18ddd81 | 188 | * @brief Enables or disables the WakeUp Pin functionality. |
mbed_official | 126:549ba18ddd81 | 189 | * @param NewState: new state of the WakeUp Pin functionality. |
mbed_official | 126:549ba18ddd81 | 190 | * This parameter can be: ENABLE or DISABLE. |
mbed_official | 126:549ba18ddd81 | 191 | * @retval None |
mbed_official | 126:549ba18ddd81 | 192 | */ |
mbed_official | 126:549ba18ddd81 | 193 | void PWR_WakeUpPinCmd(FunctionalState NewState) |
mbed_official | 126:549ba18ddd81 | 194 | { |
mbed_official | 126:549ba18ddd81 | 195 | /* Check the parameters */ |
mbed_official | 126:549ba18ddd81 | 196 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 126:549ba18ddd81 | 197 | *(__IO uint32_t *) CSR_EWUP_BB = (uint32_t)NewState; |
mbed_official | 126:549ba18ddd81 | 198 | } |
mbed_official | 126:549ba18ddd81 | 199 | |
mbed_official | 126:549ba18ddd81 | 200 | /** |
mbed_official | 126:549ba18ddd81 | 201 | * @brief Enters STOP mode. |
mbed_official | 126:549ba18ddd81 | 202 | * @param PWR_Regulator: specifies the regulator state in STOP mode. |
mbed_official | 126:549ba18ddd81 | 203 | * This parameter can be one of the following values: |
mbed_official | 126:549ba18ddd81 | 204 | * @arg PWR_Regulator_ON: STOP mode with regulator ON |
mbed_official | 126:549ba18ddd81 | 205 | * @arg PWR_Regulator_LowPower: STOP mode with regulator in low power mode |
mbed_official | 126:549ba18ddd81 | 206 | * @param PWR_STOPEntry: specifies if STOP mode in entered with WFI or WFE instruction. |
mbed_official | 126:549ba18ddd81 | 207 | * This parameter can be one of the following values: |
mbed_official | 126:549ba18ddd81 | 208 | * @arg PWR_STOPEntry_WFI: enter STOP mode with WFI instruction |
mbed_official | 126:549ba18ddd81 | 209 | * @arg PWR_STOPEntry_WFE: enter STOP mode with WFE instruction |
mbed_official | 126:549ba18ddd81 | 210 | * @retval None |
mbed_official | 126:549ba18ddd81 | 211 | */ |
mbed_official | 126:549ba18ddd81 | 212 | void PWR_EnterSTOPMode(uint32_t PWR_Regulator, uint8_t PWR_STOPEntry) |
mbed_official | 126:549ba18ddd81 | 213 | { |
mbed_official | 126:549ba18ddd81 | 214 | uint32_t tmpreg = 0; |
mbed_official | 126:549ba18ddd81 | 215 | /* Check the parameters */ |
mbed_official | 126:549ba18ddd81 | 216 | assert_param(IS_PWR_REGULATOR(PWR_Regulator)); |
mbed_official | 126:549ba18ddd81 | 217 | assert_param(IS_PWR_STOP_ENTRY(PWR_STOPEntry)); |
mbed_official | 126:549ba18ddd81 | 218 | |
mbed_official | 126:549ba18ddd81 | 219 | /* Select the regulator state in STOP mode ---------------------------------*/ |
mbed_official | 126:549ba18ddd81 | 220 | tmpreg = PWR->CR; |
mbed_official | 126:549ba18ddd81 | 221 | /* Clear PDDS and LPDS bits */ |
mbed_official | 126:549ba18ddd81 | 222 | tmpreg &= CR_DS_MASK; |
mbed_official | 126:549ba18ddd81 | 223 | /* Set LPDS bit according to PWR_Regulator value */ |
mbed_official | 126:549ba18ddd81 | 224 | tmpreg |= PWR_Regulator; |
mbed_official | 126:549ba18ddd81 | 225 | /* Store the new value */ |
mbed_official | 126:549ba18ddd81 | 226 | PWR->CR = tmpreg; |
mbed_official | 126:549ba18ddd81 | 227 | /* Set SLEEPDEEP bit of Cortex System Control Register */ |
mbed_official | 126:549ba18ddd81 | 228 | SCB->SCR |= SCB_SCR_SLEEPDEEP; |
mbed_official | 126:549ba18ddd81 | 229 | |
mbed_official | 126:549ba18ddd81 | 230 | /* Select STOP mode entry --------------------------------------------------*/ |
mbed_official | 126:549ba18ddd81 | 231 | if(PWR_STOPEntry == PWR_STOPEntry_WFI) |
mbed_official | 126:549ba18ddd81 | 232 | { |
mbed_official | 126:549ba18ddd81 | 233 | /* Request Wait For Interrupt */ |
mbed_official | 126:549ba18ddd81 | 234 | __WFI(); |
mbed_official | 126:549ba18ddd81 | 235 | } |
mbed_official | 126:549ba18ddd81 | 236 | else |
mbed_official | 126:549ba18ddd81 | 237 | { |
mbed_official | 126:549ba18ddd81 | 238 | /* Request Wait For Event */ |
mbed_official | 126:549ba18ddd81 | 239 | __WFE(); |
mbed_official | 126:549ba18ddd81 | 240 | } |
mbed_official | 126:549ba18ddd81 | 241 | |
mbed_official | 126:549ba18ddd81 | 242 | /* Reset SLEEPDEEP bit of Cortex System Control Register */ |
mbed_official | 126:549ba18ddd81 | 243 | SCB->SCR &= (uint32_t)~((uint32_t)SCB_SCR_SLEEPDEEP); |
mbed_official | 126:549ba18ddd81 | 244 | } |
mbed_official | 126:549ba18ddd81 | 245 | |
mbed_official | 126:549ba18ddd81 | 246 | /** |
mbed_official | 126:549ba18ddd81 | 247 | * @brief Enters STANDBY mode. |
mbed_official | 126:549ba18ddd81 | 248 | * @param None |
mbed_official | 126:549ba18ddd81 | 249 | * @retval None |
mbed_official | 126:549ba18ddd81 | 250 | */ |
mbed_official | 126:549ba18ddd81 | 251 | void PWR_EnterSTANDBYMode(void) |
mbed_official | 126:549ba18ddd81 | 252 | { |
mbed_official | 126:549ba18ddd81 | 253 | /* Clear Wake-up flag */ |
mbed_official | 126:549ba18ddd81 | 254 | PWR->CR |= PWR_CR_CWUF; |
mbed_official | 126:549ba18ddd81 | 255 | /* Select STANDBY mode */ |
mbed_official | 126:549ba18ddd81 | 256 | PWR->CR |= PWR_CR_PDDS; |
mbed_official | 126:549ba18ddd81 | 257 | /* Set SLEEPDEEP bit of Cortex System Control Register */ |
mbed_official | 126:549ba18ddd81 | 258 | SCB->SCR |= SCB_SCR_SLEEPDEEP; |
mbed_official | 126:549ba18ddd81 | 259 | /* This option is used to ensure that store operations are completed */ |
mbed_official | 126:549ba18ddd81 | 260 | #if defined ( __CC_ARM ) |
mbed_official | 126:549ba18ddd81 | 261 | __force_stores(); |
mbed_official | 126:549ba18ddd81 | 262 | #endif |
mbed_official | 126:549ba18ddd81 | 263 | /* Request Wait For Interrupt */ |
mbed_official | 126:549ba18ddd81 | 264 | __WFI(); |
mbed_official | 126:549ba18ddd81 | 265 | } |
mbed_official | 126:549ba18ddd81 | 266 | |
mbed_official | 126:549ba18ddd81 | 267 | /** |
mbed_official | 126:549ba18ddd81 | 268 | * @brief Checks whether the specified PWR flag is set or not. |
mbed_official | 126:549ba18ddd81 | 269 | * @param PWR_FLAG: specifies the flag to check. |
mbed_official | 126:549ba18ddd81 | 270 | * This parameter can be one of the following values: |
mbed_official | 126:549ba18ddd81 | 271 | * @arg PWR_FLAG_WU: Wake Up flag |
mbed_official | 126:549ba18ddd81 | 272 | * @arg PWR_FLAG_SB: StandBy flag |
mbed_official | 126:549ba18ddd81 | 273 | * @arg PWR_FLAG_PVDO: PVD Output |
mbed_official | 126:549ba18ddd81 | 274 | * @retval The new state of PWR_FLAG (SET or RESET). |
mbed_official | 126:549ba18ddd81 | 275 | */ |
mbed_official | 126:549ba18ddd81 | 276 | FlagStatus PWR_GetFlagStatus(uint32_t PWR_FLAG) |
mbed_official | 126:549ba18ddd81 | 277 | { |
mbed_official | 126:549ba18ddd81 | 278 | FlagStatus bitstatus = RESET; |
mbed_official | 126:549ba18ddd81 | 279 | /* Check the parameters */ |
mbed_official | 126:549ba18ddd81 | 280 | assert_param(IS_PWR_GET_FLAG(PWR_FLAG)); |
mbed_official | 126:549ba18ddd81 | 281 | |
mbed_official | 126:549ba18ddd81 | 282 | if ((PWR->CSR & PWR_FLAG) != (uint32_t)RESET) |
mbed_official | 126:549ba18ddd81 | 283 | { |
mbed_official | 126:549ba18ddd81 | 284 | bitstatus = SET; |
mbed_official | 126:549ba18ddd81 | 285 | } |
mbed_official | 126:549ba18ddd81 | 286 | else |
mbed_official | 126:549ba18ddd81 | 287 | { |
mbed_official | 126:549ba18ddd81 | 288 | bitstatus = RESET; |
mbed_official | 126:549ba18ddd81 | 289 | } |
mbed_official | 126:549ba18ddd81 | 290 | /* Return the flag status */ |
mbed_official | 126:549ba18ddd81 | 291 | return bitstatus; |
mbed_official | 126:549ba18ddd81 | 292 | } |
mbed_official | 126:549ba18ddd81 | 293 | |
mbed_official | 126:549ba18ddd81 | 294 | /** |
mbed_official | 126:549ba18ddd81 | 295 | * @brief Clears the PWR's pending flags. |
mbed_official | 126:549ba18ddd81 | 296 | * @param PWR_FLAG: specifies the flag to clear. |
mbed_official | 126:549ba18ddd81 | 297 | * This parameter can be one of the following values: |
mbed_official | 126:549ba18ddd81 | 298 | * @arg PWR_FLAG_WU: Wake Up flag |
mbed_official | 126:549ba18ddd81 | 299 | * @arg PWR_FLAG_SB: StandBy flag |
mbed_official | 126:549ba18ddd81 | 300 | * @retval None |
mbed_official | 126:549ba18ddd81 | 301 | */ |
mbed_official | 126:549ba18ddd81 | 302 | void PWR_ClearFlag(uint32_t PWR_FLAG) |
mbed_official | 126:549ba18ddd81 | 303 | { |
mbed_official | 126:549ba18ddd81 | 304 | /* Check the parameters */ |
mbed_official | 126:549ba18ddd81 | 305 | assert_param(IS_PWR_CLEAR_FLAG(PWR_FLAG)); |
mbed_official | 126:549ba18ddd81 | 306 | |
mbed_official | 126:549ba18ddd81 | 307 | PWR->CR |= PWR_FLAG << 2; |
mbed_official | 126:549ba18ddd81 | 308 | } |
mbed_official | 126:549ba18ddd81 | 309 | |
mbed_official | 126:549ba18ddd81 | 310 | /** |
mbed_official | 126:549ba18ddd81 | 311 | * @} |
mbed_official | 126:549ba18ddd81 | 312 | */ |
mbed_official | 126:549ba18ddd81 | 313 | |
mbed_official | 126:549ba18ddd81 | 314 | /** |
mbed_official | 126:549ba18ddd81 | 315 | * @} |
mbed_official | 126:549ba18ddd81 | 316 | */ |
mbed_official | 126:549ba18ddd81 | 317 | |
mbed_official | 126:549ba18ddd81 | 318 | /** |
mbed_official | 126:549ba18ddd81 | 319 | * @} |
mbed_official | 126:549ba18ddd81 | 320 | */ |
mbed_official | 126:549ba18ddd81 | 321 | |
mbed_official | 126:549ba18ddd81 | 322 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |