mbed w/ spi bug fig

Dependents:   display-puck

Fork of mbed-src by mbed official

Committer:
mbed_official
Date:
Thu May 22 20:00:09 2014 +0100
Revision:
205:c41fc65bcfb4
Child:
218:44081b78fdc2
Synchronized with git revision ea4b6f76efab17a3f7d7777b0cc1ef05fec6d1cb

Full URL: https://github.com/mbedmicro/mbed/commit/ea4b6f76efab17a3f7d7777b0cc1ef05fec6d1cb/

[NUCLEO_F072RB] cmsis files

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 205:c41fc65bcfb4 1 /**
mbed_official 205:c41fc65bcfb4 2 ******************************************************************************
mbed_official 205:c41fc65bcfb4 3 * @file stm32f0xx_hal_pwr_ex.c
mbed_official 205:c41fc65bcfb4 4 * @author MCD Application Team
mbed_official 205:c41fc65bcfb4 5 * @version V1.0.0
mbed_official 205:c41fc65bcfb4 6 * @date 20-May-2014
mbed_official 205:c41fc65bcfb4 7 * @brief Extended PWR HAL module driver.
mbed_official 205:c41fc65bcfb4 8 *
mbed_official 205:c41fc65bcfb4 9 * This file provides firmware functions to manage the following
mbed_official 205:c41fc65bcfb4 10 * functionalities of the Power Controller (PWR) peripheral:
mbed_official 205:c41fc65bcfb4 11 * + Extended Initialization and de-initialization function
mbed_official 205:c41fc65bcfb4 12 * + Extended Peripheral Control function
mbed_official 205:c41fc65bcfb4 13 *
mbed_official 205:c41fc65bcfb4 14 @verbatim
mbed_official 205:c41fc65bcfb4 15 ******************************************************************************
mbed_official 205:c41fc65bcfb4 16 * @attention
mbed_official 205:c41fc65bcfb4 17 *
mbed_official 205:c41fc65bcfb4 18 * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
mbed_official 205:c41fc65bcfb4 19 *
mbed_official 205:c41fc65bcfb4 20 * Redistribution and use in source and binary forms, with or without modification,
mbed_official 205:c41fc65bcfb4 21 * are permitted provided that the following conditions are met:
mbed_official 205:c41fc65bcfb4 22 * 1. Redistributions of source code must retain the above copyright notice,
mbed_official 205:c41fc65bcfb4 23 * this list of conditions and the following disclaimer.
mbed_official 205:c41fc65bcfb4 24 * 2. Redistributions in binary form must reproduce the above copyright notice,
mbed_official 205:c41fc65bcfb4 25 * this list of conditions and the following disclaimer in the documentation
mbed_official 205:c41fc65bcfb4 26 * and/or other materials provided with the distribution.
mbed_official 205:c41fc65bcfb4 27 * 3. Neither the name of STMicroelectronics nor the names of its contributors
mbed_official 205:c41fc65bcfb4 28 * may be used to endorse or promote products derived from this software
mbed_official 205:c41fc65bcfb4 29 * without specific prior written permission.
mbed_official 205:c41fc65bcfb4 30 *
mbed_official 205:c41fc65bcfb4 31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
mbed_official 205:c41fc65bcfb4 32 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
mbed_official 205:c41fc65bcfb4 33 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
mbed_official 205:c41fc65bcfb4 34 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
mbed_official 205:c41fc65bcfb4 35 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
mbed_official 205:c41fc65bcfb4 36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
mbed_official 205:c41fc65bcfb4 37 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
mbed_official 205:c41fc65bcfb4 38 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
mbed_official 205:c41fc65bcfb4 39 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
mbed_official 205:c41fc65bcfb4 40 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
mbed_official 205:c41fc65bcfb4 41 *
mbed_official 205:c41fc65bcfb4 42 ******************************************************************************
mbed_official 205:c41fc65bcfb4 43 */
mbed_official 205:c41fc65bcfb4 44
mbed_official 205:c41fc65bcfb4 45 /* Includes ------------------------------------------------------------------*/
mbed_official 205:c41fc65bcfb4 46 #include "stm32f0xx_hal.h"
mbed_official 205:c41fc65bcfb4 47
mbed_official 205:c41fc65bcfb4 48 /** @addtogroup STM32F0xx_HAL_Driver
mbed_official 205:c41fc65bcfb4 49 * @{
mbed_official 205:c41fc65bcfb4 50 */
mbed_official 205:c41fc65bcfb4 51
mbed_official 205:c41fc65bcfb4 52 /** @defgroup PWREx
mbed_official 205:c41fc65bcfb4 53 * @brief PWR Extended HAL module driver
mbed_official 205:c41fc65bcfb4 54 * @{
mbed_official 205:c41fc65bcfb4 55 */
mbed_official 205:c41fc65bcfb4 56
mbed_official 205:c41fc65bcfb4 57 #ifdef HAL_PWR_MODULE_ENABLED
mbed_official 205:c41fc65bcfb4 58
mbed_official 205:c41fc65bcfb4 59 /* Private typedef -----------------------------------------------------------*/
mbed_official 205:c41fc65bcfb4 60 /* Private define ------------------------------------------------------------*/
mbed_official 205:c41fc65bcfb4 61 /* Private macro -------------------------------------------------------------*/
mbed_official 205:c41fc65bcfb4 62 /* Private variables ---------------------------------------------------------*/
mbed_official 205:c41fc65bcfb4 63 /* Private function prototypes -----------------------------------------------*/
mbed_official 205:c41fc65bcfb4 64 /* Private functions ---------------------------------------------------------*/
mbed_official 205:c41fc65bcfb4 65
mbed_official 205:c41fc65bcfb4 66 /** @defgroup PWREx_Private_Functions
mbed_official 205:c41fc65bcfb4 67 * @{
mbed_official 205:c41fc65bcfb4 68 */
mbed_official 205:c41fc65bcfb4 69
mbed_official 205:c41fc65bcfb4 70 /** @defgroup PWREx_Group1 Extended Peripheral Control functions
mbed_official 205:c41fc65bcfb4 71 * @brief Extended Peripheral Control functions
mbed_official 205:c41fc65bcfb4 72 *
mbed_official 205:c41fc65bcfb4 73 @verbatim
mbed_official 205:c41fc65bcfb4 74
mbed_official 205:c41fc65bcfb4 75 ===============================================================================
mbed_official 205:c41fc65bcfb4 76 ##### Peripheral Control function #####
mbed_official 205:c41fc65bcfb4 77 ===============================================================================
mbed_official 205:c41fc65bcfb4 78
mbed_official 205:c41fc65bcfb4 79 *** PVD configuration ***
mbed_official 205:c41fc65bcfb4 80 =========================
mbed_official 205:c41fc65bcfb4 81 [..]
mbed_official 205:c41fc65bcfb4 82 (+) The PVD is used to monitor the VDD power supply by comparing it to a
mbed_official 205:c41fc65bcfb4 83 threshold selected by the PVD Level (PLS[2:0] bits in the PWR_CR).
mbed_official 205:c41fc65bcfb4 84 (+) A PVDO flag is available to indicate if VDD/VDDA is higher or lower
mbed_official 205:c41fc65bcfb4 85 than the PVD threshold. This event is internally connected to the EXTI
mbed_official 205:c41fc65bcfb4 86 line16 and can generate an interrupt if enabled. This is done through
mbed_official 205:c41fc65bcfb4 87 __HAL_PVD_EXTI_ENABLE_IT() macro
mbed_official 205:c41fc65bcfb4 88 (+) The PVD is stopped in Standby mode.
mbed_official 205:c41fc65bcfb4 89 Note: PVD is not available on STM32F030x4/x6/x8
mbed_official 205:c41fc65bcfb4 90
mbed_official 205:c41fc65bcfb4 91 @endverbatim
mbed_official 205:c41fc65bcfb4 92 * @{
mbed_official 205:c41fc65bcfb4 93 */
mbed_official 205:c41fc65bcfb4 94
mbed_official 205:c41fc65bcfb4 95 #if defined (STM32F031x6) || defined (STM32F042x6) || defined (STM32F051x8) || \
mbed_official 205:c41fc65bcfb4 96 defined (STM32F071xB) || defined (STM32F072xB)
mbed_official 205:c41fc65bcfb4 97
mbed_official 205:c41fc65bcfb4 98 /**
mbed_official 205:c41fc65bcfb4 99 * @brief Configures the voltage threshold detected by the Power Voltage Detector(PVD).
mbed_official 205:c41fc65bcfb4 100 * @param sConfigPVD: pointer to an PWR_PVDTypeDef structure that contains the configuration
mbed_official 205:c41fc65bcfb4 101 * information for the PVD.
mbed_official 205:c41fc65bcfb4 102 * @note Refer to the electrical characteristics of your device datasheet for
mbed_official 205:c41fc65bcfb4 103 * more details about the voltage threshold corresponding to each
mbed_official 205:c41fc65bcfb4 104 * detection level.
mbed_official 205:c41fc65bcfb4 105 * @retval None
mbed_official 205:c41fc65bcfb4 106 */
mbed_official 205:c41fc65bcfb4 107 void HAL_PWR_PVDConfig(PWR_PVDTypeDef *sConfigPVD)
mbed_official 205:c41fc65bcfb4 108 {
mbed_official 205:c41fc65bcfb4 109 /* Check the parameters */
mbed_official 205:c41fc65bcfb4 110 assert_param(IS_PWR_PVD_LEVEL(sConfigPVD->PVDLevel));
mbed_official 205:c41fc65bcfb4 111 assert_param(IS_PWR_PVD_MODE(sConfigPVD->Mode));
mbed_official 205:c41fc65bcfb4 112
mbed_official 205:c41fc65bcfb4 113 /* Set PLS[7:5] bits according to PVDLevel value */
mbed_official 205:c41fc65bcfb4 114 MODIFY_REG(PWR->CR, PWR_CR_PLS, sConfigPVD->PVDLevel);
mbed_official 205:c41fc65bcfb4 115
mbed_official 205:c41fc65bcfb4 116 /* Configure the EXTI 16 interrupt */
mbed_official 205:c41fc65bcfb4 117 if((sConfigPVD->Mode == PWR_MODE_IT_RISING_FALLING) ||\
mbed_official 205:c41fc65bcfb4 118 (sConfigPVD->Mode == PWR_MODE_IT_FALLING) ||\
mbed_official 205:c41fc65bcfb4 119 (sConfigPVD->Mode == PWR_MODE_IT_RISING))
mbed_official 205:c41fc65bcfb4 120 {
mbed_official 205:c41fc65bcfb4 121 __HAL_PVD_EXTI_ENABLE_IT(PWR_EXTI_LINE_PVD);
mbed_official 205:c41fc65bcfb4 122 }
mbed_official 205:c41fc65bcfb4 123 /* Configure the rising edge */
mbed_official 205:c41fc65bcfb4 124 if((sConfigPVD->Mode == PWR_MODE_IT_RISING_FALLING) ||\
mbed_official 205:c41fc65bcfb4 125 (sConfigPVD->Mode == PWR_MODE_IT_RISING))
mbed_official 205:c41fc65bcfb4 126 {
mbed_official 205:c41fc65bcfb4 127 EXTI->RTSR |= PWR_EXTI_LINE_PVD;
mbed_official 205:c41fc65bcfb4 128 }
mbed_official 205:c41fc65bcfb4 129 /* Configure the falling edge */
mbed_official 205:c41fc65bcfb4 130 if((sConfigPVD->Mode == PWR_MODE_IT_RISING_FALLING) ||\
mbed_official 205:c41fc65bcfb4 131 (sConfigPVD->Mode == PWR_MODE_IT_FALLING))
mbed_official 205:c41fc65bcfb4 132 {
mbed_official 205:c41fc65bcfb4 133 EXTI->FTSR |= PWR_EXTI_LINE_PVD;
mbed_official 205:c41fc65bcfb4 134 }
mbed_official 205:c41fc65bcfb4 135 }
mbed_official 205:c41fc65bcfb4 136
mbed_official 205:c41fc65bcfb4 137 /**
mbed_official 205:c41fc65bcfb4 138 * @brief Enables the Power Voltage Detector(PVD).
mbed_official 205:c41fc65bcfb4 139 * @param None
mbed_official 205:c41fc65bcfb4 140 * @retval None
mbed_official 205:c41fc65bcfb4 141 */
mbed_official 205:c41fc65bcfb4 142 void HAL_PWR_EnablePVD(void)
mbed_official 205:c41fc65bcfb4 143 {
mbed_official 205:c41fc65bcfb4 144 PWR->CR |= (uint32_t)PWR_CR_PVDE;
mbed_official 205:c41fc65bcfb4 145 }
mbed_official 205:c41fc65bcfb4 146
mbed_official 205:c41fc65bcfb4 147 /**
mbed_official 205:c41fc65bcfb4 148 * @brief Disables the Power Voltage Detector(PVD).
mbed_official 205:c41fc65bcfb4 149 * @param None
mbed_official 205:c41fc65bcfb4 150 * @retval None
mbed_official 205:c41fc65bcfb4 151 */
mbed_official 205:c41fc65bcfb4 152 void HAL_PWR_DisablePVD(void)
mbed_official 205:c41fc65bcfb4 153 {
mbed_official 205:c41fc65bcfb4 154 PWR->CR &= ~((uint32_t)PWR_CR_PVDE);
mbed_official 205:c41fc65bcfb4 155 }
mbed_official 205:c41fc65bcfb4 156
mbed_official 205:c41fc65bcfb4 157 /**
mbed_official 205:c41fc65bcfb4 158 * @brief This function handles the PWR PVD interrupt request.
mbed_official 205:c41fc65bcfb4 159 * @note This API should be called under the PVD_IRQHandler().
mbed_official 205:c41fc65bcfb4 160 * @param None
mbed_official 205:c41fc65bcfb4 161 * @retval None
mbed_official 205:c41fc65bcfb4 162 */
mbed_official 205:c41fc65bcfb4 163 void HAL_PWR_PVD_IRQHandler(void)
mbed_official 205:c41fc65bcfb4 164 {
mbed_official 205:c41fc65bcfb4 165 /* Check PWR exti flag */
mbed_official 205:c41fc65bcfb4 166 if(__HAL_PVD_EXTI_GET_FLAG(PWR_EXTI_LINE_PVD) != RESET)
mbed_official 205:c41fc65bcfb4 167 {
mbed_official 205:c41fc65bcfb4 168 /* PWR PVD interrupt user callback */
mbed_official 205:c41fc65bcfb4 169 HAL_PWR_PVDCallback();
mbed_official 205:c41fc65bcfb4 170
mbed_official 205:c41fc65bcfb4 171 /* Clear PWR Exti pending bit */
mbed_official 205:c41fc65bcfb4 172 __HAL_PVD_EXTI_CLEAR_FLAG(PWR_EXTI_LINE_PVD);
mbed_official 205:c41fc65bcfb4 173 }
mbed_official 205:c41fc65bcfb4 174 }
mbed_official 205:c41fc65bcfb4 175
mbed_official 205:c41fc65bcfb4 176 /**
mbed_official 205:c41fc65bcfb4 177 * @brief PWR PVD interrupt callback
mbed_official 205:c41fc65bcfb4 178 * @param None
mbed_official 205:c41fc65bcfb4 179 * @retval None
mbed_official 205:c41fc65bcfb4 180 */
mbed_official 205:c41fc65bcfb4 181 __weak void HAL_PWR_PVDCallback(void)
mbed_official 205:c41fc65bcfb4 182 {
mbed_official 205:c41fc65bcfb4 183 /* NOTE : This function Should not be modified, when the callback is needed,
mbed_official 205:c41fc65bcfb4 184 the HAL_PWR_PVDCallback could be implemented in the user file
mbed_official 205:c41fc65bcfb4 185 */
mbed_official 205:c41fc65bcfb4 186 }
mbed_official 205:c41fc65bcfb4 187
mbed_official 205:c41fc65bcfb4 188 #endif /* defined (STM32F031x6) || defined (STM32F042x6) || defined (STM32F051x8) || */
mbed_official 205:c41fc65bcfb4 189 /* defined (STM32F071xB) || defined (STM32F072xB) */
mbed_official 205:c41fc65bcfb4 190
mbed_official 205:c41fc65bcfb4 191
mbed_official 205:c41fc65bcfb4 192 /**
mbed_official 205:c41fc65bcfb4 193 * @}
mbed_official 205:c41fc65bcfb4 194 */
mbed_official 205:c41fc65bcfb4 195
mbed_official 205:c41fc65bcfb4 196 /**
mbed_official 205:c41fc65bcfb4 197 * @}
mbed_official 205:c41fc65bcfb4 198 */
mbed_official 205:c41fc65bcfb4 199
mbed_official 205:c41fc65bcfb4 200
mbed_official 205:c41fc65bcfb4 201 #endif /* HAL_PWR_MODULE_ENABLED */
mbed_official 205:c41fc65bcfb4 202 /**
mbed_official 205:c41fc65bcfb4 203 * @}
mbed_official 205:c41fc65bcfb4 204 */
mbed_official 205:c41fc65bcfb4 205
mbed_official 205:c41fc65bcfb4 206 /**
mbed_official 205:c41fc65bcfb4 207 * @}
mbed_official 205:c41fc65bcfb4 208 */
mbed_official 205:c41fc65bcfb4 209
mbed_official 205:c41fc65bcfb4 210 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/