|
STM32G474xx HAL User Manual
|
00001 /** 00002 ****************************************************************************** 00003 * @file stm32g4xx_ll_rng.h 00004 * @author MCD Application Team 00005 * @brief Header file of RNG LL module. 00006 ****************************************************************************** 00007 * @attention 00008 * 00009 * Copyright (c) 2019 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 STM32G4xx_LL_RNG_H 00021 #define STM32G4xx_LL_RNG_H 00022 00023 #ifdef __cplusplus 00024 extern "C" { 00025 #endif 00026 00027 /* Includes ------------------------------------------------------------------*/ 00028 #include "stm32g4xx.h" 00029 00030 /** @addtogroup STM32G4xx_LL_Driver 00031 * @{ 00032 */ 00033 00034 #if defined (RNG) 00035 00036 /** @defgroup RNG_LL RNG 00037 * @{ 00038 */ 00039 00040 /* Private types -------------------------------------------------------------*/ 00041 /* Private defines -----------------------------------------------------------*/ 00042 /* Private variables ---------------------------------------------------------*/ 00043 /* Private constants ---------------------------------------------------------*/ 00044 /* Private macros ------------------------------------------------------------*/ 00045 00046 /* Exported types ------------------------------------------------------------*/ 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 This parameter can be modified using unitary 00061 functions @ref LL_RNG_EnableClkErrorDetect(). */ 00062 } LL_RNG_InitTypeDef; 00063 00064 /** 00065 * @} 00066 */ 00067 #endif /* USE_FULL_LL_DRIVER */ 00068 /* Exported constants --------------------------------------------------------*/ 00069 /** @defgroup RNG_LL_Exported_Constants RNG Exported Constants 00070 * @{ 00071 */ 00072 00073 /** @defgroup RNG_LL_CED Clock Error Detection 00074 * @{ 00075 */ 00076 #define LL_RNG_CED_ENABLE 0x00000000U /*!< Clock error detection enabled */ 00077 #define LL_RNG_CED_DISABLE RNG_CR_CED /*!< Clock error detection disabled */ 00078 /** 00079 * @} 00080 */ 00081 00082 /** @defgroup RNG_LL_EC_GET_FLAG Get Flags Defines 00083 * @brief Flags defines which can be used with LL_RNG_ReadReg function 00084 * @{ 00085 */ 00086 #define LL_RNG_SR_DRDY RNG_SR_DRDY /*!< Register contains valid random data */ 00087 #define LL_RNG_SR_CECS RNG_SR_CECS /*!< Clock error current status */ 00088 #define LL_RNG_SR_SECS RNG_SR_SECS /*!< Seed error current status */ 00089 #define LL_RNG_SR_CEIS RNG_SR_CEIS /*!< Clock error interrupt status */ 00090 #define LL_RNG_SR_SEIS RNG_SR_SEIS /*!< Seed error interrupt status */ 00091 /** 00092 * @} 00093 */ 00094 00095 /** @defgroup RNG_LL_EC_IT IT Defines 00096 * @brief IT defines which can be used with LL_RNG_ReadReg and LL_RNG_WriteReg macros 00097 * @{ 00098 */ 00099 #define LL_RNG_CR_IE RNG_CR_IE /*!< RNG Interrupt enable */ 00100 /** 00101 * @} 00102 */ 00103 00104 /** 00105 * @} 00106 */ 00107 00108 /* Exported macro ------------------------------------------------------------*/ 00109 /** @defgroup RNG_LL_Exported_Macros RNG Exported Macros 00110 * @{ 00111 */ 00112 00113 /** @defgroup RNG_LL_EM_WRITE_READ Common Write and read registers Macros 00114 * @{ 00115 */ 00116 00117 /** 00118 * @brief Write a value in RNG register 00119 * @param __INSTANCE__ RNG Instance 00120 * @param __REG__ Register to be written 00121 * @param __VALUE__ Value to be written in the register 00122 * @retval None 00123 */ 00124 #define LL_RNG_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__)) 00125 00126 /** 00127 * @brief Read a value in RNG register 00128 * @param __INSTANCE__ RNG Instance 00129 * @param __REG__ Register to be read 00130 * @retval Register value 00131 */ 00132 #define LL_RNG_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__) 00133 /** 00134 * @} 00135 */ 00136 00137 /** 00138 * @} 00139 */ 00140 00141 /* Exported functions --------------------------------------------------------*/ 00142 /** @defgroup RNG_LL_Exported_Functions RNG Exported Functions 00143 * @{ 00144 */ 00145 /** @defgroup RNG_LL_EF_Configuration RNG Configuration functions 00146 * @{ 00147 */ 00148 00149 /** 00150 * @brief Enable Random Number Generation 00151 * @rmtoll CR RNGEN LL_RNG_Enable 00152 * @param RNGx RNG Instance 00153 * @retval None 00154 */ 00155 __STATIC_INLINE void LL_RNG_Enable(RNG_TypeDef *RNGx) 00156 { 00157 SET_BIT(RNGx->CR, RNG_CR_RNGEN); 00158 } 00159 00160 /** 00161 * @brief Disable Random Number Generation 00162 * @rmtoll CR RNGEN LL_RNG_Disable 00163 * @param RNGx RNG Instance 00164 * @retval None 00165 */ 00166 __STATIC_INLINE void LL_RNG_Disable(RNG_TypeDef *RNGx) 00167 { 00168 CLEAR_BIT(RNGx->CR, RNG_CR_RNGEN); 00169 } 00170 00171 /** 00172 * @brief Check if Random Number Generator is enabled 00173 * @rmtoll CR RNGEN LL_RNG_IsEnabled 00174 * @param RNGx RNG Instance 00175 * @retval State of bit (1 or 0). 00176 */ 00177 __STATIC_INLINE uint32_t LL_RNG_IsEnabled(const RNG_TypeDef *RNGx) 00178 { 00179 return ((READ_BIT(RNGx->CR, RNG_CR_RNGEN) == (RNG_CR_RNGEN)) ? 1UL : 0UL); 00180 } 00181 00182 /** 00183 * @brief Enable Clock Error Detection 00184 * @rmtoll CR CED LL_RNG_EnableClkErrorDetect 00185 * @param RNGx RNG Instance 00186 * @retval None 00187 */ 00188 __STATIC_INLINE void LL_RNG_EnableClkErrorDetect(RNG_TypeDef *RNGx) 00189 { 00190 CLEAR_BIT(RNGx->CR, RNG_CR_CED); 00191 } 00192 00193 /** 00194 * @brief Disable RNG Clock Error Detection 00195 * @rmtoll CR CED LL_RNG_DisableClkErrorDetect 00196 * @param RNGx RNG Instance 00197 * @retval None 00198 */ 00199 __STATIC_INLINE void LL_RNG_DisableClkErrorDetect(RNG_TypeDef *RNGx) 00200 { 00201 SET_BIT(RNGx->CR, RNG_CR_CED); 00202 } 00203 00204 /** 00205 * @brief Check if RNG Clock Error Detection is enabled 00206 * @rmtoll CR CED LL_RNG_IsEnabledClkErrorDetect 00207 * @param RNGx RNG Instance 00208 * @retval State of bit (1 or 0). 00209 */ 00210 __STATIC_INLINE uint32_t LL_RNG_IsEnabledClkErrorDetect(const RNG_TypeDef *RNGx) 00211 { 00212 return ((READ_BIT(RNGx->CR, RNG_CR_CED) != (RNG_CR_CED)) ? 1UL : 0UL); 00213 } 00214 00215 /** 00216 * @} 00217 */ 00218 00219 /** @defgroup RNG_LL_EF_FLAG_Management FLAG Management 00220 * @{ 00221 */ 00222 00223