mbed library sources

Dependents:   bare

Fork of mbed-src by mbed official

Committer:
mbed_official
Date:
Wed Feb 26 09:45:12 2014 +0000
Revision:
106:ced8cbb51063
Parent:
76:aeb1df146756
Synchronized with git revision 4222735eff5868389433f0e9271976b39c8115cd

Full URL: https://github.com/mbedmicro/mbed/commit/4222735eff5868389433f0e9271976b39c8115cd/

[NUCLEO_xxx] Update STM32CubeF4 driver V1.0.0 + update license

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 76:aeb1df146756 1 /**
mbed_official 76:aeb1df146756 2 ******************************************************************************
mbed_official 76:aeb1df146756 3 * @file stm32f0xx_crs.c
mbed_official 76:aeb1df146756 4 * @author MCD Application Team
mbed_official 76:aeb1df146756 5 * @version V1.3.0
mbed_official 76:aeb1df146756 6 * @date 16-January-2014
mbed_official 76:aeb1df146756 7 * @brief This file provides firmware functions to manage the following
mbed_official 76:aeb1df146756 8 * functionalities of CRS peripheral applicable only on STM32F042 and
mbed_official 76:aeb1df146756 9 * STM32F072 devices:
mbed_official 76:aeb1df146756 10 * + Configuration of the CRS peripheral
mbed_official 76:aeb1df146756 11 * + Interrupts and flags management
mbed_official 76:aeb1df146756 12 *
mbed_official 76:aeb1df146756 13 *
mbed_official 76:aeb1df146756 14 * @verbatim
mbed_official 76:aeb1df146756 15 ===============================================================================
mbed_official 76:aeb1df146756 16 ##### How to use this driver #####
mbed_official 76:aeb1df146756 17 ===============================================================================
mbed_official 76:aeb1df146756 18 [..]
mbed_official 76:aeb1df146756 19
mbed_official 76:aeb1df146756 20 (+) Enable CRS AHB clock using RCC_APB1eriphClockCmd(RCC_APB1Periph_CRS, ENABLE)
mbed_official 76:aeb1df146756 21 function
mbed_official 76:aeb1df146756 22
mbed_official 76:aeb1df146756 23
mbed_official 76:aeb1df146756 24 @endverbatim
mbed_official 76:aeb1df146756 25 *
mbed_official 76:aeb1df146756 26 ******************************************************************************
mbed_official 76:aeb1df146756 27 * @attention
mbed_official 76:aeb1df146756 28 *
mbed_official 106:ced8cbb51063 29 * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
mbed_official 76:aeb1df146756 30 *
mbed_official 106:ced8cbb51063 31 * Redistribution and use in source and binary forms, with or without modification,
mbed_official 106:ced8cbb51063 32 * are permitted provided that the following conditions are met:
mbed_official 106:ced8cbb51063 33 * 1. Redistributions of source code must retain the above copyright notice,
mbed_official 106:ced8cbb51063 34 * this list of conditions and the following disclaimer.
mbed_official 106:ced8cbb51063 35 * 2. Redistributions in binary form must reproduce the above copyright notice,
mbed_official 106:ced8cbb51063 36 * this list of conditions and the following disclaimer in the documentation
mbed_official 106:ced8cbb51063 37 * and/or other materials provided with the distribution.
mbed_official 106:ced8cbb51063 38 * 3. Neither the name of STMicroelectronics nor the names of its contributors
mbed_official 106:ced8cbb51063 39 * may be used to endorse or promote products derived from this software
mbed_official 106:ced8cbb51063 40 * without specific prior written permission.
mbed_official 76:aeb1df146756 41 *
mbed_official 106:ced8cbb51063 42 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
mbed_official 106:ced8cbb51063 43 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
mbed_official 106:ced8cbb51063 44 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
mbed_official 106:ced8cbb51063 45 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
mbed_official 106:ced8cbb51063 46 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
mbed_official 106:ced8cbb51063 47 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
mbed_official 106:ced8cbb51063 48 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
mbed_official 106:ced8cbb51063 49 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
mbed_official 106:ced8cbb51063 50 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
mbed_official 106:ced8cbb51063 51 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
mbed_official 76:aeb1df146756 52 *
mbed_official 76:aeb1df146756 53 ******************************************************************************
mbed_official 76:aeb1df146756 54 */
mbed_official 76:aeb1df146756 55
mbed_official 76:aeb1df146756 56 /* Includes ------------------------------------------------------------------*/
mbed_official 76:aeb1df146756 57 #include "stm32f0xx_crs.h"
mbed_official 76:aeb1df146756 58 #include "stm32f0xx_rcc.h"
mbed_official 76:aeb1df146756 59
mbed_official 76:aeb1df146756 60 /** @addtogroup STM32F0xx_StdPeriph_Driver
mbed_official 76:aeb1df146756 61 * @{
mbed_official 76:aeb1df146756 62 */
mbed_official 76:aeb1df146756 63
mbed_official 76:aeb1df146756 64 /** @defgroup CRS
mbed_official 76:aeb1df146756 65 * @brief CRS driver modules
mbed_official 76:aeb1df146756 66 * @{
mbed_official 76:aeb1df146756 67 */
mbed_official 76:aeb1df146756 68
mbed_official 76:aeb1df146756 69 /* Private typedef -----------------------------------------------------------*/
mbed_official 76:aeb1df146756 70 /* Private define ------------------------------------------------------------*/
mbed_official 76:aeb1df146756 71 /* CRS Flag Mask */
mbed_official 76:aeb1df146756 72 #define FLAG_MASK ((uint32_t)0x700)
mbed_official 76:aeb1df146756 73
mbed_official 76:aeb1df146756 74 /* Private macro -------------------------------------------------------------*/
mbed_official 76:aeb1df146756 75 /* Private variables ---------------------------------------------------------*/
mbed_official 76:aeb1df146756 76 /* Private function prototypes -----------------------------------------------*/
mbed_official 76:aeb1df146756 77 /* Private functions ---------------------------------------------------------*/
mbed_official 76:aeb1df146756 78
mbed_official 76:aeb1df146756 79 /** @defgroup CRS_Private_Functions
mbed_official 76:aeb1df146756 80 * @{
mbed_official 76:aeb1df146756 81 */
mbed_official 76:aeb1df146756 82
mbed_official 76:aeb1df146756 83 /** @defgroup CRS_Group1 Configuration of the CRS functions
mbed_official 76:aeb1df146756 84 * @brief Configuration of the CRS functions
mbed_official 76:aeb1df146756 85 *
mbed_official 76:aeb1df146756 86 @verbatim
mbed_official 76:aeb1df146756 87 ===============================================================================
mbed_official 76:aeb1df146756 88 ##### CRS configuration functions #####
mbed_official 76:aeb1df146756 89 ===============================================================================
mbed_official 76:aeb1df146756 90
mbed_official 76:aeb1df146756 91 @endverbatim
mbed_official 76:aeb1df146756 92 * @{
mbed_official 76:aeb1df146756 93 */
mbed_official 76:aeb1df146756 94
mbed_official 76:aeb1df146756 95 /**
mbed_official 76:aeb1df146756 96 * @brief Deinitializes CRS peripheral registers to their default reset values.
mbed_official 76:aeb1df146756 97 * @param None
mbed_official 76:aeb1df146756 98 * @retval None
mbed_official 76:aeb1df146756 99 */
mbed_official 76:aeb1df146756 100 void CRS_DeInit(void)
mbed_official 76:aeb1df146756 101 {
mbed_official 76:aeb1df146756 102 RCC_APB1PeriphResetCmd(RCC_APB1Periph_CRS, ENABLE);
mbed_official 76:aeb1df146756 103 RCC_APB1PeriphResetCmd(RCC_APB1Periph_CRS, DISABLE);
mbed_official 76:aeb1df146756 104 }
mbed_official 76:aeb1df146756 105
mbed_official 76:aeb1df146756 106 /**
mbed_official 76:aeb1df146756 107 * @brief Adjusts the Internal High Speed 48 oscillator (HSI 48) calibration value.
mbed_official 76:aeb1df146756 108 * @note The calibration is used to compensate for the variations in voltage
mbed_official 76:aeb1df146756 109 * and temperature that influence the frequency of the internal HSI48 RC.
mbed_official 76:aeb1df146756 110 * @note This function can be called only when the AUTOTRIMEN bit is reset.
mbed_official 76:aeb1df146756 111 * @param CRS_HSI48CalibrationValue:
mbed_official 76:aeb1df146756 112 * @retval None
mbed_official 76:aeb1df146756 113 */
mbed_official 76:aeb1df146756 114 void CRS_AdjustHSI48CalibrationValue(uint8_t CRS_HSI48CalibrationValue)
mbed_official 76:aeb1df146756 115 {
mbed_official 76:aeb1df146756 116 /* Clear TRIM[5:0] bits */
mbed_official 76:aeb1df146756 117 CRS->CR &= ~CRS_CR_TRIM;
mbed_official 76:aeb1df146756 118
mbed_official 76:aeb1df146756 119 /* Set the TRIM[5:0] bits according to CRS_HSI48CalibrationValue value */
mbed_official 76:aeb1df146756 120 CRS->CR |= (uint32_t)((uint32_t)CRS_HSI48CalibrationValue << 8);
mbed_official 76:aeb1df146756 121
mbed_official 76:aeb1df146756 122 }
mbed_official 76:aeb1df146756 123
mbed_official 76:aeb1df146756 124 /**
mbed_official 76:aeb1df146756 125 * @brief Enables or disables the oscillator clock for frequency error counter.
mbed_official 76:aeb1df146756 126 * @note when the CEN bit is set the CRS_CFGR register becomes write-protected.
mbed_official 76:aeb1df146756 127 * @param NewState: new state of the frequency error counter.
mbed_official 76:aeb1df146756 128 * This parameter can be: ENABLE or DISABLE.
mbed_official 76:aeb1df146756 129 * @retval None
mbed_official 76:aeb1df146756 130 */
mbed_official 76:aeb1df146756 131 void CRS_FrequencyErrorCounterCmd(FunctionalState NewState)
mbed_official 76:aeb1df146756 132 {
mbed_official 76:aeb1df146756 133 assert_param(IS_FUNCTIONAL_STATE(NewState));
mbed_official 76:aeb1df146756 134
mbed_official 76:aeb1df146756 135 if (NewState != DISABLE)
mbed_official 76:aeb1df146756 136 {
mbed_official 76:aeb1df146756 137 CRS->CR |= CRS_CR_CEN;
mbed_official 76:aeb1df146756 138 }
mbed_official 76:aeb1df146756 139 else
mbed_official 76:aeb1df146756 140 {
mbed_official 76:aeb1df146756 141 CRS->CR &= ~CRS_CR_CEN;
mbed_official 76:aeb1df146756 142 }
mbed_official 76:aeb1df146756 143 }
mbed_official 76:aeb1df146756 144
mbed_official 76:aeb1df146756 145 /**
mbed_official 76:aeb1df146756 146 * @brief Enables or disables the automatic hardware adjustement of TRIM bits.
mbed_official 76:aeb1df146756 147 * @note When the AUTOTRIMEN bit is set the CRS_CFGR register becomes write-protected.
mbed_official 76:aeb1df146756 148 * @param NewState: new state of the automatic trimming.
mbed_official 76:aeb1df146756 149 * This parameter can be: ENABLE or DISABLE.
mbed_official 76:aeb1df146756 150 * @retval None
mbed_official 76:aeb1df146756 151 */
mbed_official 76:aeb1df146756 152 void CRS_AutomaticCalibrationCmd(FunctionalState NewState)
mbed_official 76:aeb1df146756 153 {
mbed_official 76:aeb1df146756 154 assert_param(IS_FUNCTIONAL_STATE(NewState));
mbed_official 76:aeb1df146756 155
mbed_official 76:aeb1df146756 156 if (NewState != DISABLE)
mbed_official 76:aeb1df146756 157 {
mbed_official 76:aeb1df146756 158 CRS->CR |= CRS_CR_AUTOTRIMEN;
mbed_official 76:aeb1df146756 159 }
mbed_official 76:aeb1df146756 160 else
mbed_official 76:aeb1df146756 161 {
mbed_official 76:aeb1df146756 162 CRS->CR &= ~CRS_CR_AUTOTRIMEN;
mbed_official 76:aeb1df146756 163 }
mbed_official 76:aeb1df146756 164 }
mbed_official 76:aeb1df146756 165
mbed_official 76:aeb1df146756 166 /**
mbed_official 76:aeb1df146756 167 * @brief Generate the software synchronization event
mbed_official 76:aeb1df146756 168 * @param None
mbed_official 76:aeb1df146756 169 * @retval None
mbed_official 76:aeb1df146756 170 */
mbed_official 76:aeb1df146756 171 void CRS_SoftwareSynchronizationGenerate(void)
mbed_official 76:aeb1df146756 172 {
mbed_official 76:aeb1df146756 173 CRS->CR |= CRS_CR_SWSYNC;
mbed_official 76:aeb1df146756 174 }
mbed_official 76:aeb1df146756 175
mbed_official 76:aeb1df146756 176 /**
mbed_official 76:aeb1df146756 177 * @brief Adjusts the Internal High Speed 48 oscillator (HSI 48) calibration value.
mbed_official 76:aeb1df146756 178 * @note The calibration is used to compensate for the variations in voltage
mbed_official 76:aeb1df146756 179 * and temperature that influence the frequency of the internal HSI48 RC.
mbed_official 76:aeb1df146756 180 * @note This function can be called only when the CEN bit is reset.
mbed_official 76:aeb1df146756 181 * @param CRS_ReloadValue: specifies the HSI calibration trimming value.
mbed_official 76:aeb1df146756 182 * This parameter must be a number between 0 and .
mbed_official 76:aeb1df146756 183 * @retval None
mbed_official 76:aeb1df146756 184 */
mbed_official 76:aeb1df146756 185 void CRS_FrequencyErrorCounterReload(uint32_t CRS_ReloadValue)
mbed_official 76:aeb1df146756 186 {
mbed_official 76:aeb1df146756 187
mbed_official 76:aeb1df146756 188 /* Clear RELOAD[15:0] bits */
mbed_official 76:aeb1df146756 189 CRS->CFGR &= ~CRS_CFGR_RELOAD;
mbed_official 76:aeb1df146756 190
mbed_official 76:aeb1df146756 191 /* Set the RELOAD[15:0] bits according to CRS_ReloadValue value */
mbed_official 76:aeb1df146756 192 CRS->CFGR |= (uint32_t)CRS_ReloadValue;
mbed_official 76:aeb1df146756 193
mbed_official 76:aeb1df146756 194 }
mbed_official 76:aeb1df146756 195
mbed_official 76:aeb1df146756 196 /**
mbed_official 76:aeb1df146756 197 * @brief
mbed_official 76:aeb1df146756 198 * @note This function can be called only when the CEN bit is reset.
mbed_official 76:aeb1df146756 199 * @param CRS_ErrorLimitValue: specifies the HSI calibration trimming value.
mbed_official 76:aeb1df146756 200 * This parameter must be a number between 0 and .
mbed_official 76:aeb1df146756 201 * @retval None
mbed_official 76:aeb1df146756 202 */
mbed_official 76:aeb1df146756 203 void CRS_FrequencyErrorLimitConfig(uint8_t CRS_ErrorLimitValue)
mbed_official 76:aeb1df146756 204 {
mbed_official 76:aeb1df146756 205 /* Clear FELIM[7:0] bits */
mbed_official 76:aeb1df146756 206 CRS->CFGR &= ~CRS_CFGR_FELIM;
mbed_official 76:aeb1df146756 207
mbed_official 76:aeb1df146756 208 /* Set the FELIM[7:0] bits according to CRS_ErrorLimitValue value */
mbed_official 76:aeb1df146756 209 CRS->CFGR |= (uint32_t)CRS_ErrorLimitValue;
mbed_official 76:aeb1df146756 210 }
mbed_official 76:aeb1df146756 211
mbed_official 76:aeb1df146756 212 /**
mbed_official 76:aeb1df146756 213 * @brief
mbed_official 76:aeb1df146756 214 * @note This function can be called only when the CEN bit is reset.
mbed_official 76:aeb1df146756 215 * @param CRS_Prescaler: specifies the HSI calibration trimming value.
mbed_official 76:aeb1df146756 216 * This parameter can be one of the following values:
mbed_official 76:aeb1df146756 217 * @arg CRS_SYNC_Div1:
mbed_official 76:aeb1df146756 218 * @arg CRS_SYNC_Div2:
mbed_official 76:aeb1df146756 219 * @arg CRS_SYNC_Div4:
mbed_official 76:aeb1df146756 220 * @arg CRS_SYNC_Div8:
mbed_official 76:aeb1df146756 221 * @arg CRS_SYNC_Div16:
mbed_official 76:aeb1df146756 222 * @arg CRS_SYNC_Div32:
mbed_official 76:aeb1df146756 223 * @arg CRS_SYNC_Div64:
mbed_official 76:aeb1df146756 224 * @arg CRS_SYNC_Div128:
mbed_official 76:aeb1df146756 225 * @retval None
mbed_official 76:aeb1df146756 226 */
mbed_official 76:aeb1df146756 227 void CRS_SynchronizationPrescalerConfig(uint32_t CRS_Prescaler)
mbed_official 76:aeb1df146756 228 {
mbed_official 76:aeb1df146756 229 /* Check the parameters */
mbed_official 76:aeb1df146756 230 assert_param(IS_CRS_SYNC_DIV(CRS_Prescaler));
mbed_official 76:aeb1df146756 231
mbed_official 76:aeb1df146756 232 /* Clear SYNCDIV[2:0] bits */
mbed_official 76:aeb1df146756 233 CRS->CFGR &= ~CRS_CFGR_SYNCDIV;
mbed_official 76:aeb1df146756 234
mbed_official 76:aeb1df146756 235 /* Set the CRS_CFGR_SYNCDIV[2:0] bits according to CRS_Prescaler value */
mbed_official 76:aeb1df146756 236 CRS->CFGR |= CRS_Prescaler;
mbed_official 76:aeb1df146756 237 }
mbed_official 76:aeb1df146756 238
mbed_official 76:aeb1df146756 239 /**
mbed_official 76:aeb1df146756 240 * @brief
mbed_official 76:aeb1df146756 241 * @note This function can be called only when the CEN bit is reset.
mbed_official 76:aeb1df146756 242 * @param CRS_Source: .
mbed_official 76:aeb1df146756 243 * This parameter can be one of the following values:
mbed_official 76:aeb1df146756 244 * @arg CRS_SYNCSource_GPIO:
mbed_official 76:aeb1df146756 245 * @arg CRS_SYNCSource_LSE:
mbed_official 76:aeb1df146756 246 * @arg CRS_SYNCSource_USB:
mbed_official 76:aeb1df146756 247 * @retval None
mbed_official 76:aeb1df146756 248 */
mbed_official 76:aeb1df146756 249 void CRS_SynchronizationSourceConfig(uint32_t CRS_Source)
mbed_official 76:aeb1df146756 250 {
mbed_official 76:aeb1df146756 251 /* Check the parameters */
mbed_official 76:aeb1df146756 252 assert_param(IS_CRS_SYNC_SOURCE(CRS_Source));
mbed_official 76:aeb1df146756 253
mbed_official 76:aeb1df146756 254 /* Clear SYNCSRC[1:0] bits */
mbed_official 76:aeb1df146756 255 CRS->CFGR &= ~CRS_CFGR_SYNCSRC;
mbed_official 76:aeb1df146756 256
mbed_official 76:aeb1df146756 257 /* Set the SYNCSRC[1:0] bits according to CRS_Source value */
mbed_official 76:aeb1df146756 258 CRS->CFGR |= CRS_Source;
mbed_official 76:aeb1df146756 259 }
mbed_official 76:aeb1df146756 260
mbed_official 76:aeb1df146756 261 /**
mbed_official 76:aeb1df146756 262 * @brief
mbed_official 76:aeb1df146756 263 * @note This function can be called only when the CEN bit is reset.
mbed_official 76:aeb1df146756 264 * @param CRS_Polarity: .
mbed_official 76:aeb1df146756 265 * This parameter can be one of the following values:
mbed_official 76:aeb1df146756 266 * @arg CRS_SYNCPolarity_Rising:
mbed_official 76:aeb1df146756 267 * @arg CRS_SYNCPolarity_Falling:
mbed_official 76:aeb1df146756 268 * @retval None
mbed_official 76:aeb1df146756 269 */
mbed_official 76:aeb1df146756 270 void CRS_SynchronizationPolarityConfig(uint32_t CRS_Polarity)
mbed_official 76:aeb1df146756 271 {
mbed_official 76:aeb1df146756 272 /* Check the parameters */
mbed_official 76:aeb1df146756 273 assert_param(IS_CRS_SYNC_POLARITY(CRS_Polarity));
mbed_official 76:aeb1df146756 274
mbed_official 76:aeb1df146756 275 /* Clear SYNCSPOL bit */
mbed_official 76:aeb1df146756 276 CRS->CFGR &= ~CRS_CFGR_SYNCPOL;
mbed_official 76:aeb1df146756 277
mbed_official 76:aeb1df146756 278 /* Set the SYNCSPOL bits according to CRS_Polarity value */
mbed_official 76:aeb1df146756 279 CRS->CFGR |= CRS_Polarity;
mbed_official 76:aeb1df146756 280 }
mbed_official 76:aeb1df146756 281
mbed_official 76:aeb1df146756 282 /**
mbed_official 76:aeb1df146756 283 * @brief Returns the Relaod value.
mbed_official 76:aeb1df146756 284 * @param None
mbed_official 76:aeb1df146756 285 * @retval The reload value
mbed_official 76:aeb1df146756 286 */
mbed_official 76:aeb1df146756 287 uint32_t CRS_GetReloadValue(void)
mbed_official 76:aeb1df146756 288 {
mbed_official 76:aeb1df146756 289 return ((uint32_t)(CRS->CFGR & CRS_CFGR_RELOAD));
mbed_official 76:aeb1df146756 290 }
mbed_official 76:aeb1df146756 291
mbed_official 76:aeb1df146756 292 /**
mbed_official 76:aeb1df146756 293 * @brief Returns the HSI48 Calibration value.
mbed_official 76:aeb1df146756 294 * @param None
mbed_official 76:aeb1df146756 295 * @retval The reload value
mbed_official 76:aeb1df146756 296 */
mbed_official 76:aeb1df146756 297 uint32_t CRS_GetHSI48CalibrationValue(void)
mbed_official 76:aeb1df146756 298 {
mbed_official 76:aeb1df146756 299 return (((uint32_t)(CRS->CR & CRS_CR_TRIM)) >> 8);
mbed_official 76:aeb1df146756 300 }
mbed_official 76:aeb1df146756 301
mbed_official 76:aeb1df146756 302 /**
mbed_official 76:aeb1df146756 303 * @brief Returns the frequency error capture.
mbed_official 76:aeb1df146756 304 * @param None
mbed_official 76:aeb1df146756 305 * @retval The frequency error capture value
mbed_official 76:aeb1df146756 306 */
mbed_official 76:aeb1df146756 307 uint32_t CRS_GetFrequencyErrorValue(void)
mbed_official 76:aeb1df146756 308 {
mbed_official 76:aeb1df146756 309 return ((uint32_t)(CRS->ISR & CRS_ISR_FECAP));
mbed_official 76:aeb1df146756 310 }
mbed_official 76:aeb1df146756 311
mbed_official 76:aeb1df146756 312 /**
mbed_official 76:aeb1df146756 313 * @brief Returns the frequency error direction.
mbed_official 76:aeb1df146756 314 * @param None
mbed_official 76:aeb1df146756 315 * @retval The frequency error direction. The returned value can be one
mbed_official 76:aeb1df146756 316 * of the following values:
mbed_official 76:aeb1df146756 317 * - 0x00: Up counting
mbed_official 76:aeb1df146756 318 * - 0x8000: Down counting
mbed_official 76:aeb1df146756 319 */
mbed_official 76:aeb1df146756 320 uint32_t CRS_GetFrequencyErrorDirection(void)
mbed_official 76:aeb1df146756 321 {
mbed_official 76:aeb1df146756 322 return ((uint32_t)(CRS->ISR & CRS_ISR_FEDIR));
mbed_official 76:aeb1df146756 323 }
mbed_official 76:aeb1df146756 324
mbed_official 76:aeb1df146756 325 /** @defgroup CRS_Group2 Interrupts and flags management functions
mbed_official 76:aeb1df146756 326 * @brief Interrupts and flags management functions
mbed_official 76:aeb1df146756 327 *
mbed_official 76:aeb1df146756 328 @verbatim
mbed_official 76:aeb1df146756 329 ===============================================================================
mbed_official 76:aeb1df146756 330 ##### Interrupts and flags management functions #####
mbed_official 76:aeb1df146756 331 ===============================================================================
mbed_official 76:aeb1df146756 332 @endverbatim
mbed_official 76:aeb1df146756 333 * @{
mbed_official 76:aeb1df146756 334 */
mbed_official 76:aeb1df146756 335 /**
mbed_official 76:aeb1df146756 336 * @brief Enables or disables the specified CRS interrupts.
mbed_official 76:aeb1df146756 337 * @param CRS_IT: specifies the RCC interrupt sources to be enabled or disabled.
mbed_official 76:aeb1df146756 338 * This parameter can be any combination of the following values:
mbed_official 76:aeb1df146756 339 * @arg CRS_IT_SYNCOK:
mbed_official 76:aeb1df146756 340 * @arg CRS_IT_SYNCWARN:
mbed_official 76:aeb1df146756 341 * @arg CRS_IT_ERR:
mbed_official 76:aeb1df146756 342 * @arg CRS_IT_ESYNC:
mbed_official 76:aeb1df146756 343 * @param NewState: new state of the specified CRS interrupts.
mbed_official 76:aeb1df146756 344 * This parameter can be: ENABLE or DISABLE.
mbed_official 76:aeb1df146756 345 * @retval None
mbed_official 76:aeb1df146756 346 */
mbed_official 76:aeb1df146756 347 void CRS_ITConfig(uint32_t CRS_IT, FunctionalState NewState)
mbed_official 76:aeb1df146756 348 {
mbed_official 76:aeb1df146756 349 /* Check the parameters */
mbed_official 76:aeb1df146756 350 assert_param(IS_CRS_IT(CRS_IT));
mbed_official 76:aeb1df146756 351 assert_param(IS_FUNCTIONAL_STATE(NewState));
mbed_official 76:aeb1df146756 352
mbed_official 76:aeb1df146756 353 if (NewState != DISABLE)
mbed_official 76:aeb1df146756 354 {
mbed_official 76:aeb1df146756 355 CRS->CR |= CRS_IT;
mbed_official 76:aeb1df146756 356 }
mbed_official 76:aeb1df146756 357 else
mbed_official 76:aeb1df146756 358 {
mbed_official 76:aeb1df146756 359 CRS->CR &= ~CRS_IT;
mbed_official 76:aeb1df146756 360 }
mbed_official 76:aeb1df146756 361 }
mbed_official 76:aeb1df146756 362
mbed_official 76:aeb1df146756 363 /**
mbed_official 76:aeb1df146756 364 * @brief Checks whether the specified CRS flag is set or not.
mbed_official 76:aeb1df146756 365 * @param CRS_FLAG: specifies the flag to check.
mbed_official 76:aeb1df146756 366 * This parameter can be one of the following values:
mbed_official 76:aeb1df146756 367 * @arg CRS_FLAG_SYNCOK:
mbed_official 76:aeb1df146756 368 * @arg CRS_FLAG_SYNCWARN:
mbed_official 76:aeb1df146756 369 * @arg CRS_FLAG_ERR:
mbed_official 76:aeb1df146756 370 * @arg CRS_FLAG_ESYNC:
mbed_official 76:aeb1df146756 371 * @arg CRS_FLAG_TRIMOVF:
mbed_official 76:aeb1df146756 372 * @arg CRS_FLAG_SYNCERR:
mbed_official 76:aeb1df146756 373 * @arg CRS_FLAG_SYNCMISS:
mbed_official 76:aeb1df146756 374 * @retval The new state of CRS_FLAG (SET or RESET).
mbed_official 76:aeb1df146756 375 */
mbed_official 76:aeb1df146756 376 FlagStatus CRS_GetFlagStatus(uint32_t CRS_FLAG)
mbed_official 76:aeb1df146756 377 {
mbed_official 76:aeb1df146756 378 /* Check the parameters */
mbed_official 76:aeb1df146756 379 assert_param(IS_CRS_FLAG(CRS_FLAG));
mbed_official 76:aeb1df146756 380
mbed_official 76:aeb1df146756 381 return ((FlagStatus)(CRS->ISR & CRS_FLAG));
mbed_official 76:aeb1df146756 382 }
mbed_official 76:aeb1df146756 383
mbed_official 76:aeb1df146756 384 /**
mbed_official 76:aeb1df146756 385 * @brief Clears the CRS specified FLAG.
mbed_official 76:aeb1df146756 386 * @param CRS_FLAG: specifies the flag to check.
mbed_official 76:aeb1df146756 387 * This parameter can be one of the following values:
mbed_official 76:aeb1df146756 388 * @arg CRS_FLAG_SYNCOK:
mbed_official 76:aeb1df146756 389 * @arg CRS_FLAG_SYNCWARN:
mbed_official 76:aeb1df146756 390 * @arg CRS_FLAG_ERR:
mbed_official 76:aeb1df146756 391 * @arg CRS_FLAG_ESYNC:
mbed_official 76:aeb1df146756 392 * @arg CRS_FLAG_TRIMOVF:
mbed_official 76:aeb1df146756 393 * @arg CRS_FLAG_SYNCERR:
mbed_official 76:aeb1df146756 394 * @arg CRS_FLAG_SYNCMISS:
mbed_official 76:aeb1df146756 395 * @retval None
mbed_official 76:aeb1df146756 396 */
mbed_official 76:aeb1df146756 397 void CRS_ClearFlag(uint32_t CRS_FLAG)
mbed_official 76:aeb1df146756 398 {
mbed_official 76:aeb1df146756 399 /* Check the parameters */
mbed_official 76:aeb1df146756 400 assert_param(IS_CRS_FLAG(CRS_FLAG));
mbed_official 76:aeb1df146756 401
mbed_official 76:aeb1df146756 402 if ((CRS_FLAG & FLAG_MASK)!= 0)
mbed_official 76:aeb1df146756 403 {
mbed_official 76:aeb1df146756 404 CRS->ICR |= CRS_ICR_ERRC;
mbed_official 76:aeb1df146756 405 }
mbed_official 76:aeb1df146756 406 else
mbed_official 76:aeb1df146756 407 {
mbed_official 76:aeb1df146756 408 CRS->ICR |= CRS_FLAG;
mbed_official 76:aeb1df146756 409 }
mbed_official 76:aeb1df146756 410 }
mbed_official 76:aeb1df146756 411
mbed_official 76:aeb1df146756 412 /**
mbed_official 76:aeb1df146756 413 * @brief Checks whether the specified CRS IT pending bit is set or not.
mbed_official 76:aeb1df146756 414 * @param CRS_IT: specifies the IT pending bit to check.
mbed_official 76:aeb1df146756 415 * This parameter can be one of the following values:
mbed_official 76:aeb1df146756 416 * @arg CRS_IT_SYNCOK:
mbed_official 76:aeb1df146756 417 * @arg CRS_IT_SYNCWARN:
mbed_official 76:aeb1df146756 418 * @arg CRS_IT_ERR:
mbed_official 76:aeb1df146756 419 * @arg CRS_IT_ESYNC:
mbed_official 76:aeb1df146756 420 * @arg CRS_IT_TRIMOVF:
mbed_official 76:aeb1df146756 421 * @arg CRS_IT_SYNCERR:
mbed_official 76:aeb1df146756 422 * @arg CRS_IT_SYNCMISS:
mbed_official 76:aeb1df146756 423 * @retval The new state of CRS_IT (SET or RESET).
mbed_official 76:aeb1df146756 424 */
mbed_official 76:aeb1df146756 425 ITStatus CRS_GetITStatus(uint32_t CRS_IT)
mbed_official 76:aeb1df146756 426 {
mbed_official 76:aeb1df146756 427 /* Check the parameters */
mbed_official 76:aeb1df146756 428 assert_param(IS_CRS_GET_IT(CRS_IT));
mbed_official 76:aeb1df146756 429
mbed_official 76:aeb1df146756 430 return ((ITStatus)(CRS->ISR & CRS_IT));
mbed_official 76:aeb1df146756 431 }
mbed_official 76:aeb1df146756 432
mbed_official 76:aeb1df146756 433 /**
mbed_official 76:aeb1df146756 434 * @brief Clears the CRS specified IT pending bi.
mbed_official 76:aeb1df146756 435 * @param CRS_FLAG: specifies the IT pending bi to clear.
mbed_official 76:aeb1df146756 436 * This parameter can be one of the following values:
mbed_official 76:aeb1df146756 437 * @arg CRS_IT_SYNCOK:
mbed_official 76:aeb1df146756 438 * @arg CRS_IT_SYNCWARN:
mbed_official 76:aeb1df146756 439 * @arg CRS_IT_ERR:
mbed_official 76:aeb1df146756 440 * @arg CRS_IT_ESYNC:
mbed_official 76:aeb1df146756 441 * @arg CRS_IT_TRIMOVF:
mbed_official 76:aeb1df146756 442 * @arg CRS_IT_SYNCERR:
mbed_official 76:aeb1df146756 443 * @arg CRS_IT_SYNCMISS:
mbed_official 76:aeb1df146756 444 * @retval None
mbed_official 76:aeb1df146756 445 */
mbed_official 76:aeb1df146756 446 void CRS_ClearITPendingBit(uint32_t CRS_IT)
mbed_official 76:aeb1df146756 447 {
mbed_official 76:aeb1df146756 448 /* Check the parameters */
mbed_official 76:aeb1df146756 449 assert_param(IS_CRS_CLEAR_IT(CRS_IT));
mbed_official 76:aeb1df146756 450
mbed_official 76:aeb1df146756 451 if ((CRS_IT & FLAG_MASK)!= 0)
mbed_official 76:aeb1df146756 452 {
mbed_official 76:aeb1df146756 453 CRS->ICR |= CRS_ICR_ERRC;
mbed_official 76:aeb1df146756 454 }
mbed_official 76:aeb1df146756 455 else
mbed_official 76:aeb1df146756 456 {
mbed_official 76:aeb1df146756 457 CRS->ICR |= CRS_IT;
mbed_official 76:aeb1df146756 458 }
mbed_official 76:aeb1df146756 459 }
mbed_official 76:aeb1df146756 460 /**
mbed_official 76:aeb1df146756 461 * @}
mbed_official 76:aeb1df146756 462 */
mbed_official 76:aeb1df146756 463
mbed_official 76:aeb1df146756 464 /**
mbed_official 76:aeb1df146756 465 * @}
mbed_official 76:aeb1df146756 466 */
mbed_official 76:aeb1df146756 467
mbed_official 76:aeb1df146756 468 /**
mbed_official 76:aeb1df146756 469 * @}
mbed_official 76:aeb1df146756 470 */
mbed_official 76:aeb1df146756 471
mbed_official 76:aeb1df146756 472 /**
mbed_official 76:aeb1df146756 473 * @}
mbed_official 76:aeb1df146756 474 */
mbed_official 76:aeb1df146756 475
mbed_official 76:aeb1df146756 476 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/