mbed library sources

Fork of mbed-src by mbed official

Committer:
mbed_official
Date:
Tue Jun 24 14:45:08 2014 +0100
Revision:
237:f3da66175598
Child:
375:3d36234a1087
Synchronized with git revision 8ef659bca81f12dfc896b5a7af7c2abbd1a1b8b7

Full URL: https://github.com/mbedmicro/mbed/commit/8ef659bca81f12dfc896b5a7af7c2abbd1a1b8b7/

[NUCLEO_F334R8] Add platform files

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_ex.c
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 Extended PWR HAL module driver.
mbed_official 237:f3da66175598 8 *
mbed_official 237:f3da66175598 9 * This file provides firmware functions to manage the following
mbed_official 237:f3da66175598 10 * functionalities of the Power Controller (PWR) peripheral:
mbed_official 237:f3da66175598 11 * + Extended Initialization and de-initialization functions
mbed_official 237:f3da66175598 12 * + Extended Peripheral Control functions
mbed_official 237:f3da66175598 13 *
mbed_official 237:f3da66175598 14 @verbatim
mbed_official 237:f3da66175598 15 ******************************************************************************
mbed_official 237:f3da66175598 16 * @attention
mbed_official 237:f3da66175598 17 *
mbed_official 237:f3da66175598 18 * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
mbed_official 237:f3da66175598 19 *
mbed_official 237:f3da66175598 20 * Redistribution and use in source and binary forms, with or without modification,
mbed_official 237:f3da66175598 21 * are permitted provided that the following conditions are met:
mbed_official 237:f3da66175598 22 * 1. Redistributions of source code must retain the above copyright notice,
mbed_official 237:f3da66175598 23 * this list of conditions and the following disclaimer.
mbed_official 237:f3da66175598 24 * 2. Redistributions in binary form must reproduce the above copyright notice,
mbed_official 237:f3da66175598 25 * this list of conditions and the following disclaimer in the documentation
mbed_official 237:f3da66175598 26 * and/or other materials provided with the distribution.
mbed_official 237:f3da66175598 27 * 3. Neither the name of STMicroelectronics nor the names of its contributors
mbed_official 237:f3da66175598 28 * may be used to endorse or promote products derived from this software
mbed_official 237:f3da66175598 29 * without specific prior written permission.
mbed_official 237:f3da66175598 30 *
mbed_official 237:f3da66175598 31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
mbed_official 237:f3da66175598 32 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
mbed_official 237:f3da66175598 33 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
mbed_official 237:f3da66175598 34 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
mbed_official 237:f3da66175598 35 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
mbed_official 237:f3da66175598 36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
mbed_official 237:f3da66175598 37 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
mbed_official 237:f3da66175598 38 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
mbed_official 237:f3da66175598 39 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
mbed_official 237:f3da66175598 40 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
mbed_official 237:f3da66175598 41 *
mbed_official 237:f3da66175598 42 ******************************************************************************
mbed_official 237:f3da66175598 43 */
mbed_official 237:f3da66175598 44
mbed_official 237:f3da66175598 45 /* Includes ------------------------------------------------------------------*/
mbed_official 237:f3da66175598 46 #include "stm32f3xx_hal.h"
mbed_official 237:f3da66175598 47
mbed_official 237:f3da66175598 48 /** @addtogroup STM32F3xx_HAL_Driver
mbed_official 237:f3da66175598 49 * @{
mbed_official 237:f3da66175598 50 */
mbed_official 237:f3da66175598 51
mbed_official 237:f3da66175598 52 /** @defgroup PWREx
mbed_official 237:f3da66175598 53 * @brief PWR Extended HAL module driver
mbed_official 237:f3da66175598 54 * @{
mbed_official 237:f3da66175598 55 */
mbed_official 237:f3da66175598 56
mbed_official 237:f3da66175598 57 #ifdef HAL_PWR_MODULE_ENABLED
mbed_official 237:f3da66175598 58
mbed_official 237:f3da66175598 59 /* Private typedef -----------------------------------------------------------*/
mbed_official 237:f3da66175598 60 /* Private define ------------------------------------------------------------*/
mbed_official 237:f3da66175598 61 /* Private macro -------------------------------------------------------------*/
mbed_official 237:f3da66175598 62 /* Private variables ---------------------------------------------------------*/
mbed_official 237:f3da66175598 63 /* Private function prototypes -----------------------------------------------*/
mbed_official 237:f3da66175598 64 /* Private functions ---------------------------------------------------------*/
mbed_official 237:f3da66175598 65
mbed_official 237:f3da66175598 66 /** @defgroup PWREx_Private_Functions
mbed_official 237:f3da66175598 67 * @{
mbed_official 237:f3da66175598 68 */
mbed_official 237:f3da66175598 69
mbed_official 237:f3da66175598 70 /** @defgroup PWREx_Group1 Extended Peripheral Initialization and de-initialization functions
mbed_official 237:f3da66175598 71 * @brief Extended Peripheral Initialization and de-initialization functions
mbed_official 237:f3da66175598 72 *
mbed_official 237:f3da66175598 73 @verbatim
mbed_official 237:f3da66175598 74 ===============================================================================
mbed_official 237:f3da66175598 75 ##### Extended Peripheral Initialization and de-initialization functions #####
mbed_official 237:f3da66175598 76 ===============================================================================
mbed_official 237:f3da66175598 77 [..]
mbed_official 237:f3da66175598 78
mbed_official 237:f3da66175598 79 @endverbatim
mbed_official 237:f3da66175598 80 * @{
mbed_official 237:f3da66175598 81 */
mbed_official 237:f3da66175598 82
mbed_official 237:f3da66175598 83 /**
mbed_official 237:f3da66175598 84 * @}
mbed_official 237:f3da66175598 85 */
mbed_official 237:f3da66175598 86
mbed_official 237:f3da66175598 87 /** @defgroup PWREx_Group2 Extended Peripheral Control functions
mbed_official 237:f3da66175598 88 * @brief Extended Peripheral Control functions
mbed_official 237:f3da66175598 89 *
mbed_official 237:f3da66175598 90 @verbatim
mbed_official 237:f3da66175598 91
mbed_official 237:f3da66175598 92 ===============================================================================
mbed_official 237:f3da66175598 93 ##### Extended Peripheral Control functions #####
mbed_official 237:f3da66175598 94 ===============================================================================
mbed_official 237:f3da66175598 95 [..]
mbed_official 237:f3da66175598 96 *** PVD configuration (present on all other devices than STM32F3x8 devices) ***
mbed_official 237:f3da66175598 97 =========================
mbed_official 237:f3da66175598 98 (+) The PVD is used to monitor the VDD power supply by comparing it to a
mbed_official 237:f3da66175598 99 threshold selected by the PVD Level (PLS[2:0] bits in the PWR_CR).
mbed_official 237:f3da66175598 100 (+) A PVDO flag is available to indicate if VDD/VDDA is higher or lower
mbed_official 237:f3da66175598 101 than the PVD threshold. This event is internally connected to the EXTI
mbed_official 237:f3da66175598 102 line16 and can generate an interrupt if enabled. This is done through
mbed_official 237:f3da66175598 103 __HAL_PVD_EXTI_ENABLE_IT() macro
mbed_official 237:f3da66175598 104 (+) The PVD is stopped in Standby mode.
mbed_official 237:f3da66175598 105 (+) Note: PVD is not available on STM32F3x8 Product Line
mbed_official 237:f3da66175598 106
mbed_official 237:f3da66175598 107
mbed_official 237:f3da66175598 108 *** Voltage regulator ***
mbed_official 237:f3da66175598 109 =========================
mbed_official 237:f3da66175598 110 (+) The voltage regulator is always enabled after Reset. It works in three different
mbed_official 237:f3da66175598 111 modes:
mbed_official 237:f3da66175598 112 In Run mode, the regulator supplies full power to the 1.8V domain (core, memories
mbed_official 237:f3da66175598 113 and digital peripherals).
mbed_official 237:f3da66175598 114 In Stop mode, the regulator supplies low power to the 1.8V domain, preserving
mbed_official 237:f3da66175598 115 contents of registers and SRAM.
mbed_official 237:f3da66175598 116 In Stop mode, the regulator is powered off. The contents of the registers and SRAM
mbed_official 237:f3da66175598 117 are lost except for the Standby circuitry and the Backup Domain.
mbed_official 237:f3da66175598 118 Note: In the STM32F3x8xx devices, the voltage regulator is bypassed and the
mbed_official 237:f3da66175598 119 microcontroller must be powered from a nominal VDD = 1.8V +/-8% voltage.
mbed_official 237:f3da66175598 120
mbed_official 237:f3da66175598 121
mbed_official 237:f3da66175598 122 (+) A PVDO flag is available to indicate if VDD/VDDA is higher or lower
mbed_official 237:f3da66175598 123 than the PVD threshold. This event is internally connected to the EXTI
mbed_official 237:f3da66175598 124 line16 and can generate an interrupt if enabled. This is done through
mbed_official 237:f3da66175598 125 __HAL_PVD_EXTI_ENABLE_IT() macro
mbed_official 237:f3da66175598 126 (+) The PVD is stopped in Standby mode.
mbed_official 237:f3da66175598 127
mbed_official 237:f3da66175598 128
mbed_official 237:f3da66175598 129 *** SDADC power configuration ***
mbed_official 237:f3da66175598 130 ================================
mbed_official 237:f3da66175598 131 (+) On STM32F373xC/STM32F378xx devices, there are up to
mbed_official 237:f3da66175598 132 3 SDADC instances that can be enabled/disabled.
mbed_official 237:f3da66175598 133
mbed_official 237:f3da66175598 134 @endverbatim
mbed_official 237:f3da66175598 135 * @{
mbed_official 237:f3da66175598 136 */
mbed_official 237:f3da66175598 137
mbed_official 237:f3da66175598 138 #if defined(STM32F301x8) || \
mbed_official 237:f3da66175598 139 defined(STM32F302x8) || defined(STM32F302xC) || \
mbed_official 237:f3da66175598 140 defined(STM32F303x8) || defined(STM32F303xC) || defined(STM32F373xC) || \
mbed_official 237:f3da66175598 141 defined(STM32F334x8)
mbed_official 237:f3da66175598 142
mbed_official 237:f3da66175598 143 /**
mbed_official 237:f3da66175598 144 * @brief Configures the voltage threshold detected by the Power Voltage Detector(PVD).
mbed_official 237:f3da66175598 145 * @param sConfigPVD: pointer to an PWR_PVDTypeDef structure that contains the configuration
mbed_official 237:f3da66175598 146 * information for the PVD.
mbed_official 237:f3da66175598 147 * @note Refer to the electrical characteristics of your device datasheet for
mbed_official 237:f3da66175598 148 * more details about the voltage threshold corresponding to each
mbed_official 237:f3da66175598 149 * detection level.
mbed_official 237:f3da66175598 150 * @retval None
mbed_official 237:f3da66175598 151 */
mbed_official 237:f3da66175598 152 void HAL_PWR_PVDConfig(PWR_PVDTypeDef *sConfigPVD)
mbed_official 237:f3da66175598 153 {
mbed_official 237:f3da66175598 154 /* Check the parameters */
mbed_official 237:f3da66175598 155 assert_param(IS_PWR_PVD_LEVEL(sConfigPVD->PVDLevel));
mbed_official 237:f3da66175598 156 assert_param(IS_PWR_PVD_MODE(sConfigPVD->Mode));
mbed_official 237:f3da66175598 157
mbed_official 237:f3da66175598 158 /* Set PLS[7:5] bits according to PVDLevel value */
mbed_official 237:f3da66175598 159 MODIFY_REG(PWR->CR, PWR_CR_PLS, sConfigPVD->PVDLevel);
mbed_official 237:f3da66175598 160
mbed_official 237:f3da66175598 161 /* Configure the EXTI 16 interrupt */
mbed_official 237:f3da66175598 162 if((sConfigPVD->Mode == PWR_MODE_IT_RISING_FALLING) ||\
mbed_official 237:f3da66175598 163 (sConfigPVD->Mode == PWR_MODE_IT_FALLING) ||\
mbed_official 237:f3da66175598 164 (sConfigPVD->Mode == PWR_MODE_IT_RISING))
mbed_official 237:f3da66175598 165 {
mbed_official 237:f3da66175598 166 __HAL_PVD_EXTI_ENABLE_IT(PWR_EXTI_LINE_PVD);
mbed_official 237:f3da66175598 167 }
mbed_official 237:f3da66175598 168 /* Configure the rising edge */
mbed_official 237:f3da66175598 169 if((sConfigPVD->Mode == PWR_MODE_IT_RISING_FALLING) ||\
mbed_official 237:f3da66175598 170 (sConfigPVD->Mode == PWR_MODE_IT_RISING))
mbed_official 237:f3da66175598 171 {
mbed_official 237:f3da66175598 172 EXTI->RTSR |= PWR_EXTI_LINE_PVD;
mbed_official 237:f3da66175598 173 }
mbed_official 237:f3da66175598 174 /* Configure the falling edge */
mbed_official 237:f3da66175598 175 if((sConfigPVD->Mode == PWR_MODE_IT_RISING_FALLING) ||\
mbed_official 237:f3da66175598 176 (sConfigPVD->Mode == PWR_MODE_IT_FALLING))
mbed_official 237:f3da66175598 177 {
mbed_official 237:f3da66175598 178 EXTI->FTSR |= PWR_EXTI_LINE_PVD;
mbed_official 237:f3da66175598 179 }
mbed_official 237:f3da66175598 180 }
mbed_official 237:f3da66175598 181
mbed_official 237:f3da66175598 182 /**
mbed_official 237:f3da66175598 183 * @brief Enables the Power Voltage Detector(PVD).
mbed_official 237:f3da66175598 184 * @param None
mbed_official 237:f3da66175598 185 * @retval None
mbed_official 237:f3da66175598 186 */
mbed_official 237:f3da66175598 187 void HAL_PWR_EnablePVD(void)
mbed_official 237:f3da66175598 188 {
mbed_official 237:f3da66175598 189 *(__IO uint32_t *) CR_PVDE_BB = (uint32_t)ENABLE;
mbed_official 237:f3da66175598 190 }
mbed_official 237:f3da66175598 191
mbed_official 237:f3da66175598 192 /**
mbed_official 237:f3da66175598 193 * @brief Disables the Power Voltage Detector(PVD).
mbed_official 237:f3da66175598 194 * @param None
mbed_official 237:f3da66175598 195 * @retval None
mbed_official 237:f3da66175598 196 */
mbed_official 237:f3da66175598 197 void HAL_PWR_DisablePVD(void)
mbed_official 237:f3da66175598 198 {
mbed_official 237:f3da66175598 199 *(__IO uint32_t *) CR_PVDE_BB = (uint32_t)DISABLE;
mbed_official 237:f3da66175598 200 }
mbed_official 237:f3da66175598 201
mbed_official 237:f3da66175598 202 /**
mbed_official 237:f3da66175598 203 * @brief This function handles the PWR PVD interrupt request.
mbed_official 237:f3da66175598 204 * @note This API should be called under the PVD_IRQHandler().
mbed_official 237:f3da66175598 205 * @param None
mbed_official 237:f3da66175598 206 * @retval None
mbed_official 237:f3da66175598 207 */
mbed_official 237:f3da66175598 208 void HAL_PWR_PVD_IRQHandler(void)
mbed_official 237:f3da66175598 209 {
mbed_official 237:f3da66175598 210 /* Check PWR exti flag */
mbed_official 237:f3da66175598 211 if(__HAL_PVD_EXTI_GET_FLAG(PWR_EXTI_LINE_PVD) != RESET)
mbed_official 237:f3da66175598 212 {
mbed_official 237:f3da66175598 213 /* PWR PVD interrupt user callback */
mbed_official 237:f3da66175598 214 HAL_PWR_PVDCallback();
mbed_official 237:f3da66175598 215
mbed_official 237:f3da66175598 216 /* Clear PWR Exti pending bit */
mbed_official 237:f3da66175598 217 __HAL_PVD_EXTI_CLEAR_FLAG(PWR_EXTI_LINE_PVD);
mbed_official 237:f3da66175598 218 }
mbed_official 237:f3da66175598 219 }
mbed_official 237:f3da66175598 220
mbed_official 237:f3da66175598 221 /**
mbed_official 237:f3da66175598 222 * @brief PWR PVD interrupt callback
mbed_official 237:f3da66175598 223 * @param None
mbed_official 237:f3da66175598 224 * @retval None
mbed_official 237:f3da66175598 225 */
mbed_official 237:f3da66175598 226 __weak void HAL_PWR_PVDCallback(void)
mbed_official 237:f3da66175598 227 {
mbed_official 237:f3da66175598 228 /* NOTE : This function Should not be modified, when the callback is needed,
mbed_official 237:f3da66175598 229 the HAL_PWR_PVDCallback could be implemented in the user file
mbed_official 237:f3da66175598 230 */
mbed_official 237:f3da66175598 231 }
mbed_official 237:f3da66175598 232
mbed_official 237:f3da66175598 233 #endif /* STM32F301x8 || STM32F302x8 || STM32F302xC || */
mbed_official 237:f3da66175598 234 /* STM32F303x8 || STM32F303xC */
mbed_official 237:f3da66175598 235 /* STM32F373xC || STM32F334x8 */
mbed_official 237:f3da66175598 236
mbed_official 237:f3da66175598 237 #if defined(STM32F373xC) || defined(STM32F378xx)
mbed_official 237:f3da66175598 238
mbed_official 237:f3da66175598 239 /**
mbed_official 237:f3da66175598 240 * @brief Enables the SDADC peripheral functionaliy
mbed_official 237:f3da66175598 241 * @param Analogx: specifies the SDADC peripheral instance.
mbed_official 237:f3da66175598 242 * This parameter can be: PWR_SDADC_ANALOG1, PWR_SDADC_ANALOG2 or PWR_SDADC_ANALOG3.
mbed_official 237:f3da66175598 243 * @retval None
mbed_official 237:f3da66175598 244 */
mbed_official 237:f3da66175598 245 void HAL_PWREx_EnableSDADCAnalog(uint32_t Analogx)
mbed_official 237:f3da66175598 246 {
mbed_official 237:f3da66175598 247 /* Check the parameters */
mbed_official 237:f3da66175598 248 assert_param(IS_PWR_SDADC_ANALOG(Analogx));
mbed_official 237:f3da66175598 249
mbed_official 237:f3da66175598 250 /* Enable PWR clock interface for SDADC use */
mbed_official 237:f3da66175598 251 __PWR_CLK_ENABLE();
mbed_official 237:f3da66175598 252
mbed_official 237:f3da66175598 253 PWR->CR |= Analogx;
mbed_official 237:f3da66175598 254 }
mbed_official 237:f3da66175598 255
mbed_official 237:f3da66175598 256 /**
mbed_official 237:f3da66175598 257 * @brief Disables the SDADC peripheral functionaliy
mbed_official 237:f3da66175598 258 * @param Analogx: specifies the SDADC peripheral instance.
mbed_official 237:f3da66175598 259 * This parameter can be: PWR_SDADC_ANALOG1, PWR_SDADC_ANALOG2 or PWR_SDADC_ANALOG3.
mbed_official 237:f3da66175598 260 * @retval None
mbed_official 237:f3da66175598 261 */
mbed_official 237:f3da66175598 262 void HAL_PWREx_DisableSDADCAnalog(uint32_t Analogx)
mbed_official 237:f3da66175598 263 {
mbed_official 237:f3da66175598 264 /* Check the parameters */
mbed_official 237:f3da66175598 265 assert_param(IS_PWR_SDADC_ANALOG(Analogx));
mbed_official 237:f3da66175598 266
mbed_official 237:f3da66175598 267 PWR->CR &= ~Analogx;
mbed_official 237:f3da66175598 268 }
mbed_official 237:f3da66175598 269
mbed_official 237:f3da66175598 270 #endif /* STM32F373xC || STM32F378xx */
mbed_official 237:f3da66175598 271
mbed_official 237:f3da66175598 272 /**
mbed_official 237:f3da66175598 273 * @}
mbed_official 237:f3da66175598 274 */
mbed_official 237:f3da66175598 275
mbed_official 237:f3da66175598 276 /**
mbed_official 237:f3da66175598 277 * @}
mbed_official 237:f3da66175598 278 */
mbed_official 237:f3da66175598 279
mbed_official 237:f3da66175598 280 #endif /* HAL_PWR_MODULE_ENABLED */
mbed_official 237:f3da66175598 281 /**
mbed_official 237:f3da66175598 282 * @}
mbed_official 237:f3da66175598 283 */
mbed_official 237:f3da66175598 284
mbed_official 237:f3da66175598 285 /**
mbed_official 237:f3da66175598 286 * @}
mbed_official 237:f3da66175598 287 */
mbed_official 237:f3da66175598 288
mbed_official 237:f3da66175598 289 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/