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