mbed library sources

Dependents:   frdm_kl05z_gpio_test

Fork of mbed-src by mbed official

Committer:
shaoziyang
Date:
Sat Sep 13 14:25:46 2014 +0000
Revision:
323:9e901b0a5aa1
Parent:
237:f3da66175598
test with CLOCK_SETUP = 0

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 237:f3da66175598 1 /**
mbed_official 237:f3da66175598 2 ******************************************************************************
mbed_official 237:f3da66175598 3 * @file stm32f3xx_hal_pwr.h
mbed_official 237:f3da66175598 4 * @author MCD Application Team
mbed_official 237:f3da66175598 5 * @version V1.0.1
mbed_official 237:f3da66175598 6 * @date 18-June-2014
mbed_official 237:f3da66175598 7 * @brief Header file of PWR HAL module.
mbed_official 237:f3da66175598 8 ******************************************************************************
mbed_official 237:f3da66175598 9 * @attention
mbed_official 237:f3da66175598 10 *
mbed_official 237:f3da66175598 11 * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
mbed_official 237:f3da66175598 12 *
mbed_official 237:f3da66175598 13 * Redistribution and use in source and binary forms, with or without modification,
mbed_official 237:f3da66175598 14 * are permitted provided that the following conditions are met:
mbed_official 237:f3da66175598 15 * 1. Redistributions of source code must retain the above copyright notice,
mbed_official 237:f3da66175598 16 * this list of conditions and the following disclaimer.
mbed_official 237:f3da66175598 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
mbed_official 237:f3da66175598 18 * this list of conditions and the following disclaimer in the documentation
mbed_official 237:f3da66175598 19 * and/or other materials provided with the distribution.
mbed_official 237:f3da66175598 20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
mbed_official 237:f3da66175598 21 * may be used to endorse or promote products derived from this software
mbed_official 237:f3da66175598 22 * without specific prior written permission.
mbed_official 237:f3da66175598 23 *
mbed_official 237:f3da66175598 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
mbed_official 237:f3da66175598 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
mbed_official 237:f3da66175598 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
mbed_official 237:f3da66175598 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
mbed_official 237:f3da66175598 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
mbed_official 237:f3da66175598 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
mbed_official 237:f3da66175598 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
mbed_official 237:f3da66175598 31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
mbed_official 237:f3da66175598 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
mbed_official 237:f3da66175598 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
mbed_official 237:f3da66175598 34 *
mbed_official 237:f3da66175598 35 ******************************************************************************
mbed_official 237:f3da66175598 36 */
mbed_official 237:f3da66175598 37
mbed_official 237:f3da66175598 38 /* Define to prevent recursive inclusion -------------------------------------*/
mbed_official 237:f3da66175598 39 #ifndef __STM32F3xx_HAL_PWR_H
mbed_official 237:f3da66175598 40 #define __STM32F3xx_HAL_PWR_H
mbed_official 237:f3da66175598 41
mbed_official 237:f3da66175598 42 #ifdef __cplusplus
mbed_official 237:f3da66175598 43 extern "C" {
mbed_official 237:f3da66175598 44 #endif
mbed_official 237:f3da66175598 45
mbed_official 237:f3da66175598 46 /* Includes ------------------------------------------------------------------*/
mbed_official 237:f3da66175598 47 #include "stm32f3xx_hal_def.h"
mbed_official 237:f3da66175598 48
mbed_official 237:f3da66175598 49 /** @addtogroup STM32F3xx_HAL_Driver
mbed_official 237:f3da66175598 50 * @{
mbed_official 237:f3da66175598 51 */
mbed_official 237:f3da66175598 52
mbed_official 237:f3da66175598 53 /** @addtogroup PWR
mbed_official 237:f3da66175598 54 * @{
mbed_official 237:f3da66175598 55 */
mbed_official 237:f3da66175598 56
mbed_official 237:f3da66175598 57 /* Exported types ------------------------------------------------------------*/
mbed_official 237:f3da66175598 58 /* Exported constants --------------------------------------------------------*/
mbed_official 237:f3da66175598 59 /* ------------- PWR registers bit address in the alias region ---------------*/
mbed_official 237:f3da66175598 60 #define PWR_OFFSET (PWR_BASE - PERIPH_BASE)
mbed_official 237:f3da66175598 61
mbed_official 237:f3da66175598 62 /* --- CR Register ---*/
mbed_official 237:f3da66175598 63 #define CR_OFFSET (PWR_OFFSET + 0x00)
mbed_official 237:f3da66175598 64 /* Alias word address of DBP bit */
mbed_official 237:f3da66175598 65 #define DBP_BitNumber POSITION_VAL(PWR_CR_DBP)
mbed_official 237:f3da66175598 66 #define CR_DBP_BB (PERIPH_BB_BASE + (CR_OFFSET * 32) + (DBP_BitNumber * 4))
mbed_official 237:f3da66175598 67
mbed_official 237:f3da66175598 68 /* Alias word address of PVDE bit */
mbed_official 237:f3da66175598 69 #define PVDE_BitNumber POSITION_VAL(PWR_CR_PVDE)
mbed_official 237:f3da66175598 70 #define CR_PVDE_BB (PERIPH_BB_BASE + (CR_OFFSET * 32) + (PVDE_BitNumber * 4))
mbed_official 237:f3da66175598 71
mbed_official 237:f3da66175598 72 /* --- CSR Register ---*/
mbed_official 237:f3da66175598 73 #define CSR_OFFSET (PWR_OFFSET + 0x04)
mbed_official 237:f3da66175598 74 /* Alias word address of EWUP1 bit */
mbed_official 237:f3da66175598 75 #define EWUP1_BitNumber POSITION_VAL(PWR_CSR_EWUP1)
mbed_official 237:f3da66175598 76 #define CSR_EWUP1_BB (PERIPH_BB_BASE + (CSR_OFFSET * 32) + (EWUP1_BitNumber * 4))
mbed_official 237:f3da66175598 77
mbed_official 237:f3da66175598 78 /* Alias word address of EWUP2 bit */
mbed_official 237:f3da66175598 79 #define EWUP2_BitNumber POSITION_VAL(PWR_CSR_EWUP2)
mbed_official 237:f3da66175598 80 #define CSR_EWUP2_BB (PERIPH_BB_BASE + (CSR_OFFSET * 32) + (EWUP2_BitNumber * 4))
mbed_official 237:f3da66175598 81
mbed_official 237:f3da66175598 82 /* Alias word address of EWUP3 bit */
mbed_official 237:f3da66175598 83 #define EWUP3_BitNumber POSITION_VAL(PWR_CSR_EWUP3)
mbed_official 237:f3da66175598 84 #define CSR_EWUP3_BB (PERIPH_BB_BASE + (CSR_OFFSET * 32) + (EWUP3_BitNumber * 4))
mbed_official 237:f3da66175598 85
mbed_official 237:f3da66175598 86 /** @defgroup PWR_Exported_Constants
mbed_official 237:f3da66175598 87 * @{
mbed_official 237:f3da66175598 88 */
mbed_official 237:f3da66175598 89
mbed_official 237:f3da66175598 90 /** @defgroup PWR_WakeUp_Pins
mbed_official 237:f3da66175598 91 * @{
mbed_official 237:f3da66175598 92 */
mbed_official 237:f3da66175598 93
mbed_official 237:f3da66175598 94 #define PWR_WAKEUP_PIN1 ((uint32_t)0x00)
mbed_official 237:f3da66175598 95 #define PWR_WAKEUP_PIN2 ((uint32_t)0x01)
mbed_official 237:f3da66175598 96 #define PWR_WAKEUP_PIN3 ((uint32_t)0x02)
mbed_official 237:f3da66175598 97 #define IS_PWR_WAKEUP_PIN(PIN) (((PIN) == PWR_WAKEUP_PIN1) || \
mbed_official 237:f3da66175598 98 ((PIN) == PWR_WAKEUP_PIN2) || \
mbed_official 237:f3da66175598 99 ((PIN) == PWR_WAKEUP_PIN3))
mbed_official 237:f3da66175598 100 /**
mbed_official 237:f3da66175598 101 * @}
mbed_official 237:f3da66175598 102 */
mbed_official 237:f3da66175598 103
mbed_official 237:f3da66175598 104 /** @defgroup PWR_Regulator_state_in_STOP_mode
mbed_official 237:f3da66175598 105 * @{
mbed_official 237:f3da66175598 106 */
mbed_official 237:f3da66175598 107 #define PWR_MAINREGULATOR_ON ((uint32_t)0x00000000)
mbed_official 237:f3da66175598 108 #define PWR_LOWPOWERREGULATOR_ON PWR_CR_LPDS
mbed_official 237:f3da66175598 109
mbed_official 237:f3da66175598 110 #define IS_PWR_REGULATOR(REGULATOR) (((REGULATOR) == PWR_MAINREGULATOR_ON) || \
mbed_official 237:f3da66175598 111 ((REGULATOR) == PWR_LOWPOWERREGULATOR_ON))
mbed_official 237:f3da66175598 112 /**
mbed_official 237:f3da66175598 113 * @}
mbed_official 237:f3da66175598 114 */
mbed_official 237:f3da66175598 115
mbed_official 237:f3da66175598 116 /** @defgroup PWR_SLEEP_mode_entry
mbed_official 237:f3da66175598 117 * @{
mbed_official 237:f3da66175598 118 */
mbed_official 237:f3da66175598 119 #define PWR_SLEEPENTRY_WFI ((uint8_t)0x01)
mbed_official 237:f3da66175598 120 #define PWR_SLEEPENTRY_WFE ((uint8_t)0x02)
mbed_official 237:f3da66175598 121 #define IS_PWR_SLEEP_ENTRY(ENTRY) (((ENTRY) == PWR_SLEEPENTRY_WFI) || ((ENTRY) == PWR_SLEEPENTRY_WFE))
mbed_official 237:f3da66175598 122 /**
mbed_official 237:f3da66175598 123 * @}
mbed_official 237:f3da66175598 124 */
mbed_official 237:f3da66175598 125
mbed_official 237:f3da66175598 126 /** @defgroup PWR_STOP_mode_entry
mbed_official 237:f3da66175598 127 * @{
mbed_official 237:f3da66175598 128 */
mbed_official 237:f3da66175598 129 #define PWR_STOPENTRY_WFI ((uint8_t)0x01)
mbed_official 237:f3da66175598 130 #define PWR_STOPENTRY_WFE ((uint8_t)0x02)
mbed_official 237:f3da66175598 131 #define IS_PWR_STOP_ENTRY(ENTRY) (((ENTRY) == PWR_STOPENTRY_WFI) || ((ENTRY) == PWR_STOPENTRY_WFE))
mbed_official 237:f3da66175598 132 /**
mbed_official 237:f3da66175598 133 * @}
mbed_official 237:f3da66175598 134 */
mbed_official 237:f3da66175598 135
mbed_official 237:f3da66175598 136 /** @defgroup PWR_Flag
mbed_official 237:f3da66175598 137 * @{
mbed_official 237:f3da66175598 138 */
mbed_official 237:f3da66175598 139 #define PWR_FLAG_WU PWR_CSR_WUF
mbed_official 237:f3da66175598 140 #define PWR_FLAG_SB PWR_CSR_SBF
mbed_official 237:f3da66175598 141 #define PWR_FLAG_PVDO PWR_CSR_PVDO
mbed_official 237:f3da66175598 142 #define PWR_FLAG_VREFINTRDY PWR_CSR_VREFINTRDYF
mbed_official 237:f3da66175598 143 #define IS_PWR_GET_FLAG(FLAG) (((FLAG) == PWR_FLAG_WU) || ((FLAG) == PWR_FLAG_SB) || \
mbed_official 237:f3da66175598 144 ((FLAG) == PWR_FLAG_PVDO) || ((FLAG) == PWR_FLAG_VREFINTRDY))
mbed_official 237:f3da66175598 145
mbed_official 237:f3da66175598 146
mbed_official 237:f3da66175598 147 /**
mbed_official 237:f3da66175598 148 * @}
mbed_official 237:f3da66175598 149 */
mbed_official 237:f3da66175598 150
mbed_official 237:f3da66175598 151 /**
mbed_official 237:f3da66175598 152 * @}
mbed_official 237:f3da66175598 153 */
mbed_official 237:f3da66175598 154
mbed_official 237:f3da66175598 155 /* Exported macro ------------------------------------------------------------*/
mbed_official 237:f3da66175598 156 /** @defgroup PWR_Exported_Macro
mbed_official 237:f3da66175598 157 * @{
mbed_official 237:f3da66175598 158 */
mbed_official 237:f3da66175598 159
mbed_official 237:f3da66175598 160 /** @brief Check PWR flag is set or not.
mbed_official 237:f3da66175598 161 * @param __FLAG__: specifies the flag to check.
mbed_official 237:f3da66175598 162 * This parameter can be one of the following values:
mbed_official 237:f3da66175598 163 * @arg PWR_FLAG_WU: Wake Up flag. This flag indicates that a wakeup event
mbed_official 237:f3da66175598 164 * was received from the WKUP pin or from the RTC alarm (Alarm A
mbed_official 237:f3da66175598 165 * or Alarm B), RTC Tamper event, RTC TimeStamp event or RTC Wakeup.
mbed_official 237:f3da66175598 166 * An additional wakeup event is detected if the WKUP pin is enabled
mbed_official 237:f3da66175598 167 * (by setting the EWUP bit) when the WKUP pin level is already high.
mbed_official 237:f3da66175598 168 * @arg PWR_FLAG_SB: StandBy flag. This flag indicates that the system was
mbed_official 237:f3da66175598 169 * resumed from StandBy mode.
mbed_official 237:f3da66175598 170 * @arg PWR_FLAG_PVDO: PVD Output. This flag is valid only if PVD is enabled
mbed_official 237:f3da66175598 171 * by the HAL_PWR_EnablePVD() function. The PVD is stopped by Standby mode
mbed_official 237:f3da66175598 172 * For this reason, this bit is equal to 0 after Standby or reset
mbed_official 237:f3da66175598 173 * until the PVDE bit is set.
mbed_official 237:f3da66175598 174 * @arg PWR_FLAG_VREFINTRDY: This flag indicates that the internal reference
mbed_official 237:f3da66175598 175 * voltage VREFINT is ready.
mbed_official 237:f3da66175598 176 * @retval The new state of __FLAG__ (TRUE or FALSE).
mbed_official 237:f3da66175598 177 */
mbed_official 237:f3da66175598 178 #define __HAL_PWR_GET_FLAG(__FLAG__) ((PWR->CSR & (__FLAG__)) == (__FLAG__))
mbed_official 237:f3da66175598 179
mbed_official 237:f3da66175598 180 /** @brief Clear the PWR's pending flags.
mbed_official 237:f3da66175598 181 * @param __FLAG__: specifies the flag to clear.
mbed_official 237:f3da66175598 182 * This parameter can be one of the following values:
mbed_official 237:f3da66175598 183 * @arg PWR_FLAG_WU: Wake Up flag
mbed_official 237:f3da66175598 184 * @arg PWR_FLAG_SB: StandBy flag
mbed_official 237:f3da66175598 185 */
mbed_official 237:f3da66175598 186 #define __HAL_PWR_CLEAR_FLAG(__FLAG__) (PWR->CR |= (__FLAG__) << 2)
mbed_official 237:f3da66175598 187
mbed_official 237:f3da66175598 188 /**
mbed_official 237:f3da66175598 189 * @}
mbed_official 237:f3da66175598 190 */
mbed_official 237:f3da66175598 191
mbed_official 237:f3da66175598 192 /* Include PWR HAL Extension module */
mbed_official 237:f3da66175598 193 #include "stm32f3xx_hal_pwr_ex.h"
mbed_official 237:f3da66175598 194
mbed_official 237:f3da66175598 195 /* Exported functions --------------------------------------------------------*/
mbed_official 237:f3da66175598 196
mbed_official 237:f3da66175598 197 /* Initialization and de-initialization functions *****************************/
mbed_official 237:f3da66175598 198 void HAL_PWR_DeInit(void);
mbed_official 237:f3da66175598 199
mbed_official 237:f3da66175598 200 /* Peripheral Control functions **********************************************/
mbed_official 237:f3da66175598 201 void HAL_PWR_EnableBkUpAccess(void);
mbed_official 237:f3da66175598 202 void HAL_PWR_DisableBkUpAccess(void);
mbed_official 237:f3da66175598 203 void HAL_PWR_EnableWakeUpPin(uint32_t WakeUpPinx);
mbed_official 237:f3da66175598 204 void HAL_PWR_DisableWakeUpPin(uint32_t WakeUpPinx);
mbed_official 237:f3da66175598 205
mbed_official 237:f3da66175598 206 void HAL_PWR_EnterSTOPMode(uint32_t Regulator, uint8_t STOPEntry);
mbed_official 237:f3da66175598 207 void HAL_PWR_EnterSLEEPMode(uint32_t Regulator, uint8_t SLEEPEntry);
mbed_official 237:f3da66175598 208 void HAL_PWR_EnterSTANDBYMode(void);
mbed_official 237:f3da66175598 209
mbed_official 237:f3da66175598 210 /**
mbed_official 237:f3da66175598 211 * @}
mbed_official 237:f3da66175598 212 */
mbed_official 237:f3da66175598 213
mbed_official 237:f3da66175598 214 /**
mbed_official 237:f3da66175598 215 * @}
mbed_official 237:f3da66175598 216 */
mbed_official 237:f3da66175598 217
mbed_official 237:f3da66175598 218 #ifdef __cplusplus
mbed_official 237:f3da66175598 219 }
mbed_official 237:f3da66175598 220 #endif
mbed_official 237:f3da66175598 221
mbed_official 237:f3da66175598 222
mbed_official 237:f3da66175598 223 #endif /* __STM32F3xx_HAL_PWR_H */
mbed_official 237:f3da66175598 224
mbed_official 237:f3da66175598 225 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/