RTEMS 6.1-rc1
stm32h7xx_ll_crs.h
Go to the documentation of this file.
1
19/* Define to prevent recursive inclusion -------------------------------------*/
20#ifndef STM32H7xx_LL_CRS_H
21#define STM32H7xx_LL_CRS_H
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
27/* Includes ------------------------------------------------------------------*/
28#include "stm32h7xx.h"
29
34#if defined(CRS)
35
41/* Private types -------------------------------------------------------------*/
42/* Private variables ---------------------------------------------------------*/
43/* Private constants ---------------------------------------------------------*/
44/* Private macros ------------------------------------------------------------*/
45
46/* Exported types ------------------------------------------------------------*/
47/* Exported constants --------------------------------------------------------*/
58#define LL_CRS_ISR_SYNCOKF CRS_ISR_SYNCOKF
59#define LL_CRS_ISR_SYNCWARNF CRS_ISR_SYNCWARNF
60#define LL_CRS_ISR_ERRF CRS_ISR_ERRF
61#define LL_CRS_ISR_ESYNCF CRS_ISR_ESYNCF
62#define LL_CRS_ISR_SYNCERR CRS_ISR_SYNCERR
63#define LL_CRS_ISR_SYNCMISS CRS_ISR_SYNCMISS
64#define LL_CRS_ISR_TRIMOVF CRS_ISR_TRIMOVF
74#define LL_CRS_CR_SYNCOKIE CRS_CR_SYNCOKIE
75#define LL_CRS_CR_SYNCWARNIE CRS_CR_SYNCWARNIE
76#define LL_CRS_CR_ERRIE CRS_CR_ERRIE
77#define LL_CRS_CR_ESYNCIE CRS_CR_ESYNCIE
86#define LL_CRS_SYNC_DIV_1 0x00000000U
87#define LL_CRS_SYNC_DIV_2 CRS_CFGR_SYNCDIV_0
88#define LL_CRS_SYNC_DIV_4 CRS_CFGR_SYNCDIV_1
89#define LL_CRS_SYNC_DIV_8 (CRS_CFGR_SYNCDIV_1 | CRS_CFGR_SYNCDIV_0)
90#define LL_CRS_SYNC_DIV_16 CRS_CFGR_SYNCDIV_2
91#define LL_CRS_SYNC_DIV_32 (CRS_CFGR_SYNCDIV_2 | CRS_CFGR_SYNCDIV_0)
92#define LL_CRS_SYNC_DIV_64 (CRS_CFGR_SYNCDIV_2 | CRS_CFGR_SYNCDIV_1)
93#define LL_CRS_SYNC_DIV_128 CRS_CFGR_SYNCDIV
102#define LL_CRS_SYNC_SOURCE_GPIO 0x00000000U
103#define LL_CRS_SYNC_SOURCE_LSE CRS_CFGR_SYNCSRC_0
104#define LL_CRS_SYNC_SOURCE_USB CRS_CFGR_SYNCSRC_1
113#define LL_CRS_SYNC_POLARITY_RISING 0x00000000U
114#define LL_CRS_SYNC_POLARITY_FALLING CRS_CFGR_SYNCPOL
123#define LL_CRS_FREQ_ERROR_DIR_UP 0x00000000U
124#define LL_CRS_FREQ_ERROR_DIR_DOWN CRS_ISR_FEDIR
138#define LL_CRS_RELOADVALUE_DEFAULT 0x0000BB7FU
139
143#define LL_CRS_ERRORLIMIT_DEFAULT 0x00000022U
144
151#define LL_CRS_HSI48CALIBRATION_DEFAULT 0x00000020U
160/* Exported macro ------------------------------------------------------------*/
178#define LL_CRS_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
179
186#define LL_CRS_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
207#define __LL_CRS_CALC_CALCULATE_RELOADVALUE(__FTARGET__, __FSYNC__) (((__FTARGET__) / (__FSYNC__)) - 1U)
208
217/* Exported functions --------------------------------------------------------*/
234__STATIC_INLINE void LL_CRS_EnableFreqErrorCounter(void)
235{
236 SET_BIT(CRS->CR, CRS_CR_CEN);
237}
238
244__STATIC_INLINE void LL_CRS_DisableFreqErrorCounter(void)
245{
246 CLEAR_BIT(CRS->CR, CRS_CR_CEN);
247}
248
254__STATIC_INLINE uint32_t LL_CRS_IsEnabledFreqErrorCounter(void)
255{
256 return ((READ_BIT(CRS->CR, CRS_CR_CEN) == (CRS_CR_CEN)) ? 1UL : 0UL);
257}
258
264__STATIC_INLINE void LL_CRS_EnableAutoTrimming(void)
265{
266 SET_BIT(CRS->CR, CRS_CR_AUTOTRIMEN);
267}
268
274__STATIC_INLINE void LL_CRS_DisableAutoTrimming(void)
275{
276 CLEAR_BIT(CRS->CR, CRS_CR_AUTOTRIMEN);
277}
278
284__STATIC_INLINE uint32_t LL_CRS_IsEnabledAutoTrimming(void)
285{
286 return ((READ_BIT(CRS->CR, CRS_CR_AUTOTRIMEN) == (CRS_CR_AUTOTRIMEN)) ? 1UL : 0UL);
287}
288
297__STATIC_INLINE void LL_CRS_SetHSI48SmoothTrimming(uint32_t Value)
298{
299 MODIFY_REG(CRS->CR, CRS_CR_TRIM, Value << CRS_CR_TRIM_Pos);
300}
301
307__STATIC_INLINE uint32_t LL_CRS_GetHSI48SmoothTrimming(void)
308{
309 return (uint32_t)(READ_BIT(CRS->CR, CRS_CR_TRIM) >> CRS_CR_TRIM_Pos);
310}
311
320__STATIC_INLINE void LL_CRS_SetReloadCounter(uint32_t Value)
321{
322 MODIFY_REG(CRS->CFGR, CRS_CFGR_RELOAD, Value);
323}
324
330__STATIC_INLINE uint32_t LL_CRS_GetReloadCounter(void)
331{
332 return (uint32_t)(READ_BIT(CRS->CFGR, CRS_CFGR_RELOAD));
333}
334
342__STATIC_INLINE void LL_CRS_SetFreqErrorLimit(uint32_t Value)
343{
344 MODIFY_REG(CRS->CFGR, CRS_CFGR_FELIM, Value << CRS_CFGR_FELIM_Pos);
345}
346
352__STATIC_INLINE uint32_t LL_CRS_GetFreqErrorLimit(void)
353{
354 return (uint32_t)(READ_BIT(CRS->CFGR, CRS_CFGR_FELIM) >> CRS_CFGR_FELIM_Pos);
355}
356
371__STATIC_INLINE void LL_CRS_SetSyncDivider(uint32_t Divider)
372{
373 MODIFY_REG(CRS->CFGR, CRS_CFGR_SYNCDIV, Divider);
374}
375
389__STATIC_INLINE uint32_t LL_CRS_GetSyncDivider(void)
390{
391 return (uint32_t)(READ_BIT(CRS->CFGR, CRS_CFGR_SYNCDIV));
392}
393
403__STATIC_INLINE void LL_CRS_SetSyncSignalSource(uint32_t Source)
404{
405 MODIFY_REG(CRS->CFGR, CRS_CFGR_SYNCSRC, Source);
406}
407
416__STATIC_INLINE uint32_t LL_CRS_GetSyncSignalSource(void)
417{
418 return (uint32_t)(READ_BIT(CRS->CFGR, CRS_CFGR_SYNCSRC));
419}
420
429__STATIC_INLINE void LL_CRS_SetSyncPolarity(uint32_t Polarity)
430{
431 MODIFY_REG(CRS->CFGR, CRS_CFGR_SYNCPOL, Polarity);
432}
433
441__STATIC_INLINE uint32_t LL_CRS_GetSyncPolarity(void)
442{
443 return (uint32_t)(READ_BIT(CRS->CFGR, CRS_CFGR_SYNCPOL));
444}
445
464__STATIC_INLINE void LL_CRS_ConfigSynchronization(uint32_t HSI48CalibrationValue, uint32_t ErrorLimitValue, uint32_t ReloadValue, uint32_t Settings)
465{
466 MODIFY_REG(CRS->CR, CRS_CR_TRIM, HSI48CalibrationValue);
467 MODIFY_REG(CRS->CFGR,
469 ReloadValue | (ErrorLimitValue << CRS_CFGR_FELIM_Pos) | Settings);
470}
471
486__STATIC_INLINE void LL_CRS_GenerateEvent_SWSYNC(void)
487{
488 SET_BIT(CRS->CR, CRS_CR_SWSYNC);
489}
490
499__STATIC_INLINE uint32_t LL_CRS_GetFreqErrorDirection(void)
500{
501 return (uint32_t)(READ_BIT(CRS->ISR, CRS_ISR_FEDIR));
502}
503
509__STATIC_INLINE uint32_t LL_CRS_GetFreqErrorCapture(void)
510{
511 return (uint32_t)(READ_BIT(CRS->ISR, CRS_ISR_FECAP) >> CRS_ISR_FECAP_Pos);
512}
513
528__STATIC_INLINE uint32_t LL_CRS_IsActiveFlag_SYNCOK(void)
529{
530 return ((READ_BIT(CRS->ISR, CRS_ISR_SYNCOKF) == (CRS_ISR_SYNCOKF)) ? 1UL : 0UL);
531}
532
538__STATIC_INLINE uint32_t LL_CRS_IsActiveFlag_SYNCWARN(void)
539{
540 return ((READ_BIT(CRS->ISR, CRS_ISR_SYNCWARNF) == (CRS_ISR_SYNCWARNF)) ? 1UL : 0UL);
541}
542
548__STATIC_INLINE uint32_t LL_CRS_IsActiveFlag_ERR(void)
549{
550 return ((READ_BIT(CRS->ISR, CRS_ISR_ERRF) == (CRS_ISR_ERRF)) ? 1UL : 0UL);
551}
552
558__STATIC_INLINE uint32_t LL_CRS_IsActiveFlag_ESYNC(void)
559{
560 return ((READ_BIT(CRS->ISR, CRS_ISR_ESYNCF) == (CRS_ISR_ESYNCF)) ? 1UL : 0UL);
561}
562
568__STATIC_INLINE uint32_t LL_CRS_IsActiveFlag_SYNCERR(void)
569{
570 return ((READ_BIT(CRS->ISR, CRS_ISR_SYNCERR) == (CRS_ISR_SYNCERR)) ? 1UL : 0UL);
571}
572
578__STATIC_INLINE uint32_t LL_CRS_IsActiveFlag_SYNCMISS(void)
579{
580 return ((READ_BIT(CRS->ISR, CRS_ISR_SYNCMISS) == (CRS_ISR_SYNCMISS)) ? 1UL : 0UL);
581}
582
588__STATIC_INLINE uint32_t LL_CRS_IsActiveFlag_TRIMOVF(void)
589{
590 return ((READ_BIT(CRS->ISR, CRS_ISR_TRIMOVF) == (CRS_ISR_TRIMOVF)) ? 1UL : 0UL);
591}
592
598__STATIC_INLINE void LL_CRS_ClearFlag_SYNCOK(void)
599{
600 WRITE_REG(CRS->ICR, CRS_ICR_SYNCOKC);
601}
602
608__STATIC_INLINE void LL_CRS_ClearFlag_SYNCWARN(void)
609{
610 WRITE_REG(CRS->ICR, CRS_ICR_SYNCWARNC);
611}
612
619__STATIC_INLINE void LL_CRS_ClearFlag_ERR(void)
620{
621 WRITE_REG(CRS->ICR, CRS_ICR_ERRC);
622}
623
629__STATIC_INLINE void LL_CRS_ClearFlag_ESYNC(void)
630{
631 WRITE_REG(CRS->ICR, CRS_ICR_ESYNCC);
632}
633
648__STATIC_INLINE void LL_CRS_EnableIT_SYNCOK(void)
649{
650 SET_BIT(CRS->CR, CRS_CR_SYNCOKIE);
651}
652
658__STATIC_INLINE void LL_CRS_DisableIT_SYNCOK(void)
659{
660 CLEAR_BIT(CRS->CR, CRS_CR_SYNCOKIE);
661}
662
668__STATIC_INLINE uint32_t LL_CRS_IsEnabledIT_SYNCOK(void)
669{
670 return ((READ_BIT(CRS->CR, CRS_CR_SYNCOKIE) == (CRS_CR_SYNCOKIE)) ? 1UL : 0UL);
671}
672
678__STATIC_INLINE void LL_CRS_EnableIT_SYNCWARN(void)
679{
680 SET_BIT(CRS->CR, CRS_CR_SYNCWARNIE);
681}
682
688__STATIC_INLINE void LL_CRS_DisableIT_SYNCWARN(void)
689{
690 CLEAR_BIT(CRS->CR, CRS_CR_SYNCWARNIE);
691}
692
698__STATIC_INLINE uint32_t LL_CRS_IsEnabledIT_SYNCWARN(void)
699{
700 return ((READ_BIT(CRS->CR, CRS_CR_SYNCWARNIE) == (CRS_CR_SYNCWARNIE)) ? 1UL : 0UL);
701}
702
708__STATIC_INLINE void LL_CRS_EnableIT_ERR(void)
709{
710 SET_BIT(CRS->CR, CRS_CR_ERRIE);
711}
712
718__STATIC_INLINE void LL_CRS_DisableIT_ERR(void)
719{
720 CLEAR_BIT(CRS->CR, CRS_CR_ERRIE);
721}
722
728__STATIC_INLINE uint32_t LL_CRS_IsEnabledIT_ERR(void)
729{
730 return ((READ_BIT(CRS->CR, CRS_CR_ERRIE) == (CRS_CR_ERRIE)) ? 1UL : 0UL);
731}
732
738__STATIC_INLINE void LL_CRS_EnableIT_ESYNC(void)
739{
740 SET_BIT(CRS->CR, CRS_CR_ESYNCIE);
741}
742
748__STATIC_INLINE void LL_CRS_DisableIT_ESYNC(void)
749{
750 CLEAR_BIT(CRS->CR, CRS_CR_ESYNCIE);
751}
752
758__STATIC_INLINE uint32_t LL_CRS_IsEnabledIT_ESYNC(void)
759{
760 return ((READ_BIT(CRS->CR, CRS_CR_ESYNCIE) == (CRS_CR_ESYNCIE)) ? 1UL : 0UL);
761}
762
767#if defined(USE_FULL_LL_DRIVER) || defined(__rtems__)
773ErrorStatus LL_CRS_DeInit(void);
774
778#endif /* USE_FULL_LL_DRIVER */
779
788#endif /* defined(CRS) */
789
794#ifdef __cplusplus
795}
796#endif
797
798#endif /* STM32H7xx_LL_CRS_H */
#define CRS_ISR_SYNCWARNF
Definition: stm32h723xx.h:5857
#define CRS_CR_SYNCOKIE
Definition: stm32h723xx.h:5803
#define CRS_CR_ESYNCIE
Definition: stm32h723xx.h:5812
#define CRS_CFGR_SYNCSRC
Definition: stm32h723xx.h:5843
#define CRS_CFGR_FELIM
Definition: stm32h723xx.h:5832
#define CRS_CR_SWSYNC
Definition: stm32h723xx.h:5821
#define CRS_CR_TRIM
Definition: stm32h723xx.h:5824
#define CRS_CFGR_RELOAD
Definition: stm32h723xx.h:5829
#define CRS_ISR_SYNCERR
Definition: stm32h723xx.h:5866
#define CRS_ISR_ESYNCF
Definition: stm32h723xx.h:5863
#define CRS_ISR_FEDIR
Definition: stm32h723xx.h:5875
#define CRS_ISR_ERRF
Definition: stm32h723xx.h:5860
#define CRS_ISR_SYNCMISS
Definition: stm32h723xx.h:5869
#define CRS_ICR_SYNCOKC
Definition: stm32h723xx.h:5883
#define CRS_CFGR_SYNCPOL
Definition: stm32h723xx.h:5849
#define CRS_ICR_SYNCWARNC
Definition: stm32h723xx.h:5886
#define CRS_CR_SYNCWARNIE
Definition: stm32h723xx.h:5806
#define CRS_CR_ERRIE
Definition: stm32h723xx.h:5809
#define CRS_CR_CEN
Definition: stm32h723xx.h:5815
#define CRS_ICR_ESYNCC
Definition: stm32h723xx.h:5892
#define CRS_CFGR_SYNCDIV
Definition: stm32h723xx.h:5836
#define CRS_ISR_SYNCOKF
Definition: stm32h723xx.h:5854
#define CRS_ICR_ERRC
Definition: stm32h723xx.h:5889
#define CRS_ISR_FECAP
Definition: stm32h723xx.h:5878
#define CRS_ISR_TRIMOVF
Definition: stm32h723xx.h:5872
#define CRS_CR_AUTOTRIMEN
Definition: stm32h723xx.h:5818
CMSIS STM32H7xx Device Peripheral Access Layer Header File.