STM32H735xx HAL User Manual
stm32h7xx_ll_crs.h
Go to the documentation of this file.
00001 /**
00002   ******************************************************************************
00003   * @file    stm32h7xx_ll_crs.h
00004   * @author  MCD Application Team
00005   * @brief   Header file of CRS LL module.
00006   ******************************************************************************
00007   * @attention
00008   *
00009   * Copyright (c) 2017 STMicroelectronics.
00010   * All rights reserved.
00011   *
00012   * This software is licensed under terms that can be found in the LICENSE file
00013   * in the root directory of this software component.
00014   * If no LICENSE file comes with this software, it is provided AS-IS.
00015   *
00016   ******************************************************************************
00017   */
00018 
00019 /* Define to prevent recursive inclusion -------------------------------------*/
00020 #ifndef STM32H7xx_LL_CRS_H
00021 #define STM32H7xx_LL_CRS_H
00022 
00023 #ifdef __cplusplus
00024 extern "C" {
00025 #endif
00026 
00027 /* Includes ------------------------------------------------------------------*/
00028 #include "stm32h7xx.h"
00029 
00030 /** @addtogroup STM32H7xx_LL_Driver
00031   * @{
00032   */
00033 
00034 #if defined(CRS)
00035 
00036 /** @defgroup CRS_LL CRS
00037   * @{
00038   */
00039 
00040 /* Private types -------------------------------------------------------------*/
00041 /* Private variables ---------------------------------------------------------*/
00042 /* Private constants ---------------------------------------------------------*/
00043 /* Private macros ------------------------------------------------------------*/
00044 
00045 /* Exported types ------------------------------------------------------------*/
00046 /* Exported constants --------------------------------------------------------*/
00047 /** @defgroup CRS_LL_Exported_Constants CRS Exported Constants
00048   * @{
00049   */
00050 
00051 /** @defgroup CRS_LL_EC_GET_FLAG Get Flags Defines
00052   * @brief    Flags defines which can be used with LL_CRS_ReadReg function
00053   * @{
00054   */
00055 #define LL_CRS_ISR_SYNCOKF                 CRS_ISR_SYNCOKF
00056 #define LL_CRS_ISR_SYNCWARNF               CRS_ISR_SYNCWARNF
00057 #define LL_CRS_ISR_ERRF                    CRS_ISR_ERRF
00058 #define LL_CRS_ISR_ESYNCF                  CRS_ISR_ESYNCF
00059 #define LL_CRS_ISR_SYNCERR                 CRS_ISR_SYNCERR
00060 #define LL_CRS_ISR_SYNCMISS                CRS_ISR_SYNCMISS
00061 #define LL_CRS_ISR_TRIMOVF                 CRS_ISR_TRIMOVF
00062 /**
00063   * @}
00064   */
00065 
00066 /** @defgroup CRS_LL_EC_IT IT Defines
00067   * @brief    IT defines which can be used with LL_CRS_ReadReg and  LL_CRS_WriteReg functions
00068   * @{
00069   */
00070 #define LL_CRS_CR_SYNCOKIE                 CRS_CR_SYNCOKIE
00071 #define LL_CRS_CR_SYNCWARNIE               CRS_CR_SYNCWARNIE
00072 #define LL_CRS_CR_ERRIE                    CRS_CR_ERRIE
00073 #define LL_CRS_CR_ESYNCIE                  CRS_CR_ESYNCIE
00074 /**
00075   * @}
00076   */
00077 
00078 /** @defgroup CRS_LL_EC_SYNC_DIV Synchronization Signal Divider
00079   * @{
00080   */
00081 #define LL_CRS_SYNC_DIV_1                  0x00000000U                               /*!< Synchro Signal not divided (default) */
00082 #define LL_CRS_SYNC_DIV_2                  CRS_CFGR_SYNCDIV_0                        /*!< Synchro Signal divided by 2 */
00083 #define LL_CRS_SYNC_DIV_4                  CRS_CFGR_SYNCDIV_1                        /*!< Synchro Signal divided by 4 */
00084 #define LL_CRS_SYNC_DIV_8                  (CRS_CFGR_SYNCDIV_1 | CRS_CFGR_SYNCDIV_0) /*!< Synchro Signal divided by 8 */
00085 #define LL_CRS_SYNC_DIV_16                 CRS_CFGR_SYNCDIV_2                        /*!< Synchro Signal divided by 16 */
00086 #define LL_CRS_SYNC_DIV_32                 (CRS_CFGR_SYNCDIV_2 | CRS_CFGR_SYNCDIV_0) /*!< Synchro Signal divided by 32 */
00087 #define LL_CRS_SYNC_DIV_64                 (CRS_CFGR_SYNCDIV_2 | CRS_CFGR_SYNCDIV_1) /*!< Synchro Signal divided by 64 */
00088 #define LL_CRS_SYNC_DIV_128                CRS_CFGR_SYNCDIV                          /*!< Synchro Signal divided by 128 */
00089 /**
00090   * @}
00091   */
00092 
00093 /** @defgroup CRS_LL_EC_SYNC_SOURCE Synchronization Signal Source
00094   * @{
00095   */
00096 #define LL_CRS_SYNC_SOURCE_GPIO            0x00000000U             /*!< Synchro Signal source GPIO */
00097 #define LL_CRS_SYNC_SOURCE_LSE             CRS_CFGR_SYNCSRC_0      /*!< Synchro Signal source LSE */
00098 #define LL_CRS_SYNC_SOURCE_USB             CRS_CFGR_SYNCSRC_1      /*!< Synchro Signal source USB SOF (default)*/
00099 /**
00100   * @}
00101   */
00102 
00103 /** @defgroup CRS_LL_EC_SYNC_POLARITY Synchronization Signal Polarity
00104   * @{
00105   */
00106 #define LL_CRS_SYNC_POLARITY_RISING        0x00000000U           /*!< Synchro Active on rising edge (default) */
00107 #define LL_CRS_SYNC_POLARITY_FALLING       CRS_CFGR_SYNCPOL      /*!< Synchro Active on falling edge */
00108 /**
00109   * @}
00110   */
00111 
00112 /** @defgroup CRS_LL_EC_FREQERRORDIR Frequency Error Direction
00113   * @{
00114   */
00115 #define LL_CRS_FREQ_ERROR_DIR_UP           0x00000000U         /*!< Upcounting direction, the actual frequency is above the target */
00116 #define LL_CRS_FREQ_ERROR_DIR_DOWN         CRS_ISR_FEDIR       /*!< Downcounting direction, the actual frequency is below the target */
00117 /**
00118   * @}
00119   */
00120 
00121 /** @defgroup CRS_LL_EC_DEFAULTVALUES Default Values
00122   * @{
00123   */
00124 /**
00125   * @brief Reset value of the RELOAD field
00126   * @note The reset value of the RELOAD field corresponds to a target frequency of 48 MHz
00127   *       and a synchronization signal frequency of 1 kHz (SOF signal from USB)
00128   */
00129 #define LL_CRS_RELOADVALUE_DEFAULT         0x0000BB7FU
00130 
00131 /**
00132   * @brief Reset value of Frequency error limit.
00133   */
00134 #define LL_CRS_ERRORLIMIT_DEFAULT          0x00000022U
00135 
00136 /**
00137   * @brief Reset value of the HSI48 Calibration field
00138   * @note The default value is 64, which corresponds to the middle of the trimming interval.
00139   *       The trimming step is specified in the product datasheet.
00140   *       A higher TRIM value corresponds to a higher output frequency.
00141   */
00142 #define LL_CRS_HSI48CALIBRATION_DEFAULT    0x00000020U
00143 /**
00144   * @}
00145   */
00146 
00147 /**
00148   * @}
00149   */
00150 
00151 /* Exported macro ------------------------------------------------------------*/
00152 /** @defgroup CRS_LL_Exported_Macros CRS Exported Macros
00153   * @{
00154   */
00155 
00156 /** @defgroup CRS_LL_EM_WRITE_READ Common Write and read registers Macros
00157   * @{
00158   */
00159 
00160 /**
00161   * @brief  Write a value in CRS register
00162   * @param  __INSTANCE__ CRS Instance
00163   * @param  __REG__ Register to be written
00164   * @param  __VALUE__ Value to be written in the register
00165   * @retval None
00166   */
00167 #define LL_CRS_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
00168 
00169 /**
00170   * @brief  Read a value in CRS register
00171   * @param  __INSTANCE__ CRS Instance
00172   * @param  __REG__ Register to be read
00173   * @retval Register value
00174   */
00175 #define LL_CRS_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
00176 /**
00177   * @}
00178   */
00179 
00180 /** @defgroup CRS_LL_EM_Exported_Macros_Calculate_Reload Exported_Macros_Calculate_Reload
00181   * @{
00182   */
00183 
00184 /**
00185   * @brief  Macro to calculate reload value to be set in CRS register according to target and sync frequencies
00186   * @note   The RELOAD value should be selected according to the ratio between
00187   *         the target frequency and the frequency of the synchronization source after
00188   *         prescaling. It is then decreased by one in order to reach the expected
00189   *         synchronization on the zero value. The formula is the following:
00190   *              RELOAD = (fTARGET / fSYNC) -1
00191   * @param  __FTARGET__ Target frequency (value in Hz)
00192   * @param  __FSYNC__ Synchronization signal frequency (value in Hz)
00193   * @retval Reload value (in Hz)
00194   */
00195 #define __LL_CRS_CALC_CALCULATE_RELOADVALUE(__FTARGET__, __FSYNC__) (((__FTARGET__) / (__FSYNC__)) - 1U)
00196 
00197 /**
00198   * @}
00199   */
00200 
00201 /**
00202   * @}
00203   */
00204 
00205 /* Exported functions --------------------------------------------------------*/
00206 /** @defgroup CRS_LL_Exported_Functions CRS Exported Functions
00207   * @{
00208   */
00209 
00210 /** @defgroup CRS_LL_EF_Configuration Configuration
00211   * @{
00212   */
00213 
00214 /**
00215   * @brief  Enable Frequency error counter
00216   * @note When this bit is set, the CRS_CFGR register is write-protected and cannot be modified
00217   * @rmtoll CR           CEN           LL_CRS_EnableFreqErrorCounter
00218   * @retval None
00219   */
00220 __STATIC_INLINE void LL_CRS_EnableFreqErrorCounter(void)
00221 {
00222   SET_BIT(CRS->CR, CRS_CR_CEN);
00223 }
00224 
00225 /**
00226   * @brief  Disable Frequency error counter
00227   * @rmtoll CR           CEN           LL_CRS_DisableFreqErrorCounter
00228   * @retval None
00229   */
00230 __STATIC_INLINE void LL_CRS_DisableFreqErrorCounter(void)
00231 {
00232   CLEAR_BIT(CRS->CR, CRS_CR_CEN);
00233 }
00234 
00235 /**
00236   * @brief  Check if Frequency error counter is enabled or not
00237   * @rmtoll CR           CEN           LL_CRS_IsEnabledFreqErrorCounter
00238   * @retval State of bit (1 or 0).
00239   */
00240 __STATIC_INLINE uint32_t LL_CRS_IsEnabledFreqErrorCounter(void)
00241 {
00242   return ((READ_BIT(CRS->CR, CRS_CR_CEN) == (CRS_CR_CEN)) ? 1UL : 0UL);
00243 }
00244 
00245 /**
00246   * @brief  Enable Automatic trimming counter
00247   * @rmtoll CR           AUTOTRIMEN    LL_CRS_EnableAutoTrimming
00248   * @retval None
00249   */
00250 __STATIC_INLINE void LL_CRS_EnableAutoTrimming(void)
00251 {
00252   SET_BIT(CRS->CR, CRS_CR_AUTOTRIMEN);
00253 }
00254 
00255 /**
00256   * @brief  Disable Automatic trimming counter
00257   * @rmtoll CR           AUTOTRIMEN    LL_CRS_DisableAutoTrimming
00258   * @retval None
00259   */
00260 __STATIC_INLINE void LL_CRS_DisableAutoTrimming(void)
00261 {
00262   CLEAR_BIT(CRS->CR, CRS_CR_AUTOTRIMEN);
00263 }
00264 
00265 /**
00266   * @brief  Check if Automatic trimming is enabled or not
00267   * @rmtoll CR           AUTOTRIMEN    LL_CRS_IsEnabledAutoTrimming
00268   * @retval State of bit (1 or 0).
00269   */
00270 __STATIC_INLINE uint32_t LL_CRS_IsEnabledAutoTrimming(void)
00271 {
00272   return ((READ_BIT(CRS->CR, CRS_CR_AUTOTRIMEN) == (CRS_CR_AUTOTRIMEN)) ? 1UL : 0UL);
00273 }
00274 
00275 /**
00276   * @brief  Set HSI48 oscillator smooth trimming
00277   * @note   When the AUTOTRIMEN bit is set, this field is controlled by hardware and is read-only
00278   * @rmtoll CR           TRIM          LL_CRS_SetHSI48SmoothTrimming
00279   * @param  Value a number between Min_Data = 0 and Max_Data = 127
00280   * @note   Default value can be set thanks to @ref LL_CRS_HSI48CALIBRATION_DEFAULT
00281   * @retval None
00282   */
00283 __STATIC_INLINE void LL_CRS_SetHSI48SmoothTrimming(uint32_t Value)
00284 {
00285   MODIFY_REG(CRS->CR, CRS_CR_TRIM, Value << CRS_CR_TRIM_Pos);
00286 }
00287 
00288 /**
00289   * @brief  Get HSI48 oscillator smooth trimming
00290   * @rmtoll CR           TRIM          LL_CRS_GetHSI48SmoothTrimming
00291   * @retval a number between Min_Data = 0 and Max_Data = 127
00292   */
00293 __STATIC_INLINE uint32_t LL_CRS_GetHSI48SmoothTrimming(void)
00294 {
00295   return (uint32_t)(READ_BIT(CRS->CR, CRS_CR_TRIM) >> CRS_CR_TRIM_Pos);
00296 }
00297 
00298 /**
00299   * @brief  Set counter reload value
00300   * @rmtoll CFGR         RELOAD        LL_CRS_SetReloadCounter
00301   * @param  Value a number between Min_Data = 0 and Max_Data = 0xFFFF
00302   * @note   Default value can be set thanks to @ref LL_CRS_RELOADVALUE_DEFAULT
00303   *         Otherwise it can be calculated in using macro @ref __LL_CRS_CALC_CALCULATE_RELOADVALUE (_FTARGET_, _FSYNC_)
00304   * @retval None
00305   */
00306 __STATIC_INLINE void LL_CRS_SetReloadCounter(uint32_t Value)
00307 {
00308   MODIFY_REG(CRS->CFGR, CRS_CFGR_RELOAD, Value);
00309 }
00310 
00311 /**
00312   * @brief  Get counter reload value
00313   * @rmtoll CFGR         RELOAD        LL_CRS_GetReloadCounter
00314   * @retval a number between Min_Data = 0 and Max_Data = 0xFFFF
00315   */
00316 __STATIC_INLINE uint32_t LL_CRS_GetReloadCounter(void)
00317 {
00318   return (uint32_t)(READ_BIT(CRS->CFGR, CRS_CFGR_RELOAD));
00319 }
00320 
00321 /**
00322   * @brief  Set frequency error limit
00323   * @rmtoll CFGR         FELIM         LL_CRS_SetFreqErrorLimit
00324   * @param  Value a number between Min_Data = 0 and Max_Data = 255
00325   * @note   Default value can be set thanks to @ref LL_CRS_ERRORLIMIT_DEFAULT
00326   * @retval None
00327   */
00328 __STATIC_INLINE void LL_CRS_SetFreqErrorLimit(uint32_t Value)
00329 {
00330   MODIFY_REG(CRS->CFGR, CRS_CFGR_FELIM, Value << CRS_CFGR_FELIM_Pos);
00331 }
00332 
00333 /**
00334   * @brief  Get frequency error limit
00335   * @rmtoll CFGR         FELIM         LL_CRS_GetFreqErrorLimit
00336   * @retval A number between Min_Data = 0 and Max_Data = 255
00337   */
00338 __STATIC_INLINE uint32_t LL_CRS_GetFreqErrorLimit(void)
00339 {
00340   return (uint32_t)(READ_BIT(CRS->CFGR, CRS_CFGR_FELIM) >> CRS_CFGR_FELIM_Pos);
00341 }
00342 
00343 /**
00344   * @brief  Set division factor for SYNC signal
00345   * @rmtoll CFGR         SYNCDIV       LL_CRS_SetSyncDivider
00346   * @param  Divider This parameter can be one of the following values:
00347   *         @arg @ref LL_CRS_SYNC_DIV_1
00348   *         @arg @ref LL_CRS_SYNC_DIV_2
00349   *         @arg @ref LL_CRS_SYNC_DIV_4
00350   *         @arg @ref LL_CRS_SYNC_DIV_8
00351   *         @arg @ref LL_CRS_SYNC_DIV_16
00352   *         @arg @ref LL_CRS_SYNC_DIV_32
00353   *         @arg @ref LL_CRS_SYNC_DIV_64
00354   *         @arg @ref LL_CRS_SYNC_DIV_128
00355   * @retval None
00356   */
00357 __STATIC_INLINE void LL_CRS_SetSyncDivider(uint32_t Divider)
00358 {
00359   MODIFY_REG(CRS->CFGR, CRS_CFGR_SYNCDIV, Divider);
00360 }
00361 
00362 /**
00363   * @brief  Get division factor for SYNC signal
00364   * @rmtoll CFGR         SYNCDIV       LL_CRS_GetSyncDivider
00365   * @retval Returned value can be one of the following values:
00366   *         @arg @ref LL_CRS_SYNC_DIV_1
00367   *         @arg @ref LL_CRS_SYNC_DIV_2
00368   *         @arg @ref LL_CRS_SYNC_DIV_4
00369   *         @arg @ref LL_CRS_SYNC_DIV_8
00370   *         @arg @ref LL_CRS_SYNC_DIV_16
00371   *         @arg @ref LL_CRS_SYNC_DIV_32
00372   *         @arg @ref LL_CRS_SYNC_DIV_64
00373   *         @arg @ref LL_CRS_SYNC_DIV_128
00374   */
00375 __STATIC_INLINE uint32_t LL_CRS_GetSyncDivider(void)
00376 {
00377   return (uint32_t)(READ_BIT(CRS->CFGR, CRS_CFGR_SYNCDIV));
00378 }
00379 
00380 /**
00381   * @brief  Set SYNC signal source
00382   * @rmtoll CFGR         SYNCSRC       LL_CRS_SetSyncSignalSource
00383   * @param  Source This parameter can be one of the following values:
00384   *         @arg @ref LL_CRS_SYNC_SOURCE_GPIO
00385   *         @arg @ref LL_CRS_SYNC_SOURCE_LSE
00386   *         @arg @ref LL_CRS_SYNC_SOURCE_USB
00387   * @retval None
00388   */
00389 __STATIC_INLINE void LL_CRS_SetSyncSignalSource(uint32_t Source)
00390 {
00391   MODIFY_REG(CRS->CFGR, CRS_CFGR_SYNCSRC, Source);
00392 }
00393 
00394 /**
00395   * @brief  Get SYNC signal source
00396   * @rmtoll CFGR         SYNCSRC       LL_CRS_GetSyncSignalSource
00397   * @retval Returned value can be one of the following values:
00398   *         @arg @ref LL_CRS_SYNC_SOURCE_GPIO
00399   *         @arg @ref LL_CRS_SYNC_SOURCE_LSE
00400   *         @arg @ref LL_CRS_SYNC_SOURCE_USB
00401   */
00402 __STATIC_INLINE uint32_t LL_CRS_GetSyncSignalSource(void)
00403 {
00404   return (uint32_t)(READ_BIT(CRS->CFGR, CRS_CFGR_SYNCSRC));
00405 }
00406 
00407 /**
00408   * @brief  Set input polarity for the SYNC signal source
00409   * @rmtoll CFGR         SYNCPOL       LL_CRS_SetSyncPolarity
00410   * @param  Polarity This parameter can be one of the following values:
00411   *         @arg @ref LL_CRS_SYNC_POLARITY_RISING
00412   *         @arg @ref LL_CRS_SYNC_POLARITY_FALLING
00413   * @retval None
00414   */
00415 __STATIC_INLINE void LL_CRS_SetSyncPolarity(uint32_t Polarity)
00416 {
00417   MODIFY_REG(CRS->CFGR, CRS_CFGR_SYNCPOL, Polarity);
00418 }
00419 
00420 /**
00421   * @brief  Get input polarity for the SYNC signal source
00422   * @rmtoll CFGR         SYNCPOL       LL_CRS_GetSyncPolarity
00423   * @retval Returned value can be one of the following values:
00424   *         @arg @ref LL_CRS_SYNC_POLARITY_RISING
00425   *         @arg @ref LL_CRS_SYNC_POLARITY_FALLING
00426   */
00427 __STATIC_INLINE uint32_t LL_CRS_GetSyncPolarity(void)
00428 {
00429   return (uint32_t)(READ_BIT(CRS->CFGR, CRS_CFGR_SYNCPOL));
00430 }
00431 
00432 /**
00433   * @brief  Configure CRS for the synchronization
00434   * @rmtoll CR           TRIM          LL_CRS_ConfigSynchronization\n
00435   *         CFGR         RELOAD        LL_CRS_ConfigSynchronization\n
00436   *         CFGR         FELIM         LL_CRS_ConfigSynchronization\n
00437   *         CFGR         SYNCDIV       LL_CRS_ConfigSynchronization\n
00438   *         CFGR         SYNCSRC       LL_CRS_ConfigSynchronization\n
00439   *         CFGR         SYNCPOL       LL_CRS_ConfigSynchronization
00440   * @param  HSI48CalibrationValue a number between Min_Data = 0 and Max_Data = 63
00441   * @param  ErrorLimitValue a number between Min_Data = 0 and Max_Data = 0xFFFF
00442   * @param  ReloadValue a number between Min_Data = 0 and Max_Data = 255
00443   * @param  Settings This parameter can be a combination of the following values:
00444   *         @arg @ref LL_CRS_SYNC_DIV_1 or @ref LL_CRS_SYNC_DIV_2 or @ref LL_CRS_SYNC_DIV_4 or @ref LL_CRS_SYNC_DIV_8
00445   *              or @ref LL_CRS_SYNC_DIV_16 or @ref LL_CRS_SYNC_DIV_32 or @ref LL_CRS_SYNC_DIV_64 or @ref LL_CRS_SYNC_DIV_128
00446   *         @arg @ref LL_CRS_SYNC_SOURCE_GPIO or @ref LL_CRS_SYNC_SOURCE_LSE or @ref LL_CRS_SYNC_SOURCE_USB
00447   *         @arg @ref LL_CRS_SYNC_POLARITY_RISING or @ref LL_CRS_SYNC_POLARITY_FALLING
00448   * @retval None
00449   */
00450 __STATIC_INLINE void LL_CRS_ConfigSynchronization(uint32_t HSI48CalibrationValue, uint32_t ErrorLimitValue, uint32_t ReloadValue, uint32_t Settings)
00451 {
00452   MODIFY_REG(CRS->CR, CRS_CR_TRIM, HSI48CalibrationValue);
00453   MODIFY_REG(CRS->CFGR,
00454              CRS_CFGR_RELOAD | CRS_CFGR_FELIM | CRS_CFGR_SYNCDIV | CRS_CFGR_SYNCSRC | CRS_CFGR_SYNCPOL,
00455              ReloadValue | (ErrorLimitValue << CRS_CFGR_FELIM_Pos) | Settings);
00456 }
00457 
00458 /**
00459   * @}
00460   */
00461 
00462 /** @defgroup CRS_LL_EF_CRS_Management CRS_Management
00463   * @{
00464   */
00465 
00466 /**
00467   * @brief  Generate software SYNC event
00468   * @rmtoll CR           SWSYNC        LL_CRS_GenerateEvent_SWSYNC
00469   * @retval None
00470   */
00471 __STATIC_INLINE void LL_CRS_GenerateEvent_SWSYNC(void)
00472 {
00473   SET_BIT(CRS->CR, CRS_CR_SWSYNC);
00474 }
00475 
00476 /**
00477   * @brief  Get the frequency error direction latched in the time of the last
00478   * SYNC event
00479   * @rmtoll ISR          FEDIR         LL_CRS_GetFreqErrorDirection
00480   * @retval Returned value can be one of the following values:
00481   *         @arg @ref LL_CRS_FREQ_ERROR_DIR_UP
00482   *         @arg @ref LL_CRS_FREQ_ERROR_DIR_DOWN
00483   */
00484 __STATIC_INLINE uint32_t LL_CRS_GetFreqErrorDirection(void)
00485 {
00486   return (uint32_t)(READ_BIT(CRS->ISR, CRS_ISR_FEDIR));
00487 }
00488 
00489 /**
00490   * @brief  Get the frequency error counter value latched in the time of the last SYNC event
00491   * @rmtoll ISR          FECAP         LL_CRS_GetFreqErrorCapture
00492   * @retval A number between Min_Data = 0x0000 and Max_Data = 0xFFFF
00493   */
00494 __STATIC_INLINE uint32_t LL_CRS_GetFreqErrorCapture(void)
00495 {
00496   return (uint32_t)(READ_BIT(CRS->ISR, CRS_ISR_FECAP) >> CRS_ISR_FECAP_Pos);
00497 }
00498 
00499 /**
00500   * @}
00501   */
00502 
00503 /** @defgroup CRS_LL_EF_FLAG_Management FLAG_Management
00504   * @{
00505   */
00506 
00507 /**
00508   * @brief  Check if SYNC event OK signal occurred or not
00509   * @rmtoll ISR          SYNCOKF       LL_CRS_IsActiveFlag_SYNCOK
00510   * @retval State of bit (1 or 0).
00511   */
00512 __STATIC_INLINE uint32_t LL_CRS_IsActiveFlag_SYNCOK(void)
00513 {
00514   return ((READ_BIT(CRS->ISR, CRS_ISR_SYNCOKF) == (CRS_ISR_SYNCOKF)) ? 1UL : 0UL);
00515 }
00516 
00517 /**
00518   * @brief  Check if SYNC warning signal occurred or not
00519   * @rmtoll ISR          SYNCWARNF     LL_CRS_IsActiveFlag_SYNCWARN
00520   * @retval State of bit (1 or 0).
00521   */
00522 __STATIC_INLINE uint32_t LL_CRS_IsActiveFlag_SYNCWARN(void)
00523 {
00524   return ((READ_BIT(CRS->ISR, CRS_ISR_SYNCWARNF) == (CRS_ISR_SYNCWARNF)) ? 1UL : 0UL);
00525 }
00526 
00527 /**
00528   * @brief  Check if Synchronization or trimming error signal occurred or not
00529   * @rmtoll ISR          ERRF          LL_CRS_IsActiveFlag_ERR
00530   * @retval State of bit (1 or 0).
00531   */
00532 __STATIC_INLINE uint32_t LL_CRS_IsActiveFlag_ERR(void)
00533 {
00534   return ((READ_BIT(CRS->ISR, CRS_ISR_ERRF) == (CRS_ISR_ERRF)) ? 1UL : 0UL);
00535 }
00536 
00537 /**
00538   * @brief  Check if Expected SYNC signal occurred or not
00539   * @rmtoll ISR          ESYNCF        LL_CRS_IsActiveFlag_ESYNC
00540   * @retval State of bit (1 or 0).
00541   */
00542 __STATIC_INLINE uint32_t LL_CRS_IsActiveFlag_ESYNC(void)
00543 {
00544   return ((READ_BIT(CRS->ISR, CRS_ISR_ESYNCF) == (CRS_ISR_ESYNCF)) ? 1UL : 0UL);
00545 }
00546 
00547 /**
00548   * @brief  Check if SYNC error signal occurred or not
00549   * @rmtoll ISR          SYNCERR       LL_CRS_IsActiveFlag_SYNCERR
00550   * @retval State of bit (1 or 0).
00551   */
00552 __STATIC_INLINE uint32_t LL_CRS_IsActiveFlag_SYNCERR(void)
00553 {
00554   return ((READ_BIT(CRS->ISR, CRS_ISR_SYNCERR) == (CRS_ISR_SYNCERR)) ? 1UL : 0UL);
00555 }
00556 
00557 /**
00558   * @brief  Check if SYNC missed error signal occurred or not
00559   * @rmtoll ISR          SYNCMISS      LL_CRS_IsActiveFlag_SYNCMISS
00560   * @retval State of bit (1 or 0).
00561   */
00562 __STATIC_INLINE uint32_t LL_CRS_IsActiveFlag_SYNCMISS(void)
00563 {
00564   return ((READ_BIT(CRS->ISR, CRS_ISR_SYNCMISS) == (CRS_ISR_SYNCMISS)) ? 1UL : 0UL);
00565 }
00566 
00567 /**
00568   * @brief  Check if Trimming overflow or underflow occurred or not
00569   * @rmtoll ISR          TRIMOVF       LL_CRS_IsActiveFlag_TRIMOVF
00570   * @retval State of bit (1 or 0).
00571   */
00572 __STATIC_INLINE uint32_t LL_CRS_IsActiveFlag_TRIMOVF(void)
00573 {
00574   return ((READ_BIT(CRS->ISR, CRS_ISR_TRIMOVF) == (CRS_ISR_TRIMOVF)) ? 1UL : 0UL);
00575 }
00576 
00577 /**
00578   * @brief  Clear the SYNC event OK flag
00579   * @rmtoll ICR          SYNCOKC       LL_CRS_ClearFlag_SYNCOK
00580   * @retval None
00581   */
00582 __STATIC_INLINE void LL_CRS_ClearFlag_SYNCOK(void)
00583 {
00584   WRITE_REG(CRS->ICR, CRS_ICR_SYNCOKC);
00585 }
00586 
00587 /**
00588   * @brief  Clear the  SYNC warning flag
00589   * @rmtoll ICR          SYNCWARNC     LL_CRS_ClearFlag_SYNCWARN
00590   * @retval None
00591   */
00592 __STATIC_INLINE void LL_CRS_ClearFlag_SYNCWARN(void)
00593 {
00594   WRITE_REG(CRS->ICR, CRS_ICR_SYNCWARNC);
00595 }
00596 
00597 /**
00598   * @brief  Clear TRIMOVF, SYNCMISS and SYNCERR bits and consequently also
00599   * the ERR flag
00600   * @rmtoll ICR          ERRC          LL_CRS_ClearFlag_ERR
00601   * @retval None
00602   */
00603 __STATIC_INLINE void LL_CRS_ClearFlag_ERR(void)
00604 {
00605   WRITE_REG(CRS->ICR, CRS_ICR_ERRC);
00606 }
00607 
00608 /**
00609   * @brief  Clear Expected SYNC flag
00610   * @rmtoll ICR          ESYNCC        LL_CRS_ClearFlag_ESYNC
00611   * @retval None
00612   */
00613 __STATIC_INLINE void LL_CRS_ClearFlag_ESYNC(void)
00614 {
00615   WRITE_REG(CRS->ICR, CRS_ICR_ESYNCC);
00616 }
00617 
00618 /**
00619   * @}
00620   */
00621 
00622 /** @defgroup CRS_LL_EF_IT_Management IT_Management
00623   * @{
00624   */
00625 
00626 /**
00627   * @brief  Enable SYNC event OK interrupt
00628   * @rmtoll CR           SYNCOKIE      LL_CRS_EnableIT_SYNCOK
00629   * @retval None
00630   */
00631 __STATIC_INLINE void LL_CRS_EnableIT_SYNCOK(void)
00632 {
00633   SET_BIT(CRS->CR, CRS_CR_SYNCOKIE);
00634 }
00635 
00636 /**
00637   * @brief  Disable SYNC event OK interrupt
00638   * @rmtoll CR           SYNCOKIE      LL_CRS_DisableIT_SYNCOK
00639   * @retval None
00640   */
00641 __STATIC_INLINE void LL_CRS_DisableIT_SYNCOK(void)
00642 {
00643   CLEAR_BIT(CRS->CR, CRS_CR_SYNCOKIE);
00644 }
00645 
00646 /**
00647   * @brief  Check if SYNC event OK interrupt is enabled or not
00648   * @rmtoll CR           SYNCOKIE      LL_CRS_IsEnabledIT_SYNCOK
00649   * @retval State of bit (1 or 0).
00650   */
00651 __STATIC_INLINE uint32_t LL_CRS_IsEnabledIT_SYNCOK(void)
00652 {
00653   return ((READ_BIT(CRS->CR, CRS_CR_SYNCOKIE) == (CRS_CR_SYNCOKIE)) ? 1UL : 0UL);
00654 }
00655 
00656 /**
00657   * @brief  Enable SYNC warning interrupt
00658   * @rmtoll CR           SYNCWARNIE    LL_CRS_EnableIT_SYNCWARN
00659   * @retval None
00660   */
00661 __STATIC_INLINE void LL_CRS_EnableIT_SYNCWARN(void)
00662 {
00663   SET_BIT(CRS->CR, CRS_CR_SYNCWARNIE);
00664 }
00665 
00666 /**
00667   * @brief  Disable SYNC warning interrupt
00668   * @rmtoll CR           SYNCWARNIE    LL_CRS_DisableIT_SYNCWARN
00669   * @retval None
00670   */
00671 __STATIC_INLINE void LL_CRS_DisableIT_SYNCWARN(void)
00672 {
00673   CLEAR_BIT(CRS->CR, CRS_CR_SYNCWARNIE);
00674 }
00675 
00676 /**
00677   * @brief  Check if SYNC warning interrupt is enabled or not
00678   * @rmtoll CR           SYNCWARNIE    LL_CRS_IsEnabledIT_SYNCWARN
00679   * @retval State of bit (1 or 0).
00680   */
00681 __STATIC_INLINE uint32_t LL_CRS_IsEnabledIT_SYNCWARN(void)
00682 {
00683   return ((READ_BIT(CRS->CR, CRS_CR_SYNCWARNIE) == (CRS_CR_SYNCWARNIE)) ? 1UL : 0UL);
00684 }
00685 
00686 /**
00687   * @brief  Enable Synchronization or trimming error interrupt
00688   * @rmtoll CR           ERRIE         LL_CRS_EnableIT_ERR
00689   * @retval None
00690   */
00691 __STATIC_INLINE void LL_CRS_EnableIT_ERR(void)
00692 {
00693   SET_BIT(CRS->CR, CRS_CR_ERRIE);
00694 }
00695 
00696 /**
00697   * @brief  Disable Synchronization or trimming error interrupt
00698   * @rmtoll CR           ERRIE         LL_CRS_DisableIT_ERR
00699   * @retval None
00700   */
00701 __STATIC_INLINE void LL_CRS_DisableIT_ERR(void)
00702 {
00703   CLEAR_BIT(CRS->CR, CRS_CR_ERRIE);
00704 }
00705 
00706 /**
00707   * @brief  Check if Synchronization or trimming error interrupt is enabled or not
00708   * @rmtoll CR           ERRIE         LL_CRS_IsEnabledIT_ERR
00709   * @retval State of bit (1 or 0).
00710   */
00711 __STATIC_INLINE uint32_t LL_CRS_IsEnabledIT_ERR(void)
00712 {
00713   return ((READ_BIT(CRS->CR, CRS_CR_ERRIE) == (CRS_CR_ERRIE)) ? 1UL : 0UL);
00714 }
00715 
00716 /**
00717   * @brief  Enable Expected SYNC interrupt
00718   * @rmtoll CR           ESYNCIE       LL_CRS_EnableIT_ESYNC
00719   * @retval None
00720   */
00721 __STATIC_INLINE void LL_CRS_EnableIT_ESYNC(void)
00722 {
00723   SET_BIT(CRS->CR, CRS_CR_ESYNCIE);
00724 }
00725 
00726 /**
00727   * @brief  Disable Expected SYNC interrupt
00728   * @rmtoll CR           ESYNCIE       LL_CRS_DisableIT_ESYNC
00729   * @retval None
00730   */
00731 __STATIC_INLINE void LL_CRS_DisableIT_ESYNC(void)
00732 {
00733   CLEAR_BIT(CRS->CR, CRS_CR_ESYNCIE);
00734 }
00735 
00736 /**
00737   * @brief  Check if Expected SYNC interrupt is enabled or not
00738   * @rmtoll CR           ESYNCIE       LL_CRS_IsEnabledIT_ESYNC
00739   * @retval State of bit (1 or 0).
00740   */
00741 __STATIC_INLINE uint32_t LL_CRS_IsEnabledIT_ESYNC(void)
00742 {
00743   return ((READ_BIT(CRS->CR, CRS_CR_ESYNCIE) == (CRS_CR_ESYNCIE)) ? 1UL : 0UL);
00744 }
00745 
00746 /**
00747   * @}
00748   */
00749 
00750 #if defined(USE_FULL_LL_DRIVER)
00751 /** @defgroup CRS_LL_EF_Init Initialization and de-initialization functions
00752   * @{
00753   */
00754 
00755 ErrorStatus LL_CRS_DeInit(void);
00756 
00757 /**
00758   * @}
00759   */
00760 #endif /* USE_FULL_LL_DRIVER */
00761 
00762 /**
00763   * @}
00764   */
00765 
00766 /**
00767   * @}
00768   */
00769 
00770 #endif /* defined(CRS) */
00771 
00772 /**
00773   * @}
00774   */
00775 
00776 #ifdef __cplusplus
00777 }
00778 #endif
00779 
00780 #endif /* STM32H7xx_LL_CRS_H */