21 #ifndef __STM32L4xx_LL_CRS_H 22 #define __STM32L4xx_LL_CRS_H 29 #include "stm32l4xx.h" 56 #define LL_CRS_ISR_SYNCOKF CRS_ISR_SYNCOKF 57 #define LL_CRS_ISR_SYNCWARNF CRS_ISR_SYNCWARNF 58 #define LL_CRS_ISR_ERRF CRS_ISR_ERRF 59 #define LL_CRS_ISR_ESYNCF CRS_ISR_ESYNCF 60 #define LL_CRS_ISR_SYNCERR CRS_ISR_SYNCERR 61 #define LL_CRS_ISR_SYNCMISS CRS_ISR_SYNCMISS 62 #define LL_CRS_ISR_TRIMOVF CRS_ISR_TRIMOVF 71 #define LL_CRS_CR_SYNCOKIE CRS_CR_SYNCOKIE 72 #define LL_CRS_CR_SYNCWARNIE CRS_CR_SYNCWARNIE 73 #define LL_CRS_CR_ERRIE CRS_CR_ERRIE 74 #define LL_CRS_CR_ESYNCIE CRS_CR_ESYNCIE 82 #define LL_CRS_SYNC_DIV_1 ((uint32_t)0x00U) 83 #define LL_CRS_SYNC_DIV_2 CRS_CFGR_SYNCDIV_0 84 #define LL_CRS_SYNC_DIV_4 CRS_CFGR_SYNCDIV_1 85 #define LL_CRS_SYNC_DIV_8 (CRS_CFGR_SYNCDIV_1 | CRS_CFGR_SYNCDIV_0) 86 #define LL_CRS_SYNC_DIV_16 CRS_CFGR_SYNCDIV_2 87 #define LL_CRS_SYNC_DIV_32 (CRS_CFGR_SYNCDIV_2 | CRS_CFGR_SYNCDIV_0) 88 #define LL_CRS_SYNC_DIV_64 (CRS_CFGR_SYNCDIV_2 | CRS_CFGR_SYNCDIV_1) 89 #define LL_CRS_SYNC_DIV_128 CRS_CFGR_SYNCDIV 97 #define LL_CRS_SYNC_SOURCE_GPIO ((uint32_t)0x00U) 98 #define LL_CRS_SYNC_SOURCE_LSE CRS_CFGR_SYNCSRC_0 99 #define LL_CRS_SYNC_SOURCE_USB CRS_CFGR_SYNCSRC_1 107 #define LL_CRS_SYNC_POLARITY_RISING ((uint32_t)0x00U) 108 #define LL_CRS_SYNC_POLARITY_FALLING CRS_CFGR_SYNCPOL 116 #define LL_CRS_FREQ_ERROR_DIR_UP ((uint32_t)0x00U) 117 #define LL_CRS_FREQ_ERROR_DIR_DOWN ((uint32_t)CRS_ISR_FEDIR) 130 #define LL_CRS_RELOADVALUE_DEFAULT ((uint32_t)0xBB7FU) 135 #define LL_CRS_ERRORLIMIT_DEFAULT ((uint32_t)0x22U) 144 #if defined (STM32L412xx) || defined (STM32L422xx) 145 #define LL_CRS_HSI48CALIBRATION_DEFAULT ((uint32_t)64U) 147 #define LL_CRS_HSI48CALIBRATION_DEFAULT ((uint32_t)32U) 173 #define LL_CRS_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__)) 181 #define LL_CRS_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__) 201 #define __LL_CRS_CALC_CALCULATE_RELOADVALUE(__FTARGET__, __FSYNC__) (((__FTARGET__) / (__FSYNC__)) - 1U) 228 SET_BIT(CRS->CR, CRS_CR_CEN);
248 return (READ_BIT(CRS->CR, CRS_CR_CEN) == (CRS_CR_CEN));
258 SET_BIT(CRS->CR, CRS_CR_AUTOTRIMEN);
278 return (READ_BIT(CRS->CR, CRS_CR_AUTOTRIMEN) == (CRS_CR_AUTOTRIMEN));
291 MODIFY_REG(CRS->CR, CRS_CR_TRIM, Value << CRS_CR_TRIM_Pos);
301 return (uint32_t)(READ_BIT(CRS->CR, CRS_CR_TRIM) >> CRS_CR_TRIM_Pos);
314 MODIFY_REG(CRS->CFGR, CRS_CFGR_RELOAD, Value);
324 return (uint32_t)(READ_BIT(CRS->CFGR, CRS_CFGR_RELOAD));
336 MODIFY_REG(CRS->CFGR, CRS_CFGR_FELIM, Value << CRS_CFGR_FELIM_Pos);
346 return (uint32_t)(READ_BIT(CRS->CFGR, CRS_CFGR_FELIM) >> CRS_CFGR_FELIM_Pos);
365 MODIFY_REG(CRS->CFGR, CRS_CFGR_SYNCDIV, Divider);
383 return (uint32_t)(READ_BIT(CRS->CFGR, CRS_CFGR_SYNCDIV));
397 MODIFY_REG(CRS->CFGR, CRS_CFGR_SYNCSRC, Source);
410 return (uint32_t)(READ_BIT(CRS->CFGR, CRS_CFGR_SYNCSRC));
423 MODIFY_REG(CRS->CFGR, CRS_CFGR_SYNCPOL, Polarity);
435 return (uint32_t)(READ_BIT(CRS->CFGR, CRS_CFGR_SYNCPOL));
458 MODIFY_REG(CRS->CR, CRS_CR_TRIM, HSI48CalibrationValue);
460 CRS_CFGR_RELOAD | CRS_CFGR_FELIM | CRS_CFGR_SYNCDIV | CRS_CFGR_SYNCSRC | CRS_CFGR_SYNCPOL,
461 ReloadValue | (ErrorLimitValue << CRS_CFGR_FELIM_Pos) | Settings);
479 SET_BIT(CRS->CR, CRS_CR_SWSYNC);
492 return (uint32_t)(READ_BIT(CRS->ISR, CRS_ISR_FEDIR));
502 return (uint32_t)(READ_BIT(CRS->ISR, CRS_ISR_FECAP) >> CRS_ISR_FECAP_Pos);
520 return (READ_BIT(CRS->ISR, CRS_ISR_SYNCOKF) == (CRS_ISR_SYNCOKF));
530 return (READ_BIT(CRS->ISR, CRS_ISR_SYNCWARNF) == (CRS_ISR_SYNCWARNF));
540 return (READ_BIT(CRS->ISR, CRS_ISR_ERRF) == (CRS_ISR_ERRF));
550 return (READ_BIT(CRS->ISR, CRS_ISR_ESYNCF) == (CRS_ISR_ESYNCF));
560 return (READ_BIT(CRS->ISR, CRS_ISR_SYNCERR) == (CRS_ISR_SYNCERR));
570 return (READ_BIT(CRS->ISR, CRS_ISR_SYNCMISS) == (CRS_ISR_SYNCMISS));
580 return (READ_BIT(CRS->ISR, CRS_ISR_TRIMOVF) == (CRS_ISR_TRIMOVF));
590 WRITE_REG(CRS->ICR, CRS_ICR_SYNCOKC);
600 WRITE_REG(CRS->ICR, CRS_ICR_SYNCWARNC);
611 WRITE_REG(CRS->ICR, CRS_ICR_ERRC);
621 WRITE_REG(CRS->ICR, CRS_ICR_ESYNCC);
639 SET_BIT(CRS->CR, CRS_CR_SYNCOKIE);
659 return (READ_BIT(CRS->CR, CRS_CR_SYNCOKIE) == (CRS_CR_SYNCOKIE));
669 SET_BIT(CRS->CR, CRS_CR_SYNCWARNIE);
689 return (READ_BIT(CRS->CR, CRS_CR_SYNCWARNIE) == (CRS_CR_SYNCWARNIE));
699 SET_BIT(CRS->CR, CRS_CR_ERRIE);
719 return (READ_BIT(CRS->CR, CRS_CR_ERRIE) == (CRS_CR_ERRIE));
729 SET_BIT(CRS->CR, CRS_CR_ESYNCIE);
749 return (READ_BIT(CRS->CR, CRS_CR_ESYNCIE) == (CRS_CR_ESYNCIE));
756 #if defined(USE_FULL_LL_DRIVER) __STATIC_INLINE uint32_t LL_CRS_GetFreqErrorLimit(void)
Get frequency error limit CFGR FELIM LL_CRS_GetFreqErrorLimit.
__STATIC_INLINE void LL_CRS_EnableIT_SYNCOK(void)
Enable SYNC event OK interrupt CR SYNCOKIE LL_CRS_EnableIT_SYNCOK.
ErrorStatus LL_CRS_DeInit(void)
De-Initializes CRS peripheral registers to their default reset values.
__STATIC_INLINE uint32_t LL_CRS_IsEnabledFreqErrorCounter(void)
Check if Frequency error counter is enabled or not CR CEN LL_CRS_IsEnabledFreqErrorCounter.
__STATIC_INLINE uint32_t LL_CRS_IsActiveFlag_ESYNC(void)
Check if Expected SYNC signal occurred or not ISR ESYNCF LL_CRS_IsActiveFlag_ESYNC.
__STATIC_INLINE void LL_CRS_SetSyncDivider(uint32_t Divider)
Set division factor for SYNC signal CFGR SYNCDIV LL_CRS_SetSyncDivider.
__STATIC_INLINE uint32_t LL_CRS_IsEnabledIT_SYNCOK(void)
Check if SYNC event OK interrupt is enabled or not CR SYNCOKIE LL_CRS_IsEnabledIT_SYNCOK.
__STATIC_INLINE uint32_t LL_CRS_GetHSI48SmoothTrimming(void)
Get HSI48 oscillator smooth trimming CR TRIM LL_CRS_GetHSI48SmoothTrimming.
__STATIC_INLINE uint32_t LL_CRS_IsActiveFlag_SYNCERR(void)
Check if SYNC error signal occurred or not ISR SYNCERR LL_CRS_IsActiveFlag_SYNCERR.
__STATIC_INLINE void LL_CRS_DisableAutoTrimming(void)
Disable Automatic trimming counter CR AUTOTRIMEN LL_CRS_DisableAutoTrimming.
__STATIC_INLINE void LL_CRS_ConfigSynchronization(uint32_t HSI48CalibrationValue, uint32_t ErrorLimitValue, uint32_t ReloadValue, uint32_t Settings)
Configure CRS for the synchronization CR TRIM LL_CRS_ConfigSynchronization CFGR RELOAD LL_CRS_Confi...
__STATIC_INLINE void LL_CRS_DisableIT_ESYNC(void)
Disable Expected SYNC interrupt CR ESYNCIE LL_CRS_DisableIT_ESYNC.
CLEAR_BIT(hrtc->Instance->CR, RTC_CR_WUTE)
__STATIC_INLINE void LL_CRS_SetHSI48SmoothTrimming(uint32_t Value)
Set HSI48 oscillator smooth trimming.
__STATIC_INLINE void LL_CRS_DisableIT_ERR(void)
Disable Synchronization or trimming error interrupt CR ERRIE LL_CRS_DisableIT_ERR.
__STATIC_INLINE void LL_CRS_DisableIT_SYNCWARN(void)
Disable SYNC warning interrupt CR SYNCWARNIE LL_CRS_DisableIT_SYNCWARN.
__STATIC_INLINE uint32_t LL_CRS_IsActiveFlag_ERR(void)
Check if Synchronization or trimming error signal occurred or not ISR ERRF LL_CRS_IsActiveFlag_ERR.
__STATIC_INLINE void LL_CRS_EnableFreqErrorCounter(void)
Enable Frequency error counter.
__STATIC_INLINE void LL_CRS_EnableAutoTrimming(void)
Enable Automatic trimming counter CR AUTOTRIMEN LL_CRS_EnableAutoTrimming.
__STATIC_INLINE void LL_CRS_SetReloadCounter(uint32_t Value)
Set counter reload value CFGR RELOAD LL_CRS_SetReloadCounter.
__STATIC_INLINE void LL_CRS_DisableFreqErrorCounter(void)
Disable Frequency error counter CR CEN LL_CRS_DisableFreqErrorCounter.
__STATIC_INLINE uint32_t LL_CRS_GetFreqErrorDirection(void)
Get the frequency error direction latched in the time of the last SYNC event ISR FEDIR LL_CRS_GetFre...
__STATIC_INLINE void LL_CRS_GenerateEvent_SWSYNC(void)
Generate software SYNC event CR SWSYNC LL_CRS_GenerateEvent_SWSYNC.
__STATIC_INLINE uint32_t LL_CRS_GetSyncPolarity(void)
Get input polarity for the SYNC signal source CFGR SYNCPOL LL_CRS_GetSyncPolarity.
__STATIC_INLINE void LL_CRS_SetSyncSignalSource(uint32_t Source)
Set SYNC signal source CFGR SYNCSRC LL_CRS_SetSyncSignalSource.
__STATIC_INLINE void LL_CRS_EnableIT_ERR(void)
Enable Synchronization or trimming error interrupt CR ERRIE LL_CRS_EnableIT_ERR. ...
__STATIC_INLINE uint32_t LL_CRS_IsActiveFlag_TRIMOVF(void)
Check if Trimming overflow or underflow occurred or not ISR TRIMOVF LL_CRS_IsActiveFlag_TRIMOVF.
__STATIC_INLINE void LL_CRS_EnableIT_SYNCWARN(void)
Enable SYNC warning interrupt CR SYNCWARNIE LL_CRS_EnableIT_SYNCWARN.
__STATIC_INLINE uint32_t LL_CRS_GetFreqErrorCapture(void)
Get the frequency error counter value latched in the time of the last SYNC event ISR FECAP LL_CRS_Ge...
__STATIC_INLINE uint32_t LL_CRS_GetSyncDivider(void)
Get division factor for SYNC signal CFGR SYNCDIV LL_CRS_GetSyncDivider.
__STATIC_INLINE uint32_t LL_CRS_GetReloadCounter(void)
Get counter reload value CFGR RELOAD LL_CRS_GetReloadCounter.
__STATIC_INLINE void LL_CRS_EnableIT_ESYNC(void)
Enable Expected SYNC interrupt CR ESYNCIE LL_CRS_EnableIT_ESYNC.
__STATIC_INLINE uint32_t LL_CRS_IsEnabledIT_ESYNC(void)
Check if Expected SYNC interrupt is enabled or not CR ESYNCIE LL_CRS_IsEnabledIT_ESYNC.
__STATIC_INLINE void LL_CRS_ClearFlag_SYNCWARN(void)
Clear the SYNC warning flag ICR SYNCWARNC LL_CRS_ClearFlag_SYNCWARN.
__STATIC_INLINE void LL_CRS_ClearFlag_ESYNC(void)
Clear Expected SYNC flag ICR ESYNCC LL_CRS_ClearFlag_ESYNC.
__STATIC_INLINE uint32_t LL_CRS_IsActiveFlag_SYNCWARN(void)
Check if SYNC warning signal occurred or not ISR SYNCWARNF LL_CRS_IsActiveFlag_SYNCWARN.
__STATIC_INLINE void LL_CRS_ClearFlag_ERR(void)
Clear TRIMOVF, SYNCMISS and SYNCERR bits and consequently also the ERR flag ICR ERRC LL_CRS_ClearFla...
__STATIC_INLINE uint32_t LL_CRS_IsActiveFlag_SYNCMISS(void)
Check if SYNC missed error signal occurred or not ISR SYNCMISS LL_CRS_IsActiveFlag_SYNCMISS.
__STATIC_INLINE uint32_t LL_CRS_IsActiveFlag_SYNCOK(void)
Check if SYNC event OK signal occurred or not ISR SYNCOKF LL_CRS_IsActiveFlag_SYNCOK.
__STATIC_INLINE void LL_CRS_SetSyncPolarity(uint32_t Polarity)
Set input polarity for the SYNC signal source CFGR SYNCPOL LL_CRS_SetSyncPolarity.
MODIFY_REG(hrtc->Instance->CR, RTC_CR_WUCKSEL,(uint32_t) WakeUpClock)
__STATIC_INLINE void LL_CRS_DisableIT_SYNCOK(void)
Disable SYNC event OK interrupt CR SYNCOKIE LL_CRS_DisableIT_SYNCOK.
__STATIC_INLINE uint32_t LL_CRS_GetSyncSignalSource(void)
Get SYNC signal source CFGR SYNCSRC LL_CRS_GetSyncSignalSource.
__STATIC_INLINE void LL_CRS_SetFreqErrorLimit(uint32_t Value)
Set frequency error limit CFGR FELIM LL_CRS_SetFreqErrorLimit.
__STATIC_INLINE void LL_CRS_ClearFlag_SYNCOK(void)
Clear the SYNC event OK flag ICR SYNCOKC LL_CRS_ClearFlag_SYNCOK.
__STATIC_INLINE uint32_t LL_CRS_IsEnabledIT_ERR(void)
Check if Synchronization or trimming error interrupt is enabled or not CR ERRIE LL_CRS_IsEnabledIT_E...
__STATIC_INLINE uint32_t LL_CRS_IsEnabledAutoTrimming(void)
Check if Automatic trimming is enabled or not CR AUTOTRIMEN LL_CRS_IsEnabledAutoTrimming.
__STATIC_INLINE uint32_t LL_CRS_IsEnabledIT_SYNCWARN(void)
Check if SYNC warning interrupt is enabled or not CR SYNCWARNIE LL_CRS_IsEnabledIT_SYNCWARN.