STM32F479xx HAL User Manual
stm32f4xx_ll_rng.h
Go to the documentation of this file.
00001 /**
00002   ******************************************************************************
00003   * @file    stm32f4xx_ll_rng.h
00004   * @author  MCD Application Team
00005   * @brief   Header file of RNG LL module.
00006   ******************************************************************************
00007   * @attention
00008   *
00009   * <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
00010   * All rights reserved.</center></h2>
00011   *
00012   * This software component is licensed by ST under BSD 3-Clause license,
00013   * the "License"; You may not use this file except in compliance with the
00014   * License. You may obtain a copy of the License at:
00015   *                        opensource.org/licenses/BSD-3-Clause
00016   *
00017   ******************************************************************************
00018   */
00019 
00020 /* Define to prevent recursive inclusion -------------------------------------*/
00021 #ifndef STM32F4xx_LL_RNG_H
00022 #define STM32F4xx_LL_RNG_H
00023 
00024 #ifdef __cplusplus
00025 extern "C" {
00026 #endif
00027 
00028 /* Includes ------------------------------------------------------------------*/
00029 #include "stm32f4xx.h"
00030 
00031 /** @addtogroup STM32F4xx_LL_Driver
00032   * @{
00033   */
00034 
00035 #if defined (RNG)
00036 
00037 /** @defgroup RNG_LL RNG
00038   * @{
00039   */
00040 
00041 /* Private types -------------------------------------------------------------*/
00042 /* Private variables ---------------------------------------------------------*/
00043 /* Private constants ---------------------------------------------------------*/
00044 /* Private macros ------------------------------------------------------------*/
00045 
00046 /* Exported types ------------------------------------------------------------*/
00047 /* Exported constants --------------------------------------------------------*/
00048 /** @defgroup RNG_LL_Exported_Constants RNG Exported Constants
00049   * @{
00050   */
00051 
00052 
00053 /** @defgroup RNG_LL_EC_GET_FLAG Get Flags Defines
00054   * @brief    Flags defines which can be used with LL_RNG_ReadReg function
00055   * @{
00056   */
00057 #define LL_RNG_SR_DRDY RNG_SR_DRDY    /*!< Register contains valid random data */
00058 #define LL_RNG_SR_CECS RNG_SR_CECS    /*!< Clock error current status */
00059 #define LL_RNG_SR_SECS RNG_SR_SECS    /*!< Seed error current status */
00060 #define LL_RNG_SR_CEIS RNG_SR_CEIS    /*!< Clock error interrupt status */
00061 #define LL_RNG_SR_SEIS RNG_SR_SEIS    /*!< Seed error interrupt status */
00062 /**
00063   * @}
00064   */
00065 
00066 /** @defgroup RNG_LL_EC_IT IT Defines
00067   * @brief    IT defines which can be used with LL_RNG_ReadReg and  LL_RNG_WriteReg macros
00068   * @{
00069   */
00070 #define LL_RNG_CR_IE   RNG_CR_IE      /*!< RNG Interrupt enable */
00071 /**
00072   * @}
00073   */
00074 
00075 /**
00076   * @}
00077   */
00078 
00079 /* Exported macro ------------------------------------------------------------*/
00080 /** @defgroup RNG_LL_Exported_Macros RNG Exported Macros
00081   * @{
00082   */
00083 
00084 /** @defgroup RNG_LL_EM_WRITE_READ Common Write and read registers Macros
00085   * @{
00086   */
00087 
00088 /**
00089   * @brief  Write a value in RNG register
00090   * @param  __INSTANCE__ RNG Instance
00091   * @param  __REG__ Register to be written
00092   * @param  __VALUE__ Value to be written in the register
00093   * @retval None
00094   */
00095 #define LL_RNG_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
00096 
00097 /**
00098   * @brief  Read a value in RNG register
00099   * @param  __INSTANCE__ RNG Instance
00100   * @param  __REG__ Register to be read
00101   * @retval Register value
00102   */
00103 #define LL_RNG_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
00104 /**
00105   * @}
00106   */
00107 
00108 /**
00109   * @}
00110   */
00111 
00112 
00113 /* Exported functions --------------------------------------------------------*/
00114 /** @defgroup RNG_LL_Exported_Functions RNG Exported Functions
00115   * @{
00116   */
00117 /** @defgroup RNG_LL_EF_Configuration RNG Configuration functions
00118   * @{
00119   */
00120 
00121 /**
00122   * @brief  Enable Random Number Generation
00123   * @rmtoll CR           RNGEN         LL_RNG_Enable
00124   * @param  RNGx RNG Instance
00125   * @retval None
00126   */
00127 __STATIC_INLINE void LL_RNG_Enable(RNG_TypeDef *RNGx)
00128 {
00129   SET_BIT(RNGx->CR, RNG_CR_RNGEN);
00130 }
00131 
00132 /**
00133   * @brief  Disable Random Number Generation
00134   * @rmtoll CR           RNGEN         LL_RNG_Disable
00135   * @param  RNGx RNG Instance
00136   * @retval None
00137   */
00138 __STATIC_INLINE void LL_RNG_Disable(RNG_TypeDef *RNGx)
00139 {
00140   CLEAR_BIT(RNGx->CR, RNG_CR_RNGEN);
00141 }
00142 
00143 /**
00144   * @brief  Check if Random Number Generator is enabled
00145   * @rmtoll CR           RNGEN         LL_RNG_IsEnabled
00146   * @param  RNGx RNG Instance
00147   * @retval State of bit (1 or 0).
00148   */
00149 __STATIC_INLINE uint32_t LL_RNG_IsEnabled(RNG_TypeDef *RNGx)
00150 {
00151   return ((READ_BIT(RNGx->CR, RNG_CR_RNGEN) == (RNG_CR_RNGEN)) ? 1UL : 0UL);
00152 }
00153 
00154 /**
00155   * @}
00156   */
00157 
00158 /** @defgroup RNG_LL_EF_FLAG_Management FLAG Management
00159   * @{
00160   */
00161 
00162 /**
00163   * @brief  Indicate if the RNG Data ready Flag is set or not
00164   * @rmtoll SR           DRDY          LL_RNG_IsActiveFlag_DRDY
00165   * @param  RNGx RNG Instance
00166   * @retval State of bit (1 or 0).
00167   */
00168 __STATIC_INLINE uint32_t LL_RNG_IsActiveFlag_DRDY(RNG_TypeDef *RNGx)
00169 {
00170   return ((READ_BIT(RNGx->SR, RNG_SR_DRDY) == (RNG_SR_DRDY)) ? 1UL : 0UL);
00171 }
00172 
00173 /**
00174   * @brief  Indicate if the Clock Error Current Status Flag is set or not
00175   * @rmtoll SR           CECS          LL_RNG_IsActiveFlag_CECS
00176   * @param  RNGx RNG Instance
00177   * @retval State of bit (1 or 0).
00178   */
00179 __STATIC_INLINE uint32_t LL_RNG_IsActiveFlag_CECS(RNG_TypeDef *RNGx)
00180 {
00181   return ((READ_BIT(RNGx->SR, RNG_SR_CECS) == (RNG_SR_CECS)) ? 1UL : 0UL);
00182 }
00183 
00184 /**
00185   * @brief  Indicate if the Seed Error Current Status Flag is set or not
00186   * @rmtoll SR           SECS          LL_RNG_IsActiveFlag_SECS
00187   * @param  RNGx RNG Instance
00188   * @retval State of bit (1 or 0).
00189   */
00190 __STATIC_INLINE uint32_t LL_RNG_IsActiveFlag_SECS(RNG_TypeDef *RNGx)
00191 {
00192   return ((READ_BIT(RNGx->SR, RNG_SR_SECS) == (RNG_SR_SECS)) ? 1UL : 0UL);
00193 }
00194 
00195 /**
00196   * @brief  Indicate if the Clock Error Interrupt Status Flag is set or not
00197   * @rmtoll SR           CEIS          LL_RNG_IsActiveFlag_CEIS
00198   * @param  RNGx RNG Instance
00199   * @retval State of bit (1 or 0).
00200   */
00201 __STATIC_INLINE uint32_t LL_RNG_IsActiveFlag_CEIS(RNG_TypeDef *RNGx)
00202 {
00203   return ((READ_BIT(RNGx->SR, RNG_SR_CEIS) == (RNG_SR_CEIS)) ? 1UL : 0UL);
00204 }
00205 
00206 /**
00207   * @brief  Indicate if the Seed Error Interrupt Status Flag is set or not
00208   * @rmtoll SR           SEIS          LL_RNG_IsActiveFlag_SEIS
00209   * @param  RNGx RNG Instance
00210   * @retval State of bit (1 or 0).
00211   */
00212 __STATIC_INLINE uint32_t LL_RNG_IsActiveFlag_SEIS(RNG_TypeDef *RNGx)
00213 {
00214   return ((READ_BIT(RNGx->SR, RNG_SR_SEIS) == (RNG_SR_SEIS)) ? 1UL : 0UL);
00215 }
00216 
00217 /**
00218   * @brief  Clear Clock Error interrupt Status (CEIS) Flag
00219   * @rmtoll SR           CEIS          LL_RNG_ClearFlag_CEIS
00220   * @param  RNGx RNG Instance
00221   * @retval None
00222   */
00223 __STATIC_INLINE void LL_RNG_ClearFlag_CEIS(RNG_TypeDef *RNGx)
00224 {
00225   WRITE_REG(RNGx->SR, ~RNG_SR_CEIS);
00226 }
00227 
00228 /**
00229   * @brief  Clear Seed Error interrupt Status (SEIS) Flag
00230   * @rmtoll SR           SEIS          LL_RNG_ClearFlag_SEIS
00231   * @param  RNGx RNG Instance
00232   * @retval None
00233   */
00234 __STATIC_INLINE void LL_RNG_ClearFlag_SEIS(RNG_TypeDef *RNGx)
00235 {
00236   WRITE_REG(RNGx->SR, ~RNG_SR_SEIS);
00237 }
00238 
00239 /**
00240   * @}
00241   */
00242 
00243 /** @defgroup RNG_LL_EF_IT_Management IT Management
00244   * @{
00245   */
00246 
00247 /**
00248   * @brief  Enable Random Number Generator Interrupt
00249   *         (applies for either Seed error, Clock Error or Data ready interrupts)
00250   * @rmtoll CR           IE            LL_RNG_EnableIT
00251   * @param  RNGx RNG Instance
00252   * @retval None
00253   */
00254 __STATIC_INLINE void LL_RNG_EnableIT(RNG_TypeDef *RNGx)
00255 {
00256   SET_BIT(RNGx->CR, RNG_CR_IE);
00257 }
00258 
00259 /**
00260   * @brief  Disable Random Number Generator Interrupt
00261   *         (applies for either Seed error, Clock Error or Data ready interrupts)
00262   * @rmtoll CR           IE            LL_RNG_DisableIT
00263   * @param  RNGx RNG Instance
00264   * @retval None
00265   */
00266 __STATIC_INLINE void LL_RNG_DisableIT(RNG_TypeDef *RNGx)
00267 {
00268   CLEAR_BIT(RNGx->CR, RNG_CR_IE);
00269 }
00270 
00271 /**
00272   * @brief  Check if Random Number Generator Interrupt is enabled
00273   *         (applies for either Seed error, Clock Error or Data ready interrupts)
00274   * @rmtoll CR           IE            LL_RNG_IsEnabledIT
00275   * @param  RNGx RNG Instance
00276   * @retval State of bit (1 or 0).
00277   */
00278 __STATIC_INLINE uint32_t LL_RNG_IsEnabledIT(RNG_TypeDef *RNGx)
00279 {
00280   return ((READ_BIT(RNGx->CR, RNG_CR_IE) == (RNG_CR_IE)) ? 1UL : 0UL);
00281 }
00282 
00283 /**
00284   * @}
00285   */
00286 
00287 /** @defgroup RNG_LL_EF_Data_Management Data Management
00288   * @{
00289   */
00290 
00291 /**
00292   * @brief  Return32-bit Random Number value
00293   * @rmtoll DR           RNDATA        LL_RNG_ReadRandData32
00294   * @param  RNGx RNG Instance
00295   * @retval Generated 32-bit random value
00296   */
00297 __STATIC_INLINE uint32_t LL_RNG_ReadRandData32(RNG_TypeDef *RNGx)
00298 {
00299   return (uint32_t)(READ_REG(RNGx->DR));
00300 }
00301 
00302 /**
00303   * @}
00304   */
00305 
00306 #if defined(USE_FULL_LL_DRIVER)
00307 /** @defgroup RNG_LL_EF_Init Initialization and de-initialization functions
00308   * @{
00309   */
00310 ErrorStatus LL_RNG_DeInit(RNG_TypeDef *RNGx);
00311 
00312 /**
00313   * @}
00314   */
00315 #endif /* USE_FULL_LL_DRIVER */
00316 
00317 /**
00318   * @}
00319   */
00320 
00321 /**
00322   * @}
00323   */
00324 
00325 #endif /* RNG */
00326 
00327 /**
00328   * @}
00329   */
00330 
00331 #ifdef __cplusplus
00332 }
00333 #endif
00334 
00335 #endif /* __STM32F4xx_LL_RNG_H */
00336 
00337 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/