STM32F439xx HAL User Manual
|
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>© COPYRIGHT(c) 2017 STMicroelectronics</center></h2> 00010 * 00011 * Redistribution and use in source and binary forms, with or without modification, 00012 * are permitted provided that the following conditions are met: 00013 * 1. Redistributions of source code must retain the above copyright notice, 00014 * this list of conditions and the following disclaimer. 00015 * 2. Redistributions in binary form must reproduce the above copyright notice, 00016 * this list of conditions and the following disclaimer in the documentation 00017 * and/or other materials provided with the distribution. 00018 * 3. Neither the name of STMicroelectronics nor the names of its contributors 00019 * may be used to endorse or promote products derived from this software 00020 * without specific prior written permission. 00021 * 00022 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00023 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00024 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00025 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 00026 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00027 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 00028 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00029 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00030 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00031 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00032 * 00033 ****************************************************************************** 00034 */ 00035 00036 /* Define to prevent recursive inclusion -------------------------------------*/ 00037 #ifndef __STM32F4xx_LL_RNG_H 00038 #define __STM32F4xx_LL_RNG_H 00039 00040 #ifdef __cplusplus 00041 extern "C" { 00042 #endif 00043 00044 /* Includes ------------------------------------------------------------------*/ 00045 #include "stm32f4xx.h" 00046 00047 /** @addtogroup STM32F4xx_LL_Driver 00048 * @{ 00049 */ 00050 00051 #if defined(RNG) 00052 00053 /** @defgroup RNG_LL RNG 00054 * @{ 00055 */ 00056 00057 /* Private types -------------------------------------------------------------*/ 00058 /* Private variables ---------------------------------------------------------*/ 00059 /* Private constants ---------------------------------------------------------*/ 00060 /* Private macros ------------------------------------------------------------*/ 00061 00062 /* Exported types ------------------------------------------------------------*/ 00063 /* Exported constants --------------------------------------------------------*/ 00064 /** @defgroup RNG_LL_Exported_Constants RNG Exported Constants 00065 * @{ 00066 */ 00067 00068 /** @defgroup RNG_LL_EC_GET_FLAG Get Flags Defines 00069 * @brief Flags defines which can be used with LL_RNG_ReadReg function 00070 * @{ 00071 */ 00072 #define LL_RNG_SR_DRDY RNG_SR_DRDY /*!< Register contains valid random data */ 00073 #define LL_RNG_SR_CECS RNG_SR_CECS /*!< Clock error current status */ 00074 #define LL_RNG_SR_SECS RNG_SR_SECS /*!< Seed error current status */ 00075 #define LL_RNG_SR_CEIS RNG_SR_CEIS /*!< Clock error interrupt status */ 00076 #define LL_RNG_SR_SEIS RNG_SR_SEIS /*!< Seed error interrupt status */ 00077 /** 00078 * @} 00079 */ 00080 00081 /** @defgroup RNG_LL_EC_IT IT Defines 00082 * @brief IT defines which can be used with LL_RNG_ReadReg and LL_RNG_WriteReg macros 00083 * @{ 00084 */ 00085 #define LL_RNG_CR_IE RNG_CR_IE /*!< RNG Interrupt enable */ 00086 /** 00087 * @} 00088 */ 00089 00090 /** 00091 * @} 00092 */ 00093 00094 /* Exported macro ------------------------------------------------------------*/ 00095 /** @defgroup RNG_LL_Exported_Macros RNG Exported Macros 00096 * @{ 00097 */ 00098 00099 /** @defgroup RNG_LL_EM_WRITE_READ Common Write and read registers Macros 00100 * @{ 00101 */ 00102 00103 /** 00104 * @brief Write a value in RNG register 00105 * @param __INSTANCE__ RNG Instance 00106 * @param __REG__ Register to be written 00107 * @param __VALUE__ Value to be written in the register 00108 * @retval None 00109 */ 00110 #define LL_RNG_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__)) 00111 00112 /** 00113 * @brief Read a value in RNG register 00114 * @param __INSTANCE__ RNG Instance 00115 * @param __REG__ Register to be read 00116 * @retval Register value 00117 */ 00118 #define LL_RNG_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__) 00119 /** 00120 * @} 00121 */ 00122 00123 /** 00124 * @} 00125 */ 00126 00127 00128 /* Exported functions --------------------------------------------------------*/ 00129 /** @defgroup RNG_LL_Exported_Functions RNG Exported Functions 00130 * @{ 00131 */ 00132 /** @defgroup RNG_LL_EF_Configuration RNG Configuration functions 00133 * @{ 00134 */ 00135 00136 /** 00137 * @brief Enable Random Number Generation 00138 * @rmtoll CR RNGEN LL_RNG_Enable 00139 * @param RNGx RNG Instance 00140 * @retval None 00141 */ 00142 __STATIC_INLINE void LL_RNG_Enable(RNG_TypeDef *RNGx) 00143 { 00144 SET_BIT(RNGx->CR, RNG_CR_RNGEN); 00145 } 00146 00147 /** 00148 * @brief Disable Random Number Generation 00149 * @rmtoll CR RNGEN LL_RNG_Disable 00150 * @param RNGx RNG Instance 00151 * @retval None 00152 */ 00153 __STATIC_INLINE void LL_RNG_Disable(RNG_TypeDef *RNGx) 00154 { 00155 CLEAR_BIT(RNGx->CR, RNG_CR_RNGEN); 00156 } 00157 00158 /** 00159 * @brief Check if Random Number Generator is enabled 00160 * @rmtoll CR RNGEN LL_RNG_IsEnabled 00161 * @param RNGx RNG Instance 00162 * @retval State of bit (1 or 0). 00163 */ 00164 __STATIC_INLINE uint32_t LL_RNG_IsEnabled(RNG_TypeDef *RNGx) 00165 { 00166 return (READ_BIT(RNGx->CR, RNG_CR_RNGEN) == (RNG_CR_RNGEN)); 00167 } 00168 00169 /** 00170 * @} 00171 */ 00172 00173 /** @defgroup RNG_LL_EF_FLAG_Management FLAG Management 00174 * @{ 00175 */ 00176 00177 /** 00178 * @brief Indicate if the RNG Data ready Flag is set or not 00179 * @rmtoll SR DRDY LL_RNG_IsActiveFlag_DRDY 00180 * @param RNGx RNG Instance 00181 * @retval State of bit (1 or 0). 00182 */ 00183 __STATIC_INLINE uint32_t LL_RNG_IsActiveFlag_DRDY(RNG_TypeDef *RNGx) 00184 { 00185 return (READ_BIT(RNGx->SR, RNG_SR_DRDY) == (RNG_SR_DRDY)); 00186 } 00187 00188 /** 00189 * @brief Indicate if the Clock Error Current Status Flag is set or not 00190 * @rmtoll SR CECS LL_RNG_IsActiveFlag_CECS 00191 * @param RNGx RNG Instance 00192 * @retval State of bit (1 or 0). 00193 */ 00194 __STATIC_INLINE uint32_t LL_RNG_IsActiveFlag_CECS(RNG_TypeDef *RNGx) 00195 { 00196 return (READ_BIT(RNGx->SR, RNG_SR_CECS) == (RNG_SR_CECS)); 00197 } 00198 00199 /** 00200 * @brief Indicate if the Seed Error Current Status Flag is set or not 00201 * @rmtoll SR SECS LL_RNG_IsActiveFlag_SECS 00202 * @param RNGx RNG Instance 00203 * @retval State of bit (1 or 0). 00204 */ 00205 __STATIC_INLINE uint32_t LL_RNG_IsActiveFlag_SECS(RNG_TypeDef *RNGx) 00206 { 00207 return (READ_BIT(RNGx->SR, RNG_SR_SECS) == (RNG_SR_SECS)); 00208 } 00209 00210 /** 00211 * @brief Indicate if the Clock Error Interrupt Status Flag is set or not 00212 * @rmtoll SR CEIS LL_RNG_IsActiveFlag_CEIS 00213 * @param RNGx RNG Instance 00214 * @retval State of bit (1 or 0). 00215 */ 00216 __STATIC_INLINE uint32_t LL_RNG_IsActiveFlag_CEIS(RNG_TypeDef *RNGx) 00217 { 00218 return (READ_BIT(RNGx->SR, RNG_SR_CEIS) == (RNG_SR_CEIS)); 00219 } 00220 00221 /** 00222 * @brief Indicate if the Seed Error Interrupt Status Flag is set or not 00223 * @rmtoll SR SEIS LL_RNG_IsActiveFlag_SEIS 00224 * @param RNGx RNG Instance 00225 * @retval State of bit (1 or 0). 00226 */ 00227 __STATIC_INLINE uint32_t LL_RNG_IsActiveFlag_SEIS(RNG_TypeDef *RNGx) 00228 { 00229 return (READ_BIT(RNGx->SR, RNG_SR_SEIS) == (RNG_SR_SEIS)); 00230 } 00231 00232 /** 00233 * @brief Clear Clock Error interrupt Status (CEIS) Flag 00234 * @rmtoll SR CEIS LL_RNG_ClearFlag_CEIS 00235 * @param RNGx RNG Instance 00236 * @retval None 00237 */ 00238 __STATIC_INLINE void LL_RNG_ClearFlag_CEIS(RNG_TypeDef *RNGx) 00239 { 00240 WRITE_REG(RNGx->SR, ~RNG_SR_CEIS); 00241 } 00242 00243 /** 00244 * @brief Clear Seed Error interrupt Status (SEIS) Flag 00245 * @rmtoll SR SEIS LL_RNG_ClearFlag_SEIS 00246 * @param RNGx RNG Instance 00247 * @retval None 00248 */ 00249 __STATIC_INLINE void LL_RNG_ClearFlag_SEIS(RNG_TypeDef *RNGx) 00250 { 00251 WRITE_REG(RNGx->SR, ~RNG_SR_SEIS); 00252 } 00253 00254 /** 00255 * @} 00256 */ 00257 00258 /** @defgroup RNG_LL_EF_IT_Management IT Management 00259 * @{ 00260 */ 00261 00262 /** 00263 * @brief Enable Random Number Generator Interrupt 00264 * (applies for either Seed error, Clock Error or Data ready interrupts) 00265 * @rmtoll CR IE LL_RNG_EnableIT 00266 * @param RNGx RNG Instance 00267 * @retval None 00268 */ 00269 __STATIC_INLINE void LL_RNG_EnableIT(RNG_TypeDef *RNGx) 00270 { 00271 SET_BIT(RNGx->CR, RNG_CR_IE); 00272 } 00273 00274 /** 00275 * @brief Disable Random Number Generator Interrupt 00276 * (applies for either Seed error, Clock Error or Data ready interrupts) 00277 * @rmtoll CR IE LL_RNG_DisableIT 00278 * @param RNGx RNG Instance 00279 * @retval None 00280 */ 00281 __STATIC_INLINE void LL_RNG_DisableIT(RNG_TypeDef *RNGx) 00282 { 00283 CLEAR_BIT(RNGx->CR, RNG_CR_IE); 00284 } 00285 00286 /** 00287 * @brief Check if Random Number Generator Interrupt is enabled 00288 * (applies for either Seed error, Clock Error or Data ready interrupts) 00289 * @rmtoll CR IE LL_RNG_IsEnabledIT 00290 * @param RNGx RNG Instance 00291 * @retval State of bit (1 or 0). 00292 */ 00293 __STATIC_INLINE uint32_t LL_RNG_IsEnabledIT(RNG_TypeDef *RNGx) 00294 { 00295 return (READ_BIT(RNGx->CR, RNG_CR_IE) == (RNG_CR_IE)); 00296 } 00297 00298 /** 00299 * @} 00300 */ 00301 00302 /** @defgroup RNG_LL_EF_Data_Management Data Management 00303 * @{ 00304 */ 00305 00306 /** 00307 * @brief Return32-bit Random Number value 00308 * @rmtoll DR RNDATA LL_RNG_ReadRandData32 00309 * @param RNGx RNG Instance 00310 * @retval Generated 32-bit random value 00311 */ 00312 __STATIC_INLINE uint32_t LL_RNG_ReadRandData32(RNG_TypeDef *RNGx) 00313 { 00314 return (uint32_t)(READ_REG(RNGx->DR)); 00315 } 00316 00317 /** 00318 * @} 00319 */ 00320 00321 #if defined(USE_FULL_LL_DRIVER) 00322 /** @defgroup RNG_LL_EF_Init Initialization and de-initialization functions 00323 * @{ 00324 */ 00325 00326 ErrorStatus LL_RNG_DeInit(RNG_TypeDef *RNGx); 00327 00328 /** 00329 * @} 00330 */ 00331 #endif /* USE_FULL_LL_DRIVER */ 00332 00333 /** 00334 * @} 00335 */ 00336 00337 /** 00338 * @} 00339 */ 00340 00341 #endif /* defined(RNG) */ 00342 00343 /** 00344 * @} 00345 */ 00346 00347 #ifdef __cplusplus 00348 } 00349 #endif 00350 00351 #endif /* __STM32F4xx_LL_RNG_H */ 00352 00353 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/