mbed library sources. Supersedes mbed-src.

Dependents:   Nucleo_Hello_Encoder BLE_iBeaconScan AM1805_DEMO DISCO-F429ZI_ExportTemplate1 ... more

Committer:
AnnaBridge
Date:
Wed Feb 20 22:31:08 2019 +0000
Revision:
189:f392fc9709a3
Parent:
186:707f6e361f3e
mbed library release version 165

Who changed what in which revision?

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