STM32L443xx HAL User Manual
stm32l4xx_ll_rng.h
Go to the documentation of this file.
00001 /**
00002   ******************************************************************************
00003   * @file    stm32l4xx_ll_rng.h
00004   * @author  MCD Application Team
00005   * @brief   Header file of RNG LL module.
00006   ******************************************************************************
00007   * @attention
00008   *
00009   * Copyright (c) 2017 STMicroelectronics.
00010   * All rights reserved.
00011   *
00012   * This software is licensed under terms that can be found in the LICENSE file
00013   * in the root directory of this software component.
00014   * If no LICENSE file comes with this software, it is provided AS-IS.
00015   *
00016   ******************************************************************************
00017   */
00018 
00019 /* Define to prevent recursive inclusion -------------------------------------*/
00020 #ifndef STM32L4xx_LL_RNG_H
00021 #define STM32L4xx_LL_RNG_H
00022 
00023 #ifdef __cplusplus
00024 extern "C" {
00025 #endif
00026 
00027 /* Includes ------------------------------------------------------------------*/
00028 #include "stm32l4xx.h"
00029 
00030 /** @addtogroup STM32L4xx_LL_Driver
00031   * @{
00032   */
00033 
00034 #if defined (RNG)
00035 
00036 /** @defgroup RNG_LL RNG
00037   * @{
00038   */
00039 
00040 /* Private types -------------------------------------------------------------*/
00041 /* Private variables ---------------------------------------------------------*/
00042 /* Private constants ---------------------------------------------------------*/
00043 /* Private macros ------------------------------------------------------------*/
00044 
00045 /* Exported types ------------------------------------------------------------*/
00046 #if defined(RNG_CR_CED)
00047 #if defined(USE_FULL_LL_DRIVER)
00048 /** @defgroup RNG_LL_ES_Init_Struct RNG Exported Init structures
00049   * @{
00050   */
00051 
00052 
00053 /**
00054   * @brief LL RNG Init Structure Definition
00055   */
00056 typedef struct
00057 {
00058   uint32_t         ClockErrorDetection; /*!< Clock error detection.
00059                                       This parameter can be one value of @ref RNG_LL_CED.
00060 
00061                                       This parameter can be modified using unitary functions @ref LL_RNG_EnableClkErrorDetect(). */
00062 } LL_RNG_InitTypeDef;
00063 
00064 /**
00065   * @}
00066   */
00067 #endif /* USE_FULL_LL_DRIVER */
00068 #endif
00069 /* Exported constants --------------------------------------------------------*/
00070 /** @defgroup RNG_LL_Exported_Constants RNG Exported Constants
00071   * @{
00072   */
00073 
00074 #if defined(RNG_CR_CED)
00075 /** @defgroup RNG_LL_CED Clock Error Detection
00076   * @{
00077   */
00078 #define LL_RNG_CED_ENABLE         0x00000000U              /*!< Clock error detection enabled  */
00079 #define LL_RNG_CED_DISABLE        RNG_CR_CED               /*!< Clock error detection disabled */
00080 /**
00081   * @}
00082   */
00083 #endif
00084 
00085 #if defined(RNG_CR_CONDRST)
00086 /** @defgroup RNG_LL_Clock_Divider_Factor  Value used to configure an internal
00087  *            programmable divider acting on the incoming RNG clock
00088   * @{
00089   */
00090 #define LL_RNG_CLKDIV_BY_1       (0x00000000UL)      /*!< No clock division  */
00091 #define LL_RNG_CLKDIV_BY_2       (RNG_CR_CLKDIV_0)
00092                            /*!< 2 RNG clock cycles per internal RNG clock    */
00093 #define LL_RNG_CLKDIV_BY_4       (RNG_CR_CLKDIV_1)
00094                            /*!< 4 RNG clock cycles per internal RNG clock    */
00095 #define LL_RNG_CLKDIV_BY_8       (RNG_CR_CLKDIV_1 | RNG_CR_CLKDIV_0)
00096                            /*!< 8 RNG clock cycles per internal RNG clock    */
00097 #define LL_RNG_CLKDIV_BY_16      (RNG_CR_CLKDIV_2)
00098                            /*!< 16 RNG clock cycles per internal RNG clock   */
00099 #define LL_RNG_CLKDIV_BY_32      (RNG_CR_CLKDIV_2 | RNG_CR_CLKDIV_0)
00100                            /*!< 32 RNG clock cycles per internal RNG clock   */
00101 #define LL_RNG_CLKDIV_BY_64      (RNG_CR_CLKDIV_2 | RNG_CR_CLKDIV_1)
00102                            /*!< 64 RNG clock cycles per internal RNG clock   */
00103 #define LL_RNG_CLKDIV_BY_128     (RNG_CR_CLKDIV_2 | RNG_CR_CLKDIV_1 | RNG_CR_CLKDIV_0)
00104                            /*!< 128 RNG clock cycles per internal RNG clock  */
00105 #define LL_RNG_CLKDIV_BY_256     (RNG_CR_CLKDIV_3)
00106                            /*!< 256 RNG clock cycles per internal RNG clock  */
00107 #define LL_RNG_CLKDIV_BY_512     (RNG_CR_CLKDIV_3 | RNG_CR_CLKDIV_0)
00108                            /*!< 512 RNG clock cycles per internal RNG clock  */
00109 #define LL_RNG_CLKDIV_BY_1024    (RNG_CR_CLKDIV_3 | RNG_CR_CLKDIV_1)
00110                            /*!< 1024 RNG clock cycles per internal RNG clock */
00111 #define LL_RNG_CLKDIV_BY_2048    (RNG_CR_CLKDIV_3 | RNG_CR_CLKDIV_1 | RNG_CR_CLKDIV_0)
00112                           /*!< 2048 RNG clock cycles per internal RNG clock  */
00113 #define LL_RNG_CLKDIV_BY_4096    (RNG_CR_CLKDIV_3 | RNG_CR_CLKDIV_2)
00114                            /*!< 4096 RNG clock cycles per internal RNG clock  */
00115 #define LL_RNG_CLKDIV_BY_8192    (RNG_CR_CLKDIV_3 | RNG_CR_CLKDIV_2 | RNG_CR_CLKDIV_0)
00116                           /*!< 8192 RNG clock cycles per internal RNG clock  */
00117 #define LL_RNG_CLKDIV_BY_16384   (RNG_CR_CLKDIV_3 | RNG_CR_CLKDIV_2 | RNG_CR_CLKDIV_1)
00118                           /*!< 16384 RNG clock cycles per internal RNG clock */
00119 #define LL_RNG_CLKDIV_BY_32768   (RNG_CR_CLKDIV_3 | RNG_CR_CLKDIV_2 | RNG_CR_CLKDIV_1 | RNG_CR_CLKDIV_0)
00120                           /*!< 32768 RNG clock cycles per internal RNG clock */
00121 /**
00122   * @}
00123   */
00124 
00125 /** @defgroup RNG_LL_NIST_Compliance  NIST Compliance configuration
00126   * @{
00127   */
00128 #define LL_RNG_NIST_COMPLIANT     (0x00000000UL) /*!< NIST compliant configuration*/
00129 #define LL_RNG_NOTNIST_COMPLIANT (RNG_CR_NISTC) /*!< Non NIST compliant configuration */
00130 
00131 /**
00132   * @}
00133   */
00134 #endif/*RNG_CR_CONDRST*/
00135 /** @defgroup RNG_LL_EC_GET_FLAG Get Flags Defines
00136   * @brief    Flags defines which can be used with LL_RNG_ReadReg function
00137   * @{
00138   */
00139 #define LL_RNG_SR_DRDY RNG_SR_DRDY    /*!< Register contains valid random data */
00140 #define LL_RNG_SR_CECS RNG_SR_CECS    /*!< Clock error current status */
00141 #define LL_RNG_SR_SECS RNG_SR_SECS    /*!< Seed error current status */
00142 #define LL_RNG_SR_CEIS RNG_SR_CEIS    /*!< Clock error interrupt status */
00143 #define LL_RNG_SR_SEIS RNG_SR_SEIS    /*!< Seed error interrupt status */
00144 /**
00145   * @}
00146   */
00147 
00148 /** @defgroup RNG_LL_EC_IT IT Defines
00149   * @brief    IT defines which can be used with LL_RNG_ReadReg and  LL_RNG_WriteReg macros
00150   * @{
00151   */
00152 #define LL_RNG_CR_IE   RNG_CR_IE      /*!< RNG Interrupt enable */
00153 /**
00154   * @}
00155   */
00156 
00157 /**
00158   * @}
00159   */
00160 
00161 /* Exported macro ------------------------------------------------------------*/
00162 /** @defgroup RNG_LL_Exported_Macros RNG Exported Macros
00163   * @{
00164   */
00165 
00166 /** @defgroup RNG_LL_EM_WRITE_READ Common Write and read registers Macros
00167   * @{
00168   */
00169 
00170 /**
00171   * @brief  Write a value in RNG register
00172   * @param  __INSTANCE__ RNG Instance
00173   * @param  __REG__ Register to be written
00174   * @param  __VALUE__ Value to be written in the register
00175   * @retval None
00176   */
00177 #define LL_RNG_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
00178 
00179 /**
00180   * @brief  Read a value in RNG register
00181   * @param  __INSTANCE__ RNG Instance
00182   * @param  __REG__ Register to be read
00183   * @retval Register value
00184   */
00185 #define LL_RNG_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
00186 /**
00187   * @}
00188   */
00189 
00190 /**
00191   * @}
00192   */
00193 
00194 
00195 /* Exported functions --------------------------------------------------------*/
00196 /** @defgroup RNG_LL_Exported_Functions RNG Exported Functions
00197   * @{
00198   */
00199 /** @defgroup RNG_LL_EF_Configuration RNG Configuration functions
00200   * @{
00201   */
00202 
00203 /**
00204   * @brief  Enable Random Number Generation
00205   * @rmtoll CR           RNGEN         LL_RNG_Enable
00206   * @param  RNGx RNG Instance
00207   * @retval None
00208   */
00209 __STATIC_INLINE void LL_RNG_Enable(RNG_TypeDef *RNGx)
00210 {
00211   SET_BIT(RNGx->CR, RNG_CR_RNGEN);
00212 }
00213 
00214 /**
00215   * @brief  Disable Random Number Generation
00216   * @rmtoll CR           RNGEN         LL_RNG_Disable
00217   * @param  RNGx RNG Instance
00218   * @retval None
00219   */
00220 __STATIC_INLINE void LL_RNG_Disable(RNG_TypeDef *RNGx)
00221 {
00222   CLEAR_BIT(RNGx->CR, RNG_CR_RNGEN);
00223 }
00224 
00225 /**
00226   * @brief  Check if Random Number Generator is enabled
00227   * @rmtoll CR           RNGEN         LL_RNG_IsEnabled
00228   * @param  RNGx RNG Instance
00229   * @retval State of bit (1 or 0).
00230   */
00231 __STATIC_INLINE uint32_t LL_RNG_IsEnabled(RNG_TypeDef *RNGx)
00232 {
00233   return ((READ_BIT(RNGx->CR, RNG_CR_RNGEN) == (RNG_CR_RNGEN)) ? 1UL : 0UL);
00234 }
00235 
00236 #if defined(RNG_CR_CED)
00237 /**
00238   * @brief  Enable Clock Error Detection
00239   * @rmtoll CR           CED           LL_RNG_EnableClkErrorDetect
00240   * @param  RNGx RNG Instance
00241   * @retval None
00242   */
00243 __STATIC_INLINE void LL_RNG_EnableClkErrorDetect(RNG_TypeDef *RNGx)
00244 {
00245   CLEAR_BIT(RNGx->CR, RNG_CR_CED);
00246 }
00247 
00248 /**
00249   * @brief  Disable RNG Clock Error Detection
00250   * @rmtoll CR           CED         LL_RNG_DisableClkErrorDetect
00251   * @param  RNGx RNG Instance
00252   * @retval None
00253   */
00254 __STATIC_INLINE void LL_RNG_DisableClkErrorDetect(RNG_TypeDef *RNGx)
00255 {
00256   SET_BIT(RNGx->CR, RNG_CR_CED);
00257 }
00258 
00259 /**
00260   * @brief  Check if RNG Clock Error Detection is enabled
00261   * @rmtoll CR           CED         LL_RNG_IsEnabledClkErrorDetect
00262   * @param  RNGx RNG Instance
00263   * @retval State of bit (1 or 0).
00264   */
00265 __STATIC_INLINE uint32_t LL_RNG_IsEnabledClkErrorDetect(RNG_TypeDef *RNGx)
00266 {
00267   return ((READ_BIT(RNGx->CR, RNG_CR_CED) != (RNG_CR_CED)) ? 1UL : 0UL);
00268 }
00269 
00270 #if defined(RNG_CR_CONDRST)
00271 /**
00272   * @brief  Set RNG Conditioning Soft Reset bit
00273   * @rmtoll CR           CONDRST          LL_RNG_SetConditioningResetBit
00274   * @param  RNGx RNG Instance
00275   * @retval None
00276   */
00277 __STATIC_INLINE void LL_RNG_SetConditioningResetBit(RNG_TypeDef *RNGx)
00278 {
00279    SET_BIT(RNGx->CR, RNG_CR_CONDRST);
00280 }
00281 
00282 /**
00283   * @brief  Reset RNG  Conditioning Soft Reset bit
00284   * @rmtoll CR           CONDRST         LL_RNG_ResetConditioningResetBit
00285   * @param  RNGx RNG Instance
00286   * @retval None
00287   */
00288 __STATIC_INLINE void LL_RNG_ResetConditioningResetBit(RNG_TypeDef *RNGx)
00289 {
00290   CLEAR_BIT(RNGx->CR, RNG_CR_CONDRST);
00291 }
00292 
00293 /**
00294   * @brief  Check if RNG Conditioning Soft Reset bit is set
00295   * @rmtoll CR           CONDRST         LL_RNG_IsResetConditioningBitSet
00296   * @param  RNGx RNG Instance
00297   * @retval State of bit (1 or 0).
00298   */
00299 __STATIC_INLINE uint32_t LL_RNG_IsResetConditioningBitSet(RNG_TypeDef *RNGx)
00300 {
00301   return ((READ_BIT(RNGx->CR, RNG_CR_CONDRST) == (RNG_CR_CONDRST)) ? 1UL : 0UL);
00302 }
00303 
00304 /**
00305   * @brief  Enable RNG Config Lock
00306   * @rmtoll CR           CONFIGLOCK          LL_RNG_ConfigLock
00307   * @param  RNGx RNG Instance
00308   * @retval None
00309   */
00310 __STATIC_INLINE void LL_RNG_ConfigLock(RNG_TypeDef *RNGx)
00311 {
00312    SET_BIT(RNGx->CR, RNG_CR_CONFIGLOCK);
00313 }
00314 
00315 /**
00316   * @brief  Check if RNG Config Lock is enabled
00317   * @rmtoll CR           CONFIGLOCK         LL_RNG_IsConfigLocked
00318   * @param  RNGx RNG Instance
00319   * @retval State of bit (1 or 0).
00320   */
00321 __STATIC_INLINE uint32_t LL_RNG_IsConfigLocked(RNG_TypeDef *RNGx)
00322 {
00323   return ((READ_BIT(RNGx->CR, RNG_CR_CONFIGLOCK) == (RNG_CR_CONFIGLOCK)) ? 1UL : 0UL);
00324 }
00325 
00326 /**
00327   * @brief  Enable NIST Compliance
00328   * @rmtoll CR           NISTC          LL_RNG_EnableNistCompliance
00329   * @param  RNGx RNG Instance
00330   * @retval None
00331   */
00332 __STATIC_INLINE void LL_RNG_EnableNistCompliance(RNG_TypeDef *RNGx)
00333 {
00334    CLEAR_BIT(RNGx->CR, RNG_CR_NISTC);
00335 }
00336 
00337 /**
00338   * @brief  Disable NIST Compliance
00339   * @rmtoll CR           NISTC         LL_RNG_DisableNistCompliance
00340   * @param  RNGx RNG Instance
00341   * @retval None
00342   */
00343 __STATIC_INLINE void LL_RNG_DisableNistCompliance(RNG_TypeDef *RNGx)
00344 {
00345   SET_BIT(RNGx->CR, RNG_CR_NISTC);
00346 }
00347 
00348 /**
00349   * @brief  Check if NIST Compliance is enabled
00350   * @rmtoll CR           NISTC         LL_RNG_IsNistComplianceEnabled
00351   * @param  RNGx RNG Instance
00352   * @retval State of bit (1 or 0).
00353   */
00354 __STATIC_INLINE uint32_t LL_RNG_IsNistComplianceEnabled(RNG_TypeDef *RNGx)
00355 {
00356   return ((READ_BIT(RNGx->CR, RNG_CR_NISTC) != (RNG_CR_NISTC)) ? 1UL : 0UL);
00357 }
00358 
00359 /**
00360   * @brief  Set RNG  Config1 Configuration field value
00361   * @rmtoll CR           RNG_CONFIG1         LL_RNG_SetConfig1
00362   * @param  RNGx RNG Instance
00363   * @param  Config1 Value between 0 and 0x3F
00364   * @retval None
00365   */
00366 __STATIC_INLINE void LL_RNG_SetConfig1(RNG_TypeDef *RNGx, uint32_t Config1)
00367 {
00368   MODIFY_REG(RNGx->CR, RNG_CR_RNG_CONFIG1, Config1 << RNG_CR_RNG_CONFIG1_Pos);
00369 }
00370 
00371 /**
00372   * @brief  Get RNG  Config1 Configuration field value
00373   * @rmtoll CR           RNG_CONFIG1         LL_RNG_GetConfig1
00374   * @param  RNGx RNG Instance
00375   * @retval Returned Value expressed on 6 bits : Value between 0 and 0x3F
00376   */
00377 __STATIC_INLINE uint32_t LL_RNG_GetConfig1(RNG_TypeDef *RNGx)
00378 {
00379   return (uint32_t)(READ_BIT(RNGx->CR, RNG_CR_RNG_CONFIG1) >> RNG_CR_RNG_CONFIG1_Pos);
00380 }
00381 
00382 /**
00383   * @brief  Set RNG  Config2 Configuration field value
00384   * @rmtoll CR           RNG_CONFIG2         LL_RNG_SetConfig2
00385   * @param  RNGx RNG Instance
00386   * @param  Config2 Value between 0 and 0x7
00387   * @retval None
00388   */
00389 __STATIC_INLINE void LL_RNG_SetConfig2(RNG_TypeDef *RNGx, uint32_t Config2)
00390 {
00391   MODIFY_REG(RNGx->CR, RNG_CR_RNG_CONFIG2, Config2 << RNG_CR_RNG_CONFIG2_Pos);
00392 }
00393 
00394 /**
00395   * @brief  Get RNG  Config2 Configuration field value
00396   * @rmtoll CR           RNG_CONFIG2         LL_RNG_GetConfig2
00397   * @param  RNGx RNG Instance
00398   * @retval Returned Value expressed on 3 bits : Value between 0 and 0x7
00399   */
00400 __STATIC_INLINE uint32_t LL_RNG_GetConfig2(RNG_TypeDef *RNGx)
00401 {
00402   return (uint32_t)(READ_BIT(RNGx->CR, RNG_CR_RNG_CONFIG2) >> RNG_CR_RNG_CONFIG2_Pos);
00403 }
00404 
00405 /**
00406   * @brief  Set RNG  Config3 Configuration field value
00407   * @rmtoll CR           RNG_CONFIG3         LL_RNG_SetConfig3
00408   * @param  RNGx RNG Instance
00409   * @param  Config3 Value between 0 and 0xF
00410   * @retval None
00411   */
00412 __STATIC_INLINE void LL_RNG_SetConfig3(RNG_TypeDef *RNGx, uint32_t Config3)
00413 {
00414   MODIFY_REG(RNGx->CR, RNG_CR_RNG_CONFIG3, Config3 << RNG_CR_RNG_CONFIG3_Pos);
00415 }
00416 
00417 /**
00418   * @brief  Get RNG  Config3 Configuration field value
00419   * @rmtoll CR           RNG_CONFIG3         LL_RNG_GetConfig3
00420   * @param  RNGx RNG Instance
00421   * @retval Returned Value expressed on 4 bits : Value between 0 and 0xF
00422   */
00423 __STATIC_INLINE uint32_t LL_RNG_GetConfig3(RNG_TypeDef *RNGx)
00424 {
00425   return (uint32_t)(READ_BIT(RNGx->CR, RNG_CR_RNG_CONFIG3) >> RNG_CR_RNG_CONFIG3_Pos);
00426 }
00427 
00428 /**
00429   * @brief  Set RNG  Clock divider factor
00430   * @rmtoll CR           CLKDIV         LL_RNG_SetClockDivider
00431   * @param  RNGx RNG Instance
00432   * @param  Divider can be one of the following values:
00433   *         @arg @ref LL_RNG_CLKDIV_BY_1
00434   *         @arg @ref LL_RNG_CLKDIV_BY_2
00435   *         @arg @ref LL_RNG_CLKDIV_BY_4
00436   *         @arg @ref LL_RNG_CLKDIV_BY_8
00437   *         @arg @ref LL_RNG_CLKDIV_BY_16
00438   *         @arg @ref LL_RNG_CLKDIV_BY_32
00439   *         @arg @ref LL_RNG_CLKDIV_BY_64
00440   *         @arg @ref LL_RNG_CLKDIV_BY_128
00441   *         @arg @ref LL_RNG_CLKDIV_BY_256
00442   *         @arg @ref LL_RNG_CLKDIV_BY_512
00443   *         @arg @ref LL_RNG_CLKDIV_BY_1024
00444   *         @arg @ref LL_RNG_CLKDIV_BY_2048
00445   *         @arg @ref LL_RNG_CLKDIV_BY_4096
00446   *         @arg @ref LL_RNG_CLKDIV_BY_8192
00447   *         @arg @ref LL_RNG_CLKDIV_BY_16384
00448   *         @arg @ref LL_RNG_CLKDIV_BY_32768
00449   * @retval None
00450   */
00451 __STATIC_INLINE void LL_RNG_SetClockDivider(RNG_TypeDef *RNGx, uint32_t Divider)
00452 {
00453   MODIFY_REG(RNGx->CR, RNG_CR_CLKDIV, Divider << RNG_CR_CLKDIV_Pos);
00454 }
00455 
00456 /**
00457   * @brief  Get RNG  Clock divider factor
00458   * @rmtoll CR           CLKDIV         LL_RNG_GetClockDivider
00459   * @param  RNGx RNG Instance
00460   * @retval Returned value can be one of the following values:
00461   *         @arg @ref LL_RNG_CLKDIV_BY_1
00462   *         @arg @ref LL_RNG_CLKDIV_BY_2
00463   *         @arg @ref LL_RNG_CLKDIV_BY_4
00464   *         @arg @ref LL_RNG_CLKDIV_BY_8
00465   *         @arg @ref LL_RNG_CLKDIV_BY_16
00466   *         @arg @ref LL_RNG_CLKDIV_BY_32
00467   *         @arg @ref LL_RNG_CLKDIV_BY_64
00468   *         @arg @ref LL_RNG_CLKDIV_BY_128
00469   *         @arg @ref LL_RNG_CLKDIV_BY_256
00470   *         @arg @ref LL_RNG_CLKDIV_BY_512
00471   *         @arg @ref LL_RNG_CLKDIV_BY_1024
00472   *         @arg @ref LL_RNG_CLKDIV_BY_2048
00473   *         @arg @ref LL_RNG_CLKDIV_BY_4096
00474   *         @arg @ref LL_RNG_CLKDIV_BY_8192
00475   *         @arg @ref LL_RNG_CLKDIV_BY_16384
00476   *         @arg @ref LL_RNG_CLKDIV_BY_32768
00477   */
00478 __STATIC_INLINE uint32_t LL_RNG_GetClockDivider(RNG_TypeDef *RNGx)
00479 {
00480   return (uint32_t)READ_BIT(RNGx->CR, RNG_CR_CLKDIV);
00481 }
00482 #endif /*RNG_CR_CONDRST*/
00483 #endif
00484 /**
00485   * @}
00486   */
00487 
00488 /** @defgroup RNG_LL_EF_FLAG_Management FLAG Management
00489   * @{
00490   */
00491 
00492 /**
00493   * @brief  Indicate if the RNG Data ready Flag is set or not
00494   * @rmtoll SR           DRDY          LL_RNG_IsActiveFlag_DRDY
00495   * @param  RNGx RNG Instance
00496   * @retval State of bit (1 or 0).
00497   */
00498 __STATIC_INLINE uint32_t LL_RNG_IsActiveFlag_DRDY(RNG_TypeDef *RNGx)
00499 {
00500   return ((READ_BIT(RNGx->SR, RNG_SR_DRDY) == (RNG_SR_DRDY)) ? 1UL : 0UL);
00501 }
00502 
00503 /**
00504   * @brief  Indicate if the Clock Error Current Status Flag is set or not
00505   * @rmtoll SR           CECS          LL_RNG_IsActiveFlag_CECS
00506   * @param  RNGx RNG Instance
00507   * @retval State of bit (1 or 0).
00508   */
00509 __STATIC_INLINE uint32_t LL_RNG_IsActiveFlag_CECS(RNG_TypeDef *RNGx)
00510 {
00511   return ((READ_BIT(RNGx->SR, RNG_SR_CECS) == (RNG_SR_CECS)) ? 1UL : 0UL);
00512 }
00513 
00514 /**
00515   * @brief  Indicate if the Seed Error Current Status Flag is set or not
00516   * @rmtoll SR           SECS          LL_RNG_IsActiveFlag_SECS
00517   * @param  RNGx RNG Instance
00518   * @retval State of bit (1 or 0).
00519   */
00520 __STATIC_INLINE uint32_t LL_RNG_IsActiveFlag_SECS(RNG_TypeDef *RNGx)
00521 {
00522   return ((READ_BIT(RNGx->SR, RNG_SR_SECS) == (RNG_SR_SECS)) ? 1UL : 0UL);
00523 }
00524 
00525 /**
00526   * @brief  Indicate if the Clock Error Interrupt Status Flag is set or not
00527   * @rmtoll SR           CEIS          LL_RNG_IsActiveFlag_CEIS
00528   * @param  RNGx RNG Instance
00529   * @retval State of bit (1 or 0).
00530   */
00531 __STATIC_INLINE uint32_t LL_RNG_IsActiveFlag_CEIS(RNG_TypeDef *RNGx)
00532 {
00533   return ((READ_BIT(RNGx->SR, RNG_SR_CEIS) == (RNG_SR_CEIS)) ? 1UL : 0UL);
00534 }
00535 
00536 /**
00537   * @brief  Indicate if the Seed Error Interrupt Status Flag is set or not
00538   * @rmtoll SR           SEIS          LL_RNG_IsActiveFlag_SEIS
00539   * @param  RNGx RNG Instance
00540   * @retval State of bit (1 or 0).
00541   */
00542 __STATIC_INLINE uint32_t LL_RNG_IsActiveFlag_SEIS(RNG_TypeDef *RNGx)
00543 {
00544   return ((READ_BIT(RNGx->SR, RNG_SR_SEIS) == (RNG_SR_SEIS)) ? 1UL : 0UL);
00545 }
00546 
00547 /**
00548   * @brief  Clear Clock Error interrupt Status (CEIS) Flag
00549   * @rmtoll SR           CEIS          LL_RNG_ClearFlag_CEIS
00550   * @param  RNGx RNG Instance
00551   * @retval None
00552   */
00553 __STATIC_INLINE void LL_RNG_ClearFlag_CEIS(RNG_TypeDef *RNGx)
00554 {
00555   WRITE_REG(RNGx->SR, ~RNG_SR_CEIS);
00556 }
00557 
00558 /**
00559   * @brief  Clear Seed Error interrupt Status (SEIS) Flag
00560   * @rmtoll SR           SEIS          LL_RNG_ClearFlag_SEIS
00561   * @param  RNGx RNG Instance
00562   * @retval None
00563   */
00564 __STATIC_INLINE void LL_RNG_ClearFlag_SEIS(RNG_TypeDef *RNGx)
00565 {
00566   WRITE_REG(RNGx->SR, ~RNG_SR_SEIS);
00567 }
00568 
00569 /**
00570   * @}
00571   */
00572 
00573 /** @defgroup RNG_LL_EF_IT_Management IT Management
00574   * @{
00575   */
00576 
00577 /**
00578   * @brief  Enable Random Number Generator Interrupt
00579   *         (applies for either Seed error, Clock Error or Data ready interrupts)
00580   * @rmtoll CR           IE            LL_RNG_EnableIT
00581   * @param  RNGx RNG Instance
00582   * @retval None
00583   */
00584 __STATIC_INLINE void LL_RNG_EnableIT(RNG_TypeDef *RNGx)
00585 {
00586   SET_BIT(RNGx->CR, RNG_CR_IE);
00587 }
00588 
00589 /**
00590   * @brief  Disable Random Number Generator Interrupt
00591   *         (applies for either Seed error, Clock Error or Data ready interrupts)
00592   * @rmtoll CR           IE            LL_RNG_DisableIT
00593   * @param  RNGx RNG Instance
00594   * @retval None
00595   */
00596 __STATIC_INLINE void LL_RNG_DisableIT(RNG_TypeDef *RNGx)
00597 {
00598   CLEAR_BIT(RNGx->CR, RNG_CR_IE);
00599 }
00600 
00601 /**
00602   * @brief  Check if Random Number Generator Interrupt is enabled
00603   *         (applies for either Seed error, Clock Error or Data ready interrupts)
00604   * @rmtoll CR           IE            LL_RNG_IsEnabledIT
00605   * @param  RNGx RNG Instance
00606   * @retval State of bit (1 or 0).
00607   */
00608 __STATIC_INLINE uint32_t LL_RNG_IsEnabledIT(RNG_TypeDef *RNGx)
00609 {
00610   return ((READ_BIT(RNGx->CR, RNG_CR_IE) == (RNG_CR_IE)) ? 1UL : 0UL);
00611 }
00612 
00613 /**
00614   * @}
00615   */
00616 
00617 /** @defgroup RNG_LL_EF_Data_Management Data Management
00618   * @{
00619   */
00620 
00621 /**
00622   * @brief  Return32-bit Random Number value
00623   * @rmtoll DR           RNDATA        LL_RNG_ReadRandData32
00624   * @param  RNGx RNG Instance
00625   * @retval Generated 32-bit random value
00626   */
00627 __STATIC_INLINE uint32_t LL_RNG_ReadRandData32(RNG_TypeDef *RNGx)
00628 {
00629   return (uint32_t)(READ_REG(RNGx->DR));
00630 }
00631 
00632 /**
00633   * @}
00634   */
00635 #if defined(RNG_VER_3_2) || defined (RNG_VER_3_1)
00636 /** @defgroup RNG_LL_EF_Health_Test_Control Health Test Control
00637   * @{
00638   */
00639 
00640 /**
00641   * @brief  Set RNG Health Test Control
00642   * @rmtoll HTCR       HTCFG       LL_RNG_SetHealthconfiguration
00643   * @param  RNGx RNG Instance
00644   * @param  HTCFG can be values of 32 bits
00645   * @retval None
00646   */
00647 __STATIC_INLINE void LL_RNG_SetHealthconfiguration(RNG_TypeDef *RNGx, uint32_t HTCFG)
00648 {
00649   WRITE_REG(RNGx->HTCR, HTCFG);
00650 }
00651 
00652 /**
00653   * @brief  Get RNG Health Test Control
00654   * @rmtoll HTCR         HTCFG        LL_RNG_GetHealthconfiguration
00655   * @param  RNGx RNG Instance
00656   * @retval Return 32-bit RNG Health Test configuration
00657   */
00658 __STATIC_INLINE uint32_t LL_RNG_GetHealthconfiguration(RNG_TypeDef *RNGx)
00659 {
00660   return (uint32_t)READ_REG(RNGx->HTCR);
00661 }
00662 
00663 /**
00664   * @}
00665   */
00666 #endif  /* RNG_VER_3_2 || RNG_VER_3_1 */
00667 
00668 #if defined(USE_FULL_LL_DRIVER)
00669 /** @defgroup RNG_LL_EF_Init Initialization and de-initialization functions
00670   * @{
00671   */
00672 #if defined(RNG_CR_CED)
00673 ErrorStatus LL_RNG_Init(RNG_TypeDef *RNGx, LL_RNG_InitTypeDef *RNG_InitStruct);
00674 void LL_RNG_StructInit(LL_RNG_InitTypeDef *RNG_InitStruct);
00675 #endif
00676 ErrorStatus LL_RNG_DeInit(RNG_TypeDef *RNGx);
00677 
00678 /**
00679   * @}
00680   */
00681 #endif /* USE_FULL_LL_DRIVER */
00682 
00683 /**
00684   * @}
00685   */
00686 
00687 /**
00688   * @}
00689   */
00690 
00691 #endif /* RNG */
00692 
00693 /**
00694   * @}
00695   */
00696 
00697 #ifdef __cplusplus
00698 }
00699 #endif
00700 
00701 #endif /* STM32L4xx_LL_RNG_H */