The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Dependents:   hello SerialTestv11 SerialTestv12 Sierpinski ... more

mbed 2

This is the mbed 2 library. If you'd like to learn about Mbed OS please see the mbed-os docs.

Committer:
AnnaBridge
Date:
Wed Jun 21 17:31:38 2017 +0100
Revision:
145:64910690c574
Parent:
128:9bcdf88f62b0
Release 145 of the mbed library.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Kojto 122:f9eeca106725 1 /**
Kojto 122:f9eeca106725 2 ******************************************************************************
Kojto 122:f9eeca106725 3 * @file stm32l4xx_ll_crs.h
Kojto 122:f9eeca106725 4 * @author MCD Application Team
AnnaBridge 145:64910690c574 5 * @version V1.7.1
AnnaBridge 145:64910690c574 6 * @date 21-April-2017
Kojto 122:f9eeca106725 7 * @brief Header file of CRS LL module.
Kojto 122:f9eeca106725 8 ******************************************************************************
Kojto 122:f9eeca106725 9 * @attention
Kojto 122:f9eeca106725 10 *
AnnaBridge 145:64910690c574 11 * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
Kojto 122:f9eeca106725 12 *
Kojto 122:f9eeca106725 13 * Redistribution and use in source and binary forms, with or without modification,
Kojto 122:f9eeca106725 14 * are permitted provided that the following conditions are met:
Kojto 122:f9eeca106725 15 * 1. Redistributions of source code must retain the above copyright notice,
Kojto 122:f9eeca106725 16 * this list of conditions and the following disclaimer.
Kojto 122:f9eeca106725 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
Kojto 122:f9eeca106725 18 * this list of conditions and the following disclaimer in the documentation
Kojto 122:f9eeca106725 19 * and/or other materials provided with the distribution.
Kojto 122:f9eeca106725 20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
Kojto 122:f9eeca106725 21 * may be used to endorse or promote products derived from this software
Kojto 122:f9eeca106725 22 * without specific prior written permission.
Kojto 122:f9eeca106725 23 *
Kojto 122:f9eeca106725 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
Kojto 122:f9eeca106725 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
Kojto 122:f9eeca106725 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
Kojto 122:f9eeca106725 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
Kojto 122:f9eeca106725 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
Kojto 122:f9eeca106725 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
Kojto 122:f9eeca106725 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
Kojto 122:f9eeca106725 31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
Kojto 122:f9eeca106725 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
Kojto 122:f9eeca106725 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Kojto 122:f9eeca106725 34 *
Kojto 122:f9eeca106725 35 ******************************************************************************
Kojto 122:f9eeca106725 36 */
Kojto 122:f9eeca106725 37
Kojto 122:f9eeca106725 38 /* Define to prevent recursive inclusion -------------------------------------*/
Kojto 122:f9eeca106725 39 #ifndef __STM32L4xx_LL_CRS_H
Kojto 122:f9eeca106725 40 #define __STM32L4xx_LL_CRS_H
Kojto 122:f9eeca106725 41
Kojto 122:f9eeca106725 42 #ifdef __cplusplus
Kojto 122:f9eeca106725 43 extern "C" {
Kojto 122:f9eeca106725 44 #endif
Kojto 122:f9eeca106725 45
Kojto 122:f9eeca106725 46 /* Includes ------------------------------------------------------------------*/
Kojto 122:f9eeca106725 47 #include "stm32l4xx.h"
Kojto 122:f9eeca106725 48
Kojto 122:f9eeca106725 49 /** @addtogroup STM32L4xx_LL_Driver
Kojto 122:f9eeca106725 50 * @{
Kojto 122:f9eeca106725 51 */
Kojto 122:f9eeca106725 52
Kojto 122:f9eeca106725 53 #if defined(CRS)
Kojto 122:f9eeca106725 54
Kojto 122:f9eeca106725 55 /** @defgroup CRS_LL CRS
Kojto 122:f9eeca106725 56 * @{
Kojto 122:f9eeca106725 57 */
Kojto 122:f9eeca106725 58
Kojto 122:f9eeca106725 59 /* Private types -------------------------------------------------------------*/
Kojto 122:f9eeca106725 60 /* Private variables ---------------------------------------------------------*/
Kojto 122:f9eeca106725 61 /* Private constants ---------------------------------------------------------*/
Kojto 122:f9eeca106725 62 /* Private macros ------------------------------------------------------------*/
Kojto 122:f9eeca106725 63
Kojto 122:f9eeca106725 64 /* Exported types ------------------------------------------------------------*/
Kojto 122:f9eeca106725 65 /* Exported constants --------------------------------------------------------*/
Kojto 122:f9eeca106725 66 /** @defgroup CRS_LL_Exported_Constants CRS Exported Constants
Kojto 122:f9eeca106725 67 * @{
Kojto 122:f9eeca106725 68 */
Kojto 122:f9eeca106725 69
Kojto 122:f9eeca106725 70 /** @defgroup CRS_LL_EC_GET_FLAG Get Flags Defines
Kojto 122:f9eeca106725 71 * @brief Flags defines which can be used with LL_CRS_ReadReg function
Kojto 122:f9eeca106725 72 * @{
Kojto 122:f9eeca106725 73 */
Kojto 122:f9eeca106725 74 #define LL_CRS_ISR_SYNCOKF CRS_ISR_SYNCOKF
Kojto 122:f9eeca106725 75 #define LL_CRS_ISR_SYNCWARNF CRS_ISR_SYNCWARNF
Kojto 122:f9eeca106725 76 #define LL_CRS_ISR_ERRF CRS_ISR_ERRF
Kojto 122:f9eeca106725 77 #define LL_CRS_ISR_ESYNCF CRS_ISR_ESYNCF
Kojto 122:f9eeca106725 78 #define LL_CRS_ISR_SYNCERR CRS_ISR_SYNCERR
Kojto 122:f9eeca106725 79 #define LL_CRS_ISR_SYNCMISS CRS_ISR_SYNCMISS
Kojto 122:f9eeca106725 80 #define LL_CRS_ISR_TRIMOVF CRS_ISR_TRIMOVF
Kojto 122:f9eeca106725 81 /**
Kojto 122:f9eeca106725 82 * @}
Kojto 122:f9eeca106725 83 */
Kojto 122:f9eeca106725 84
Kojto 122:f9eeca106725 85 /** @defgroup CRS_LL_EC_IT IT Defines
Kojto 122:f9eeca106725 86 * @brief IT defines which can be used with LL_CRS_ReadReg and LL_CRS_WriteReg functions
Kojto 122:f9eeca106725 87 * @{
Kojto 122:f9eeca106725 88 */
Kojto 122:f9eeca106725 89 #define LL_CRS_CR_SYNCOKIE CRS_CR_SYNCOKIE
Kojto 122:f9eeca106725 90 #define LL_CRS_CR_SYNCWARNIE CRS_CR_SYNCWARNIE
Kojto 122:f9eeca106725 91 #define LL_CRS_CR_ERRIE CRS_CR_ERRIE
Kojto 122:f9eeca106725 92 #define LL_CRS_CR_ESYNCIE CRS_CR_ESYNCIE
Kojto 122:f9eeca106725 93 /**
Kojto 122:f9eeca106725 94 * @}
Kojto 122:f9eeca106725 95 */
Kojto 122:f9eeca106725 96
Kojto 122:f9eeca106725 97 /** @defgroup CRS_LL_EC_SYNC_DIV Synchronization Signal Divider
Kojto 122:f9eeca106725 98 * @{
Kojto 122:f9eeca106725 99 */
Kojto 122:f9eeca106725 100 #define LL_CRS_SYNC_DIV_1 ((uint32_t)0x00U) /*!< Synchro Signal not divided (default) */
Kojto 122:f9eeca106725 101 #define LL_CRS_SYNC_DIV_2 CRS_CFGR_SYNCDIV_0 /*!< Synchro Signal divided by 2 */
Kojto 122:f9eeca106725 102 #define LL_CRS_SYNC_DIV_4 CRS_CFGR_SYNCDIV_1 /*!< Synchro Signal divided by 4 */
Kojto 122:f9eeca106725 103 #define LL_CRS_SYNC_DIV_8 (CRS_CFGR_SYNCDIV_1 | CRS_CFGR_SYNCDIV_0) /*!< Synchro Signal divided by 8 */
Kojto 122:f9eeca106725 104 #define LL_CRS_SYNC_DIV_16 CRS_CFGR_SYNCDIV_2 /*!< Synchro Signal divided by 16 */
Kojto 122:f9eeca106725 105 #define LL_CRS_SYNC_DIV_32 (CRS_CFGR_SYNCDIV_2 | CRS_CFGR_SYNCDIV_0) /*!< Synchro Signal divided by 32 */
Kojto 122:f9eeca106725 106 #define LL_CRS_SYNC_DIV_64 (CRS_CFGR_SYNCDIV_2 | CRS_CFGR_SYNCDIV_1) /*!< Synchro Signal divided by 64 */
Kojto 122:f9eeca106725 107 #define LL_CRS_SYNC_DIV_128 CRS_CFGR_SYNCDIV /*!< Synchro Signal divided by 128 */
Kojto 122:f9eeca106725 108 /**
Kojto 122:f9eeca106725 109 * @}
Kojto 122:f9eeca106725 110 */
Kojto 122:f9eeca106725 111
Kojto 122:f9eeca106725 112 /** @defgroup CRS_LL_EC_SYNC_SOURCE Synchronization Signal Source
Kojto 122:f9eeca106725 113 * @{
Kojto 122:f9eeca106725 114 */
Kojto 122:f9eeca106725 115 #define LL_CRS_SYNC_SOURCE_GPIO ((uint32_t)0x00U) /*!< Synchro Signal soucre GPIO */
Kojto 122:f9eeca106725 116 #define LL_CRS_SYNC_SOURCE_LSE CRS_CFGR_SYNCSRC_0 /*!< Synchro Signal source LSE */
Kojto 122:f9eeca106725 117 #define LL_CRS_SYNC_SOURCE_USB CRS_CFGR_SYNCSRC_1 /*!< Synchro Signal source USB SOF (default)*/
Kojto 122:f9eeca106725 118 /**
Kojto 122:f9eeca106725 119 * @}
Kojto 122:f9eeca106725 120 */
Kojto 122:f9eeca106725 121
Kojto 122:f9eeca106725 122 /** @defgroup CRS_LL_EC_SYNC_POLARITY Synchronization Signal Polarity
Kojto 122:f9eeca106725 123 * @{
Kojto 122:f9eeca106725 124 */
Kojto 122:f9eeca106725 125 #define LL_CRS_SYNC_POLARITY_RISING ((uint32_t)0x00U) /*!< Synchro Active on rising edge (default) */
Kojto 122:f9eeca106725 126 #define LL_CRS_SYNC_POLARITY_FALLING CRS_CFGR_SYNCPOL /*!< Synchro Active on falling edge */
Kojto 122:f9eeca106725 127 /**
Kojto 122:f9eeca106725 128 * @}
Kojto 122:f9eeca106725 129 */
Kojto 122:f9eeca106725 130
Kojto 122:f9eeca106725 131 /** @defgroup CRS_LL_EC_FREQERRORDIR Frequency Error Direction
Kojto 122:f9eeca106725 132 * @{
Kojto 122:f9eeca106725 133 */
Kojto 122:f9eeca106725 134 #define LL_CRS_FREQ_ERROR_DIR_UP ((uint32_t)0x00U) /*!< Upcounting direction, the actual frequency is above the target */
Kojto 122:f9eeca106725 135 #define LL_CRS_FREQ_ERROR_DIR_DOWN ((uint32_t)CRS_ISR_FEDIR) /*!< Downcounting direction, the actual frequency is below the target */
Kojto 122:f9eeca106725 136 /**
Kojto 122:f9eeca106725 137 * @}
Kojto 122:f9eeca106725 138 */
Kojto 122:f9eeca106725 139
Kojto 122:f9eeca106725 140 /** @defgroup CRS_LL_EC_DEFAULTVALUES Default Values
Kojto 122:f9eeca106725 141 * @{
Kojto 122:f9eeca106725 142 */
Kojto 122:f9eeca106725 143 /**
Kojto 122:f9eeca106725 144 * @brief Reset value of the RELOAD field
Kojto 122:f9eeca106725 145 * @note The reset value of the RELOAD field corresponds to a target frequency of 48 MHz
Kojto 122:f9eeca106725 146 * and a synchronization signal frequency of 1 kHz (SOF signal from USB)
Kojto 122:f9eeca106725 147 */
Kojto 122:f9eeca106725 148 #define LL_CRS_RELOADVALUE_DEFAULT ((uint32_t)0xBB7FU)
Kojto 122:f9eeca106725 149
Kojto 122:f9eeca106725 150 /**
Kojto 122:f9eeca106725 151 * @brief Reset value of Frequency error limit.
Kojto 122:f9eeca106725 152 */
Kojto 122:f9eeca106725 153 #define LL_CRS_ERRORLIMIT_DEFAULT ((uint32_t)0x22U)
Kojto 122:f9eeca106725 154
Kojto 122:f9eeca106725 155 /**
Kojto 122:f9eeca106725 156 * @brief Reset value of the HSI48 Calibration field
Kojto 122:f9eeca106725 157 * @note The default value is 32, which corresponds to the middle of the trimming interval.
Kojto 122:f9eeca106725 158 * The trimming step is around 67 kHz between two consecutive TRIM steps.
Kojto 122:f9eeca106725 159 * A higher TRIM value corresponds to a higher output frequency
Kojto 122:f9eeca106725 160 */
Kojto 122:f9eeca106725 161 #define LL_CRS_HSI48CALIBRATION_DEFAULT ((uint32_t)0x20U)
Kojto 122:f9eeca106725 162 /**
Kojto 122:f9eeca106725 163 * @}
Kojto 122:f9eeca106725 164 */
Kojto 122:f9eeca106725 165
Kojto 122:f9eeca106725 166 /**
Kojto 122:f9eeca106725 167 * @}
Kojto 122:f9eeca106725 168 */
Kojto 122:f9eeca106725 169
Kojto 122:f9eeca106725 170 /* Exported macro ------------------------------------------------------------*/
Kojto 122:f9eeca106725 171 /** @defgroup CRS_LL_Exported_Macros CRS Exported Macros
Kojto 122:f9eeca106725 172 * @{
Kojto 122:f9eeca106725 173 */
Kojto 122:f9eeca106725 174
Kojto 122:f9eeca106725 175 /** @defgroup CRS_LL_EM_WRITE_READ Common Write and read registers Macros
Kojto 122:f9eeca106725 176 * @{
Kojto 122:f9eeca106725 177 */
Kojto 122:f9eeca106725 178
Kojto 122:f9eeca106725 179 /**
Kojto 122:f9eeca106725 180 * @brief Write a value in CRS register
Kojto 122:f9eeca106725 181 * @param __INSTANCE__ CRS Instance
Kojto 122:f9eeca106725 182 * @param __REG__ Register to be written
Kojto 122:f9eeca106725 183 * @param __VALUE__ Value to be written in the register
Kojto 122:f9eeca106725 184 * @retval None
Kojto 122:f9eeca106725 185 */
Kojto 122:f9eeca106725 186 #define LL_CRS_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
Kojto 122:f9eeca106725 187
Kojto 122:f9eeca106725 188 /**
Kojto 122:f9eeca106725 189 * @brief Read a value in CRS register
Kojto 122:f9eeca106725 190 * @param __INSTANCE__ CRS Instance
Kojto 122:f9eeca106725 191 * @param __REG__ Register to be read
Kojto 122:f9eeca106725 192 * @retval Register value
Kojto 122:f9eeca106725 193 */
Kojto 122:f9eeca106725 194 #define LL_CRS_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
Kojto 122:f9eeca106725 195 /**
Kojto 122:f9eeca106725 196 * @}
Kojto 122:f9eeca106725 197 */
Kojto 122:f9eeca106725 198
Kojto 122:f9eeca106725 199 /** @defgroup CRS_LL_EM_Exported_Macros_Calculate_Reload Exported_Macros_Calculate_Reload
Kojto 122:f9eeca106725 200 * @{
Kojto 122:f9eeca106725 201 */
Kojto 122:f9eeca106725 202
Kojto 122:f9eeca106725 203 /**
Kojto 122:f9eeca106725 204 * @brief Macro to calculate reload value to be set in CRS register according to target and sync frequencies
Kojto 122:f9eeca106725 205 * @note The RELOAD value should be selected according to the ratio between
Kojto 122:f9eeca106725 206 * the target frequency and the frequency of the synchronization source after
Kojto 122:f9eeca106725 207 * prescaling. It is then decreased by one in order to reach the expected
Kojto 122:f9eeca106725 208 * synchronization on the zero value. The formula is the following:
Kojto 122:f9eeca106725 209 * RELOAD = (fTARGET / fSYNC) -1
Kojto 122:f9eeca106725 210 * @param __FTARGET__ Target frequency (value in Hz)
Kojto 122:f9eeca106725 211 * @param __FSYNC__ Synchronization signal frequency (value in Hz)
Kojto 122:f9eeca106725 212 * @retval Reload value (in Hz)
Kojto 122:f9eeca106725 213 */
Kojto 122:f9eeca106725 214 #define __LL_CRS_CALC_CALCULATE_RELOADVALUE(__FTARGET__, __FSYNC__) (((__FTARGET__) / (__FSYNC__)) - 1U)
Kojto 122:f9eeca106725 215
Kojto 122:f9eeca106725 216 /**
Kojto 122:f9eeca106725 217 * @}
Kojto 122:f9eeca106725 218 */
Kojto 122:f9eeca106725 219
Kojto 122:f9eeca106725 220 /**
Kojto 122:f9eeca106725 221 * @}
Kojto 122:f9eeca106725 222 */
Kojto 122:f9eeca106725 223
Kojto 122:f9eeca106725 224 /* Exported functions --------------------------------------------------------*/
Kojto 122:f9eeca106725 225 /** @defgroup CRS_LL_Exported_Functions CRS Exported Functions
Kojto 122:f9eeca106725 226 * @{
Kojto 122:f9eeca106725 227 */
Kojto 122:f9eeca106725 228
Kojto 122:f9eeca106725 229 /** @defgroup CRS_LL_EF_Configuration Configuration
Kojto 122:f9eeca106725 230 * @{
Kojto 122:f9eeca106725 231 */
Kojto 122:f9eeca106725 232
Kojto 122:f9eeca106725 233 /**
Kojto 122:f9eeca106725 234 * @brief Enable Frequency error counter
Kojto 122:f9eeca106725 235 * @note When this bit is set, the CRS_CFGR register is write-protected and cannot be modified
Kojto 122:f9eeca106725 236 * @rmtoll CR CEN LL_CRS_EnableFreqErrorCounter
Kojto 122:f9eeca106725 237 * @retval None
Kojto 122:f9eeca106725 238 */
Kojto 122:f9eeca106725 239 __STATIC_INLINE void LL_CRS_EnableFreqErrorCounter(void)
Kojto 122:f9eeca106725 240 {
Kojto 122:f9eeca106725 241 SET_BIT(CRS->CR, CRS_CR_CEN);
Kojto 122:f9eeca106725 242 }
Kojto 122:f9eeca106725 243
Kojto 122:f9eeca106725 244 /**
Kojto 122:f9eeca106725 245 * @brief Disable Frequency error counter
Kojto 122:f9eeca106725 246 * @rmtoll CR CEN LL_CRS_DisableFreqErrorCounter
Kojto 122:f9eeca106725 247 * @retval None
Kojto 122:f9eeca106725 248 */
Kojto 122:f9eeca106725 249 __STATIC_INLINE void LL_CRS_DisableFreqErrorCounter(void)
Kojto 122:f9eeca106725 250 {
Kojto 122:f9eeca106725 251 CLEAR_BIT(CRS->CR, CRS_CR_CEN);
Kojto 122:f9eeca106725 252 }
Kojto 122:f9eeca106725 253
Kojto 122:f9eeca106725 254 /**
Kojto 122:f9eeca106725 255 * @brief Check if Frequency error counter is enabled or not
Kojto 122:f9eeca106725 256 * @rmtoll CR CEN LL_CRS_IsEnabledFreqErrorCounter
Kojto 122:f9eeca106725 257 * @retval State of bit (1 or 0).
Kojto 122:f9eeca106725 258 */
Kojto 122:f9eeca106725 259 __STATIC_INLINE uint32_t LL_CRS_IsEnabledFreqErrorCounter(void)
Kojto 122:f9eeca106725 260 {
Kojto 122:f9eeca106725 261 return (READ_BIT(CRS->CR, CRS_CR_CEN) == (CRS_CR_CEN));
Kojto 122:f9eeca106725 262 }
Kojto 122:f9eeca106725 263
Kojto 122:f9eeca106725 264 /**
Kojto 122:f9eeca106725 265 * @brief Enable Automatic trimming counter
Kojto 122:f9eeca106725 266 * @rmtoll CR AUTOTRIMEN LL_CRS_EnableAutoTrimming
Kojto 122:f9eeca106725 267 * @retval None
Kojto 122:f9eeca106725 268 */
Kojto 122:f9eeca106725 269 __STATIC_INLINE void LL_CRS_EnableAutoTrimming(void)
Kojto 122:f9eeca106725 270 {
Kojto 122:f9eeca106725 271 SET_BIT(CRS->CR, CRS_CR_AUTOTRIMEN);
Kojto 122:f9eeca106725 272 }
Kojto 122:f9eeca106725 273
Kojto 122:f9eeca106725 274 /**
Kojto 122:f9eeca106725 275 * @brief Disable Automatic trimming counter
Kojto 122:f9eeca106725 276 * @rmtoll CR AUTOTRIMEN LL_CRS_DisableAutoTrimming
Kojto 122:f9eeca106725 277 * @retval None
Kojto 122:f9eeca106725 278 */
Kojto 122:f9eeca106725 279 __STATIC_INLINE void LL_CRS_DisableAutoTrimming(void)
Kojto 122:f9eeca106725 280 {
Kojto 122:f9eeca106725 281 CLEAR_BIT(CRS->CR, CRS_CR_AUTOTRIMEN);
Kojto 122:f9eeca106725 282 }
Kojto 122:f9eeca106725 283
Kojto 122:f9eeca106725 284 /**
Kojto 122:f9eeca106725 285 * @brief Check if Automatic trimming is enabled or not
Kojto 122:f9eeca106725 286 * @rmtoll CR AUTOTRIMEN LL_CRS_IsEnabledAutoTrimming
Kojto 122:f9eeca106725 287 * @retval State of bit (1 or 0).
Kojto 122:f9eeca106725 288 */
Kojto 122:f9eeca106725 289 __STATIC_INLINE uint32_t LL_CRS_IsEnabledAutoTrimming(void)
Kojto 122:f9eeca106725 290 {
Kojto 122:f9eeca106725 291 return (READ_BIT(CRS->CR, CRS_CR_AUTOTRIMEN) == (CRS_CR_AUTOTRIMEN));
Kojto 122:f9eeca106725 292 }
Kojto 122:f9eeca106725 293
Kojto 122:f9eeca106725 294 /**
Kojto 122:f9eeca106725 295 * @brief Set HSI48 oscillator smooth trimming
Kojto 122:f9eeca106725 296 * @note When the AUTOTRIMEN bit is set, this field is controlled by hardware and is read-only
Kojto 122:f9eeca106725 297 * @rmtoll CR TRIM LL_CRS_SetHSI48SmoothTrimming
Kojto 122:f9eeca106725 298 * @param Value a number between Min_Data = 0 and Max_Data = 63
Kojto 122:f9eeca106725 299 * @note Default value can be set thanks to @ref LL_CRS_HSI48CALIBRATION_DEFAULT
Kojto 122:f9eeca106725 300 * @retval None
Kojto 122:f9eeca106725 301 */
Kojto 122:f9eeca106725 302 __STATIC_INLINE void LL_CRS_SetHSI48SmoothTrimming(uint32_t Value)
Kojto 122:f9eeca106725 303 {
AnnaBridge 145:64910690c574 304 MODIFY_REG(CRS->CR, CRS_CR_TRIM, Value << CRS_CR_TRIM_Pos);
Kojto 122:f9eeca106725 305 }
Kojto 122:f9eeca106725 306
Kojto 122:f9eeca106725 307 /**
Kojto 122:f9eeca106725 308 * @brief Get HSI48 oscillator smooth trimming
Kojto 122:f9eeca106725 309 * @rmtoll CR TRIM LL_CRS_GetHSI48SmoothTrimming
Kojto 122:f9eeca106725 310 * @retval a number between Min_Data = 0 and Max_Data = 63
Kojto 122:f9eeca106725 311 */
Kojto 122:f9eeca106725 312 __STATIC_INLINE uint32_t LL_CRS_GetHSI48SmoothTrimming(void)
Kojto 122:f9eeca106725 313 {
AnnaBridge 145:64910690c574 314 return (uint32_t)(READ_BIT(CRS->CR, CRS_CR_TRIM) >> CRS_CR_TRIM_Pos);
Kojto 122:f9eeca106725 315 }
Kojto 122:f9eeca106725 316
Kojto 122:f9eeca106725 317 /**
Kojto 122:f9eeca106725 318 * @brief Set counter reload value
Kojto 122:f9eeca106725 319 * @rmtoll CFGR RELOAD LL_CRS_SetReloadCounter
Kojto 122:f9eeca106725 320 * @param Value a number between Min_Data = 0 and Max_Data = 0xFFFF
Kojto 122:f9eeca106725 321 * @note Default value can be set thanks to @ref LL_CRS_RELOADVALUE_DEFAULT
Kojto 122:f9eeca106725 322 * Otherwise it can be calculated in using macro @ref __LL_CRS_CALC_CALCULATE_RELOADVALUE (_FTARGET_, _FSYNC_)
Kojto 122:f9eeca106725 323 * @retval None
Kojto 122:f9eeca106725 324 */
Kojto 122:f9eeca106725 325 __STATIC_INLINE void LL_CRS_SetReloadCounter(uint32_t Value)
Kojto 122:f9eeca106725 326 {
Kojto 122:f9eeca106725 327 MODIFY_REG(CRS->CFGR, CRS_CFGR_RELOAD, Value);
Kojto 122:f9eeca106725 328 }
Kojto 122:f9eeca106725 329
Kojto 122:f9eeca106725 330 /**
Kojto 122:f9eeca106725 331 * @brief Get counter reload value
Kojto 122:f9eeca106725 332 * @rmtoll CFGR RELOAD LL_CRS_GetReloadCounter
Kojto 122:f9eeca106725 333 * @retval a number between Min_Data = 0 and Max_Data = 0xFFFF
Kojto 122:f9eeca106725 334 */
Kojto 122:f9eeca106725 335 __STATIC_INLINE uint32_t LL_CRS_GetReloadCounter(void)
Kojto 122:f9eeca106725 336 {
Kojto 122:f9eeca106725 337 return (uint32_t)(READ_BIT(CRS->CFGR, CRS_CFGR_RELOAD));
Kojto 122:f9eeca106725 338 }
Kojto 122:f9eeca106725 339
Kojto 122:f9eeca106725 340 /**
Kojto 122:f9eeca106725 341 * @brief Set frequency error limit
Kojto 122:f9eeca106725 342 * @rmtoll CFGR FELIM LL_CRS_SetFreqErrorLimit
Kojto 122:f9eeca106725 343 * @param Value a number between Min_Data = 0 and Max_Data = 255
Kojto 122:f9eeca106725 344 * @note Default value can be set thanks to @ref LL_CRS_ERRORLIMIT_DEFAULT
Kojto 122:f9eeca106725 345 * @retval None
Kojto 122:f9eeca106725 346 */
Kojto 122:f9eeca106725 347 __STATIC_INLINE void LL_CRS_SetFreqErrorLimit(uint32_t Value)
Kojto 122:f9eeca106725 348 {
AnnaBridge 145:64910690c574 349 MODIFY_REG(CRS->CFGR, CRS_CFGR_FELIM, Value << CRS_CFGR_FELIM_Pos);
Kojto 122:f9eeca106725 350 }
Kojto 122:f9eeca106725 351
Kojto 122:f9eeca106725 352 /**
Kojto 122:f9eeca106725 353 * @brief Get frequency error limit
Kojto 122:f9eeca106725 354 * @rmtoll CFGR FELIM LL_CRS_GetFreqErrorLimit
Kojto 122:f9eeca106725 355 * @retval A number between Min_Data = 0 and Max_Data = 255
Kojto 122:f9eeca106725 356 */
Kojto 122:f9eeca106725 357 __STATIC_INLINE uint32_t LL_CRS_GetFreqErrorLimit(void)
Kojto 122:f9eeca106725 358 {
AnnaBridge 145:64910690c574 359 return (uint32_t)(READ_BIT(CRS->CFGR, CRS_CFGR_FELIM) >> CRS_CFGR_FELIM_Pos);
Kojto 122:f9eeca106725 360 }
Kojto 122:f9eeca106725 361
Kojto 122:f9eeca106725 362 /**
Kojto 122:f9eeca106725 363 * @brief Set division factor for SYNC signal
Kojto 122:f9eeca106725 364 * @rmtoll CFGR SYNCDIV LL_CRS_SetSyncDivider
Kojto 122:f9eeca106725 365 * @param Divider This parameter can be one of the following values:
Kojto 122:f9eeca106725 366 * @arg @ref LL_CRS_SYNC_DIV_1
Kojto 122:f9eeca106725 367 * @arg @ref LL_CRS_SYNC_DIV_2
Kojto 122:f9eeca106725 368 * @arg @ref LL_CRS_SYNC_DIV_4
Kojto 122:f9eeca106725 369 * @arg @ref LL_CRS_SYNC_DIV_8
Kojto 122:f9eeca106725 370 * @arg @ref LL_CRS_SYNC_DIV_16
Kojto 122:f9eeca106725 371 * @arg @ref LL_CRS_SYNC_DIV_32
Kojto 122:f9eeca106725 372 * @arg @ref LL_CRS_SYNC_DIV_64
Kojto 122:f9eeca106725 373 * @arg @ref LL_CRS_SYNC_DIV_128
Kojto 122:f9eeca106725 374 * @retval None
Kojto 122:f9eeca106725 375 */
Kojto 122:f9eeca106725 376 __STATIC_INLINE void LL_CRS_SetSyncDivider(uint32_t Divider)
Kojto 122:f9eeca106725 377 {
Kojto 122:f9eeca106725 378 MODIFY_REG(CRS->CFGR, CRS_CFGR_SYNCDIV, Divider);
Kojto 122:f9eeca106725 379 }
Kojto 122:f9eeca106725 380
Kojto 122:f9eeca106725 381 /**
Kojto 122:f9eeca106725 382 * @brief Get division factor for SYNC signal
Kojto 122:f9eeca106725 383 * @rmtoll CFGR SYNCDIV LL_CRS_GetSyncDivider
Kojto 122:f9eeca106725 384 * @retval Returned value can be one of the following values:
Kojto 122:f9eeca106725 385 * @arg @ref LL_CRS_SYNC_DIV_1
Kojto 122:f9eeca106725 386 * @arg @ref LL_CRS_SYNC_DIV_2
Kojto 122:f9eeca106725 387 * @arg @ref LL_CRS_SYNC_DIV_4
Kojto 122:f9eeca106725 388 * @arg @ref LL_CRS_SYNC_DIV_8
Kojto 122:f9eeca106725 389 * @arg @ref LL_CRS_SYNC_DIV_16
Kojto 122:f9eeca106725 390 * @arg @ref LL_CRS_SYNC_DIV_32
Kojto 122:f9eeca106725 391 * @arg @ref LL_CRS_SYNC_DIV_64
Kojto 122:f9eeca106725 392 * @arg @ref LL_CRS_SYNC_DIV_128
Kojto 122:f9eeca106725 393 */
Kojto 122:f9eeca106725 394 __STATIC_INLINE uint32_t LL_CRS_GetSyncDivider(void)
Kojto 122:f9eeca106725 395 {
Kojto 122:f9eeca106725 396 return (uint32_t)(READ_BIT(CRS->CFGR, CRS_CFGR_SYNCDIV));
Kojto 122:f9eeca106725 397 }
Kojto 122:f9eeca106725 398
Kojto 122:f9eeca106725 399 /**
Kojto 122:f9eeca106725 400 * @brief Set SYNC signal source
Kojto 122:f9eeca106725 401 * @rmtoll CFGR SYNCSRC LL_CRS_SetSyncSignalSource
Kojto 122:f9eeca106725 402 * @param Source This parameter can be one of the following values:
Kojto 122:f9eeca106725 403 * @arg @ref LL_CRS_SYNC_SOURCE_GPIO
Kojto 122:f9eeca106725 404 * @arg @ref LL_CRS_SYNC_SOURCE_LSE
Kojto 122:f9eeca106725 405 * @arg @ref LL_CRS_SYNC_SOURCE_USB
Kojto 122:f9eeca106725 406 * @retval None
Kojto 122:f9eeca106725 407 */
Kojto 122:f9eeca106725 408 __STATIC_INLINE void LL_CRS_SetSyncSignalSource(uint32_t Source)
Kojto 122:f9eeca106725 409 {
Kojto 122:f9eeca106725 410 MODIFY_REG(CRS->CFGR, CRS_CFGR_SYNCSRC, Source);
Kojto 122:f9eeca106725 411 }
Kojto 122:f9eeca106725 412
Kojto 122:f9eeca106725 413 /**
Kojto 122:f9eeca106725 414 * @brief Get SYNC signal source
Kojto 122:f9eeca106725 415 * @rmtoll CFGR SYNCSRC LL_CRS_GetSyncSignalSource
Kojto 122:f9eeca106725 416 * @retval Returned value can be one of the following values:
Kojto 122:f9eeca106725 417 * @arg @ref LL_CRS_SYNC_SOURCE_GPIO
Kojto 122:f9eeca106725 418 * @arg @ref LL_CRS_SYNC_SOURCE_LSE
Kojto 122:f9eeca106725 419 * @arg @ref LL_CRS_SYNC_SOURCE_USB
Kojto 122:f9eeca106725 420 */
Kojto 122:f9eeca106725 421 __STATIC_INLINE uint32_t LL_CRS_GetSyncSignalSource(void)
Kojto 122:f9eeca106725 422 {
Kojto 122:f9eeca106725 423 return (uint32_t)(READ_BIT(CRS->CFGR, CRS_CFGR_SYNCSRC));
Kojto 122:f9eeca106725 424 }
Kojto 122:f9eeca106725 425
Kojto 122:f9eeca106725 426 /**
Kojto 122:f9eeca106725 427 * @brief Set input polarity for the SYNC signal source
Kojto 122:f9eeca106725 428 * @rmtoll CFGR SYNCPOL LL_CRS_SetSyncPolarity
Kojto 122:f9eeca106725 429 * @param Polarity This parameter can be one of the following values:
Kojto 122:f9eeca106725 430 * @arg @ref LL_CRS_SYNC_POLARITY_RISING
Kojto 122:f9eeca106725 431 * @arg @ref LL_CRS_SYNC_POLARITY_FALLING
Kojto 122:f9eeca106725 432 * @retval None
Kojto 122:f9eeca106725 433 */
Kojto 122:f9eeca106725 434 __STATIC_INLINE void LL_CRS_SetSyncPolarity(uint32_t Polarity)
Kojto 122:f9eeca106725 435 {
Kojto 122:f9eeca106725 436 MODIFY_REG(CRS->CFGR, CRS_CFGR_SYNCPOL, Polarity);
Kojto 122:f9eeca106725 437 }
Kojto 122:f9eeca106725 438
Kojto 122:f9eeca106725 439 /**
Kojto 122:f9eeca106725 440 * @brief Get input polarity for the SYNC signal source
Kojto 122:f9eeca106725 441 * @rmtoll CFGR SYNCPOL LL_CRS_GetSyncPolarity
Kojto 122:f9eeca106725 442 * @retval Returned value can be one of the following values:
Kojto 122:f9eeca106725 443 * @arg @ref LL_CRS_SYNC_POLARITY_RISING
Kojto 122:f9eeca106725 444 * @arg @ref LL_CRS_SYNC_POLARITY_FALLING
Kojto 122:f9eeca106725 445 */
Kojto 122:f9eeca106725 446 __STATIC_INLINE uint32_t LL_CRS_GetSyncPolarity(void)
Kojto 122:f9eeca106725 447 {
Kojto 122:f9eeca106725 448 return (uint32_t)(READ_BIT(CRS->CFGR, CRS_CFGR_SYNCPOL));
Kojto 122:f9eeca106725 449 }
Kojto 122:f9eeca106725 450
Kojto 122:f9eeca106725 451 /**
Kojto 122:f9eeca106725 452 * @brief Configure CRS for the synchronization
Kojto 122:f9eeca106725 453 * @rmtoll CR TRIM LL_CRS_ConfigSynchronization\n
Kojto 122:f9eeca106725 454 * CFGR RELOAD LL_CRS_ConfigSynchronization\n
Kojto 122:f9eeca106725 455 * CFGR FELIM LL_CRS_ConfigSynchronization\n
Kojto 122:f9eeca106725 456 * CFGR SYNCDIV LL_CRS_ConfigSynchronization\n
Kojto 122:f9eeca106725 457 * CFGR SYNCSRC LL_CRS_ConfigSynchronization\n
Kojto 122:f9eeca106725 458 * CFGR SYNCPOL LL_CRS_ConfigSynchronization
Kojto 122:f9eeca106725 459 * @param HSI48CalibrationValue a number between Min_Data = 0 and Max_Data = 63
Kojto 122:f9eeca106725 460 * @param ErrorLimitValue a number between Min_Data = 0 and Max_Data = 0xFFFF
Kojto 122:f9eeca106725 461 * @param ReloadValue a number between Min_Data = 0 and Max_Data = 255
Kojto 122:f9eeca106725 462 * @param Settings This parameter can be a combination of the following values:
Kojto 122:f9eeca106725 463 * @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
Kojto 122:f9eeca106725 464 * 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
Kojto 122:f9eeca106725 465 * @arg @ref LL_CRS_SYNC_SOURCE_GPIO or @ref LL_CRS_SYNC_SOURCE_LSE or @ref LL_CRS_SYNC_SOURCE_USB
Kojto 122:f9eeca106725 466 * @arg @ref LL_CRS_SYNC_POLARITY_RISING or @ref LL_CRS_SYNC_POLARITY_FALLING
Kojto 122:f9eeca106725 467 * @retval None
Kojto 122:f9eeca106725 468 */
Kojto 122:f9eeca106725 469 __STATIC_INLINE void LL_CRS_ConfigSynchronization(uint32_t HSI48CalibrationValue, uint32_t ErrorLimitValue, uint32_t ReloadValue, uint32_t Settings)
Kojto 122:f9eeca106725 470 {
Kojto 122:f9eeca106725 471 MODIFY_REG(CRS->CR, CRS_CR_TRIM, HSI48CalibrationValue);
Kojto 122:f9eeca106725 472 MODIFY_REG(CRS->CFGR,
Kojto 122:f9eeca106725 473 CRS_CFGR_RELOAD | CRS_CFGR_FELIM | CRS_CFGR_SYNCDIV | CRS_CFGR_SYNCSRC | CRS_CFGR_SYNCPOL,
AnnaBridge 145:64910690c574 474 ReloadValue | (ErrorLimitValue << CRS_CFGR_FELIM_Pos) | Settings);
Kojto 122:f9eeca106725 475 }
Kojto 122:f9eeca106725 476
Kojto 122:f9eeca106725 477 /**
Kojto 122:f9eeca106725 478 * @}
Kojto 122:f9eeca106725 479 */
Kojto 122:f9eeca106725 480
Kojto 122:f9eeca106725 481 /** @defgroup CRS_LL_EF_CRS_Management CRS_Management
Kojto 122:f9eeca106725 482 * @{
Kojto 122:f9eeca106725 483 */
Kojto 122:f9eeca106725 484
Kojto 122:f9eeca106725 485 /**
Kojto 122:f9eeca106725 486 * @brief Generate software SYNC event
Kojto 122:f9eeca106725 487 * @rmtoll CR SWSYNC LL_CRS_GenerateEvent_SWSYNC
Kojto 122:f9eeca106725 488 * @retval None
Kojto 122:f9eeca106725 489 */
Kojto 122:f9eeca106725 490 __STATIC_INLINE void LL_CRS_GenerateEvent_SWSYNC(void)
Kojto 122:f9eeca106725 491 {
Kojto 122:f9eeca106725 492 SET_BIT(CRS->CR, CRS_CR_SWSYNC);
Kojto 122:f9eeca106725 493 }
Kojto 122:f9eeca106725 494
Kojto 122:f9eeca106725 495 /**
Kojto 122:f9eeca106725 496 * @brief Get the frequency error direction latched in the time of the last
Kojto 122:f9eeca106725 497 * SYNC event
Kojto 122:f9eeca106725 498 * @rmtoll ISR FEDIR LL_CRS_GetFreqErrorDirection
Kojto 122:f9eeca106725 499 * @retval Returned value can be one of the following values:
Kojto 122:f9eeca106725 500 * @arg @ref LL_CRS_FREQ_ERROR_DIR_UP
Kojto 122:f9eeca106725 501 * @arg @ref LL_CRS_FREQ_ERROR_DIR_DOWN
Kojto 122:f9eeca106725 502 */
Kojto 122:f9eeca106725 503 __STATIC_INLINE uint32_t LL_CRS_GetFreqErrorDirection(void)
Kojto 122:f9eeca106725 504 {
Kojto 122:f9eeca106725 505 return (uint32_t)(READ_BIT(CRS->ISR, CRS_ISR_FEDIR));
Kojto 122:f9eeca106725 506 }
Kojto 122:f9eeca106725 507
Kojto 122:f9eeca106725 508 /**
Kojto 122:f9eeca106725 509 * @brief Get the frequency error counter value latched in the time of the last SYNC event
Kojto 122:f9eeca106725 510 * @rmtoll ISR FECAP LL_CRS_GetFreqErrorCapture
Kojto 122:f9eeca106725 511 * @retval A number between Min_Data = 0x0000 and Max_Data = 0xFFFF
Kojto 122:f9eeca106725 512 */
Kojto 122:f9eeca106725 513 __STATIC_INLINE uint32_t LL_CRS_GetFreqErrorCapture(void)
Kojto 122:f9eeca106725 514 {
AnnaBridge 145:64910690c574 515 return (uint32_t)(READ_BIT(CRS->ISR, CRS_ISR_FECAP) >> CRS_ISR_FECAP_Pos);
Kojto 122:f9eeca106725 516 }
Kojto 122:f9eeca106725 517
Kojto 122:f9eeca106725 518 /**
Kojto 122:f9eeca106725 519 * @}
Kojto 122:f9eeca106725 520 */
Kojto 122:f9eeca106725 521
Kojto 122:f9eeca106725 522 /** @defgroup CRS_LL_EF_FLAG_Management FLAG_Management
Kojto 122:f9eeca106725 523 * @{
Kojto 122:f9eeca106725 524 */
Kojto 122:f9eeca106725 525
Kojto 122:f9eeca106725 526 /**
Kojto 122:f9eeca106725 527 * @brief Check if SYNC event OK signal occurred or not
Kojto 122:f9eeca106725 528 * @rmtoll ISR SYNCOKF LL_CRS_IsActiveFlag_SYNCOK
Kojto 122:f9eeca106725 529 * @retval State of bit (1 or 0).
Kojto 122:f9eeca106725 530 */
Kojto 122:f9eeca106725 531 __STATIC_INLINE uint32_t LL_CRS_IsActiveFlag_SYNCOK(void)
Kojto 122:f9eeca106725 532 {
Kojto 122:f9eeca106725 533 return (READ_BIT(CRS->ISR, CRS_ISR_SYNCOKF) == (CRS_ISR_SYNCOKF));
Kojto 122:f9eeca106725 534 }
Kojto 122:f9eeca106725 535
Kojto 122:f9eeca106725 536 /**
Kojto 122:f9eeca106725 537 * @brief Check if SYNC warning signal occurred or not
Kojto 122:f9eeca106725 538 * @rmtoll ISR SYNCWARNF LL_CRS_IsActiveFlag_SYNCWARN
Kojto 122:f9eeca106725 539 * @retval State of bit (1 or 0).
Kojto 122:f9eeca106725 540 */
Kojto 122:f9eeca106725 541 __STATIC_INLINE uint32_t LL_CRS_IsActiveFlag_SYNCWARN(void)
Kojto 122:f9eeca106725 542 {
Kojto 122:f9eeca106725 543 return (READ_BIT(CRS->ISR, CRS_ISR_SYNCWARNF) == (CRS_ISR_SYNCWARNF));
Kojto 122:f9eeca106725 544 }
Kojto 122:f9eeca106725 545
Kojto 122:f9eeca106725 546 /**
Kojto 122:f9eeca106725 547 * @brief Check if Synchronization or trimming error signal occurred or not
Kojto 122:f9eeca106725 548 * @rmtoll ISR ERRF LL_CRS_IsActiveFlag_ERR
Kojto 122:f9eeca106725 549 * @retval State of bit (1 or 0).
Kojto 122:f9eeca106725 550 */
Kojto 122:f9eeca106725 551 __STATIC_INLINE uint32_t LL_CRS_IsActiveFlag_ERR(void)
Kojto 122:f9eeca106725 552 {
Kojto 122:f9eeca106725 553 return (READ_BIT(CRS->ISR, CRS_ISR_ERRF) == (CRS_ISR_ERRF));
Kojto 122:f9eeca106725 554 }
Kojto 122:f9eeca106725 555
Kojto 122:f9eeca106725 556 /**
Kojto 122:f9eeca106725 557 * @brief Check if Expected SYNC signal occurred or not
Kojto 122:f9eeca106725 558 * @rmtoll ISR ESYNCF LL_CRS_IsActiveFlag_ESYNC
Kojto 122:f9eeca106725 559 * @retval State of bit (1 or 0).
Kojto 122:f9eeca106725 560 */
Kojto 122:f9eeca106725 561 __STATIC_INLINE uint32_t LL_CRS_IsActiveFlag_ESYNC(void)
Kojto 122:f9eeca106725 562 {
Kojto 122:f9eeca106725 563 return (READ_BIT(CRS->ISR, CRS_ISR_ESYNCF) == (CRS_ISR_ESYNCF));
Kojto 122:f9eeca106725 564 }
Kojto 122:f9eeca106725 565
Kojto 122:f9eeca106725 566 /**
Kojto 122:f9eeca106725 567 * @brief Check if SYNC error signal occurred or not
Kojto 122:f9eeca106725 568 * @rmtoll ISR SYNCERR LL_CRS_IsActiveFlag_SYNCERR
Kojto 122:f9eeca106725 569 * @retval State of bit (1 or 0).
Kojto 122:f9eeca106725 570 */
Kojto 122:f9eeca106725 571 __STATIC_INLINE uint32_t LL_CRS_IsActiveFlag_SYNCERR(void)
Kojto 122:f9eeca106725 572 {
Kojto 122:f9eeca106725 573 return (READ_BIT(CRS->ISR, CRS_ISR_SYNCERR) == (CRS_ISR_SYNCERR));
Kojto 122:f9eeca106725 574 }
Kojto 122:f9eeca106725 575
Kojto 122:f9eeca106725 576 /**
Kojto 122:f9eeca106725 577 * @brief Check if SYNC missed error signal occurred or not
Kojto 122:f9eeca106725 578 * @rmtoll ISR SYNCMISS LL_CRS_IsActiveFlag_SYNCMISS
Kojto 122:f9eeca106725 579 * @retval State of bit (1 or 0).
Kojto 122:f9eeca106725 580 */
Kojto 122:f9eeca106725 581 __STATIC_INLINE uint32_t LL_CRS_IsActiveFlag_SYNCMISS(void)
Kojto 122:f9eeca106725 582 {
Kojto 122:f9eeca106725 583 return (READ_BIT(CRS->ISR, CRS_ISR_SYNCMISS) == (CRS_ISR_SYNCMISS));
Kojto 122:f9eeca106725 584 }
Kojto 122:f9eeca106725 585
Kojto 122:f9eeca106725 586 /**
Kojto 122:f9eeca106725 587 * @brief Check if Trimming overflow or underflow occurred or not
Kojto 122:f9eeca106725 588 * @rmtoll ISR TRIMOVF LL_CRS_IsActiveFlag_TRIMOVF
Kojto 122:f9eeca106725 589 * @retval State of bit (1 or 0).
Kojto 122:f9eeca106725 590 */
Kojto 122:f9eeca106725 591 __STATIC_INLINE uint32_t LL_CRS_IsActiveFlag_TRIMOVF(void)
Kojto 122:f9eeca106725 592 {
Kojto 122:f9eeca106725 593 return (READ_BIT(CRS->ISR, CRS_ISR_TRIMOVF) == (CRS_ISR_TRIMOVF));
Kojto 122:f9eeca106725 594 }
Kojto 122:f9eeca106725 595
Kojto 122:f9eeca106725 596 /**
Kojto 122:f9eeca106725 597 * @brief Clear the SYNC event OK flag
Kojto 122:f9eeca106725 598 * @rmtoll ICR SYNCOKC LL_CRS_ClearFlag_SYNCOK
Kojto 122:f9eeca106725 599 * @retval None
Kojto 122:f9eeca106725 600 */
Kojto 122:f9eeca106725 601 __STATIC_INLINE void LL_CRS_ClearFlag_SYNCOK(void)
Kojto 122:f9eeca106725 602 {
Kojto 122:f9eeca106725 603 WRITE_REG(CRS->ICR, CRS_ICR_SYNCOKC);
Kojto 122:f9eeca106725 604 }
Kojto 122:f9eeca106725 605
Kojto 122:f9eeca106725 606 /**
Kojto 122:f9eeca106725 607 * @brief Clear the SYNC warning flag
Kojto 122:f9eeca106725 608 * @rmtoll ICR SYNCWARNC LL_CRS_ClearFlag_SYNCWARN
Kojto 122:f9eeca106725 609 * @retval None
Kojto 122:f9eeca106725 610 */
Kojto 122:f9eeca106725 611 __STATIC_INLINE void LL_CRS_ClearFlag_SYNCWARN(void)
Kojto 122:f9eeca106725 612 {
Kojto 122:f9eeca106725 613 WRITE_REG(CRS->ICR, CRS_ICR_SYNCWARNC);
Kojto 122:f9eeca106725 614 }
Kojto 122:f9eeca106725 615
Kojto 122:f9eeca106725 616 /**
Kojto 122:f9eeca106725 617 * @brief Clear TRIMOVF, SYNCMISS and SYNCERR bits and consequently also
Kojto 122:f9eeca106725 618 * the ERR flag
Kojto 122:f9eeca106725 619 * @rmtoll ICR ERRC LL_CRS_ClearFlag_ERR
Kojto 122:f9eeca106725 620 * @retval None
Kojto 122:f9eeca106725 621 */
Kojto 122:f9eeca106725 622 __STATIC_INLINE void LL_CRS_ClearFlag_ERR(void)
Kojto 122:f9eeca106725 623 {
Kojto 122:f9eeca106725 624 WRITE_REG(CRS->ICR, CRS_ICR_ERRC);
Kojto 122:f9eeca106725 625 }
Kojto 122:f9eeca106725 626
Kojto 122:f9eeca106725 627 /**
Kojto 122:f9eeca106725 628 * @brief Clear Expected SYNC flag
Kojto 122:f9eeca106725 629 * @rmtoll ICR ESYNCC LL_CRS_ClearFlag_ESYNC
Kojto 122:f9eeca106725 630 * @retval None
Kojto 122:f9eeca106725 631 */
Kojto 122:f9eeca106725 632 __STATIC_INLINE void LL_CRS_ClearFlag_ESYNC(void)
Kojto 122:f9eeca106725 633 {
Kojto 122:f9eeca106725 634 WRITE_REG(CRS->ICR, CRS_ICR_ESYNCC);
Kojto 122:f9eeca106725 635 }
Kojto 122:f9eeca106725 636
Kojto 122:f9eeca106725 637 /**
Kojto 122:f9eeca106725 638 * @}
Kojto 122:f9eeca106725 639 */
Kojto 122:f9eeca106725 640
Kojto 122:f9eeca106725 641 /** @defgroup CRS_LL_EF_IT_Management IT_Management
Kojto 122:f9eeca106725 642 * @{
Kojto 122:f9eeca106725 643 */
Kojto 122:f9eeca106725 644
Kojto 122:f9eeca106725 645 /**
Kojto 122:f9eeca106725 646 * @brief Enable SYNC event OK interrupt
Kojto 122:f9eeca106725 647 * @rmtoll CR SYNCOKIE LL_CRS_EnableIT_SYNCOK
Kojto 122:f9eeca106725 648 * @retval None
Kojto 122:f9eeca106725 649 */
Kojto 122:f9eeca106725 650 __STATIC_INLINE void LL_CRS_EnableIT_SYNCOK(void)
Kojto 122:f9eeca106725 651 {
Kojto 122:f9eeca106725 652 SET_BIT(CRS->CR, CRS_CR_SYNCOKIE);
Kojto 122:f9eeca106725 653 }
Kojto 122:f9eeca106725 654
Kojto 122:f9eeca106725 655 /**
Kojto 122:f9eeca106725 656 * @brief Disable SYNC event OK interrupt
Kojto 122:f9eeca106725 657 * @rmtoll CR SYNCOKIE LL_CRS_DisableIT_SYNCOK
Kojto 122:f9eeca106725 658 * @retval None
Kojto 122:f9eeca106725 659 */
Kojto 122:f9eeca106725 660 __STATIC_INLINE void LL_CRS_DisableIT_SYNCOK(void)
Kojto 122:f9eeca106725 661 {
Kojto 122:f9eeca106725 662 CLEAR_BIT(CRS->CR, CRS_CR_SYNCOKIE);
Kojto 122:f9eeca106725 663 }
Kojto 122:f9eeca106725 664
Kojto 122:f9eeca106725 665 /**
Kojto 122:f9eeca106725 666 * @brief Check if SYNC event OK interrupt is enabled or not
Kojto 122:f9eeca106725 667 * @rmtoll CR SYNCOKIE LL_CRS_IsEnabledIT_SYNCOK
Kojto 122:f9eeca106725 668 * @retval State of bit (1 or 0).
Kojto 122:f9eeca106725 669 */
Kojto 122:f9eeca106725 670 __STATIC_INLINE uint32_t LL_CRS_IsEnabledIT_SYNCOK(void)
Kojto 122:f9eeca106725 671 {
Kojto 122:f9eeca106725 672 return (READ_BIT(CRS->CR, CRS_CR_SYNCOKIE) == (CRS_CR_SYNCOKIE));
Kojto 122:f9eeca106725 673 }
Kojto 122:f9eeca106725 674
Kojto 122:f9eeca106725 675 /**
Kojto 122:f9eeca106725 676 * @brief Enable SYNC warning interrupt
Kojto 122:f9eeca106725 677 * @rmtoll CR SYNCWARNIE LL_CRS_EnableIT_SYNCWARN
Kojto 122:f9eeca106725 678 * @retval None
Kojto 122:f9eeca106725 679 */
Kojto 122:f9eeca106725 680 __STATIC_INLINE void LL_CRS_EnableIT_SYNCWARN(void)
Kojto 122:f9eeca106725 681 {
Kojto 122:f9eeca106725 682 SET_BIT(CRS->CR, CRS_CR_SYNCWARNIE);
Kojto 122:f9eeca106725 683 }
Kojto 122:f9eeca106725 684
Kojto 122:f9eeca106725 685 /**
Kojto 122:f9eeca106725 686 * @brief Disable SYNC warning interrupt
Kojto 122:f9eeca106725 687 * @rmtoll CR SYNCWARNIE LL_CRS_DisableIT_SYNCWARN
Kojto 122:f9eeca106725 688 * @retval None
Kojto 122:f9eeca106725 689 */
Kojto 122:f9eeca106725 690 __STATIC_INLINE void LL_CRS_DisableIT_SYNCWARN(void)
Kojto 122:f9eeca106725 691 {
Kojto 122:f9eeca106725 692 CLEAR_BIT(CRS->CR, CRS_CR_SYNCWARNIE);
Kojto 122:f9eeca106725 693 }
Kojto 122:f9eeca106725 694
Kojto 122:f9eeca106725 695 /**
Kojto 122:f9eeca106725 696 * @brief Check if SYNC warning interrupt is enabled or not
Kojto 122:f9eeca106725 697 * @rmtoll CR SYNCWARNIE LL_CRS_IsEnabledIT_SYNCWARN
Kojto 122:f9eeca106725 698 * @retval State of bit (1 or 0).
Kojto 122:f9eeca106725 699 */
Kojto 122:f9eeca106725 700 __STATIC_INLINE uint32_t LL_CRS_IsEnabledIT_SYNCWARN(void)
Kojto 122:f9eeca106725 701 {
Kojto 122:f9eeca106725 702 return (READ_BIT(CRS->CR, CRS_CR_SYNCWARNIE) == (CRS_CR_SYNCWARNIE));
Kojto 122:f9eeca106725 703 }
Kojto 122:f9eeca106725 704
Kojto 122:f9eeca106725 705 /**
Kojto 122:f9eeca106725 706 * @brief Enable Synchronization or trimming error interrupt
Kojto 122:f9eeca106725 707 * @rmtoll CR ERRIE LL_CRS_EnableIT_ERR
Kojto 122:f9eeca106725 708 * @retval None
Kojto 122:f9eeca106725 709 */
Kojto 122:f9eeca106725 710 __STATIC_INLINE void LL_CRS_EnableIT_ERR(void)
Kojto 122:f9eeca106725 711 {
Kojto 122:f9eeca106725 712 SET_BIT(CRS->CR, CRS_CR_ERRIE);
Kojto 122:f9eeca106725 713 }
Kojto 122:f9eeca106725 714
Kojto 122:f9eeca106725 715 /**
Kojto 122:f9eeca106725 716 * @brief Disable Synchronization or trimming error interrupt
Kojto 122:f9eeca106725 717 * @rmtoll CR ERRIE LL_CRS_DisableIT_ERR
Kojto 122:f9eeca106725 718 * @retval None
Kojto 122:f9eeca106725 719 */
Kojto 122:f9eeca106725 720 __STATIC_INLINE void LL_CRS_DisableIT_ERR(void)
Kojto 122:f9eeca106725 721 {
Kojto 122:f9eeca106725 722 CLEAR_BIT(CRS->CR, CRS_CR_ERRIE);
Kojto 122:f9eeca106725 723 }
Kojto 122:f9eeca106725 724
Kojto 122:f9eeca106725 725 /**
Kojto 122:f9eeca106725 726 * @brief Check if Synchronization or trimming error interrupt is enabled or not
Kojto 122:f9eeca106725 727 * @rmtoll CR ERRIE LL_CRS_IsEnabledIT_ERR
Kojto 122:f9eeca106725 728 * @retval State of bit (1 or 0).
Kojto 122:f9eeca106725 729 */
Kojto 122:f9eeca106725 730 __STATIC_INLINE uint32_t LL_CRS_IsEnabledIT_ERR(void)
Kojto 122:f9eeca106725 731 {
Kojto 122:f9eeca106725 732 return (READ_BIT(CRS->CR, CRS_CR_ERRIE) == (CRS_CR_ERRIE));
Kojto 122:f9eeca106725 733 }
Kojto 122:f9eeca106725 734
Kojto 122:f9eeca106725 735 /**
Kojto 122:f9eeca106725 736 * @brief Enable Expected SYNC interrupt
Kojto 122:f9eeca106725 737 * @rmtoll CR ESYNCIE LL_CRS_EnableIT_ESYNC
Kojto 122:f9eeca106725 738 * @retval None
Kojto 122:f9eeca106725 739 */
Kojto 122:f9eeca106725 740 __STATIC_INLINE void LL_CRS_EnableIT_ESYNC(void)
Kojto 122:f9eeca106725 741 {
Kojto 122:f9eeca106725 742 SET_BIT(CRS->CR, CRS_CR_ESYNCIE);
Kojto 122:f9eeca106725 743 }
Kojto 122:f9eeca106725 744
Kojto 122:f9eeca106725 745 /**
Kojto 122:f9eeca106725 746 * @brief Disable Expected SYNC interrupt
Kojto 122:f9eeca106725 747 * @rmtoll CR ESYNCIE LL_CRS_DisableIT_ESYNC
Kojto 122:f9eeca106725 748 * @retval None
Kojto 122:f9eeca106725 749 */
Kojto 122:f9eeca106725 750 __STATIC_INLINE void LL_CRS_DisableIT_ESYNC(void)
Kojto 122:f9eeca106725 751 {
Kojto 122:f9eeca106725 752 CLEAR_BIT(CRS->CR, CRS_CR_ESYNCIE);
Kojto 122:f9eeca106725 753 }
Kojto 122:f9eeca106725 754
Kojto 122:f9eeca106725 755 /**
Kojto 122:f9eeca106725 756 * @brief Check if Expected SYNC interrupt is enabled or not
Kojto 122:f9eeca106725 757 * @rmtoll CR ESYNCIE LL_CRS_IsEnabledIT_ESYNC
Kojto 122:f9eeca106725 758 * @retval State of bit (1 or 0).
Kojto 122:f9eeca106725 759 */
Kojto 122:f9eeca106725 760 __STATIC_INLINE uint32_t LL_CRS_IsEnabledIT_ESYNC(void)
Kojto 122:f9eeca106725 761 {
Kojto 122:f9eeca106725 762 return (READ_BIT(CRS->CR, CRS_CR_ESYNCIE) == (CRS_CR_ESYNCIE));
Kojto 122:f9eeca106725 763 }
Kojto 122:f9eeca106725 764
Kojto 122:f9eeca106725 765 /**
Kojto 122:f9eeca106725 766 * @}
Kojto 122:f9eeca106725 767 */
Kojto 122:f9eeca106725 768
Kojto 122:f9eeca106725 769 #if defined(USE_FULL_LL_DRIVER)
Kojto 122:f9eeca106725 770 /** @defgroup CRS_LL_EF_Init Initialization and de-initialization functions
Kojto 122:f9eeca106725 771 * @{
Kojto 122:f9eeca106725 772 */
Kojto 122:f9eeca106725 773
Kojto 122:f9eeca106725 774 ErrorStatus LL_CRS_DeInit(void);
Kojto 122:f9eeca106725 775
Kojto 122:f9eeca106725 776 /**
Kojto 122:f9eeca106725 777 * @}
Kojto 122:f9eeca106725 778 */
Kojto 122:f9eeca106725 779 #endif /* USE_FULL_LL_DRIVER */
Kojto 122:f9eeca106725 780
Kojto 122:f9eeca106725 781 /**
Kojto 122:f9eeca106725 782 * @}
Kojto 122:f9eeca106725 783 */
Kojto 122:f9eeca106725 784
Kojto 122:f9eeca106725 785 /**
Kojto 122:f9eeca106725 786 * @}
Kojto 122:f9eeca106725 787 */
Kojto 122:f9eeca106725 788
Kojto 122:f9eeca106725 789 #endif /* defined(CRS) */
Kojto 122:f9eeca106725 790
Kojto 122:f9eeca106725 791 /**
Kojto 122:f9eeca106725 792 * @}
Kojto 122:f9eeca106725 793 */
Kojto 122:f9eeca106725 794
Kojto 122:f9eeca106725 795 #ifdef __cplusplus
Kojto 122:f9eeca106725 796 }
Kojto 122:f9eeca106725 797 #endif
Kojto 122:f9eeca106725 798
Kojto 122:f9eeca106725 799 #endif /* __STM32L4xx_LL_CRS_H */
Kojto 122:f9eeca106725 800
Kojto 122:f9eeca106725 801 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/