2 ******************************************************************************
3 * @file stm32f4xx_ll_rng.h
4 * @author MCD Application Team
7 * @brief Header file of RNG LL module.
8 ******************************************************************************
11 * <h2><center>© COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
13 * Redistribution and use in source and binary forms, with or without modification,
14 * are permitted provided that the following conditions are met:
15 * 1. Redistributions of source code must retain the above copyright notice,
16 * this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright notice,
18 * this list of conditions and the following disclaimer in the documentation
19 * and/or other materials provided with the distribution.
20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 ******************************************************************************
38 /* Define to prevent recursive inclusion -------------------------------------*/
39 #ifndef __STM32F4xx_LL_RNG_H
40 #define __STM32F4xx_LL_RNG_H
46 /* Includes ------------------------------------------------------------------*/
47 #include "stm32f4xx.h"
49 /** @addtogroup STM32F4xx_LL_Driver
55 /** @defgroup RNG_LL RNG
59 /* Private types -------------------------------------------------------------*/
60 /* Private variables ---------------------------------------------------------*/
61 /* Private constants ---------------------------------------------------------*/
62 /* Private macros ------------------------------------------------------------*/
64 /* Exported types ------------------------------------------------------------*/
65 /* Exported constants --------------------------------------------------------*/
66 /** @defgroup RNG_LL_Exported_Constants RNG Exported Constants
70 /** @defgroup RNG_LL_EC_GET_FLAG Get Flags Defines
71 * @brief Flags defines which can be used with LL_RNG_ReadReg function
74 #define LL_RNG_SR_DRDY RNG_SR_DRDY /*!< Register contains valid random data */
75 #define LL_RNG_SR_CECS RNG_SR_CECS /*!< Clock error current status */
76 #define LL_RNG_SR_SECS RNG_SR_SECS /*!< Seed error current status */
77 #define LL_RNG_SR_CEIS RNG_SR_CEIS /*!< Clock error interrupt status */
78 #define LL_RNG_SR_SEIS RNG_SR_SEIS /*!< Seed error interrupt status */
83 /** @defgroup RNG_LL_EC_IT IT Defines
84 * @brief IT defines which can be used with LL_RNG_ReadReg and LL_RNG_WriteReg macros
87 #define LL_RNG_CR_IE RNG_CR_IE /*!< RNG Interrupt enable */
96 /* Exported macro ------------------------------------------------------------*/
97 /** @defgroup RNG_LL_Exported_Macros RNG Exported Macros
101 /** @defgroup RNG_LL_EM_WRITE_READ Common Write and read registers Macros
106 * @brief Write a value in RNG register
107 * @param __INSTANCE__ RNG Instance
108 * @param __REG__ Register to be written
109 * @param __VALUE__ Value to be written in the register
112 #define LL_RNG_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
115 * @brief Read a value in RNG register
116 * @param __INSTANCE__ RNG Instance
117 * @param __REG__ Register to be read
118 * @retval Register value
120 #define LL_RNG_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
130 /* Exported functions --------------------------------------------------------*/
131 /** @defgroup RNG_LL_Exported_Functions RNG Exported Functions
134 /** @defgroup RNG_LL_EF_Configuration RNG Configuration functions
139 * @brief Enable Random Number Generation
140 * @rmtoll CR RNGEN LL_RNG_Enable
141 * @param RNGx RNG Instance
144 __STATIC_INLINE
void LL_RNG_Enable(RNG_TypeDef
*RNGx
)
146 SET_BIT(RNGx
->CR
, RNG_CR_RNGEN
);
150 * @brief Disable Random Number Generation
151 * @rmtoll CR RNGEN LL_RNG_Disable
152 * @param RNGx RNG Instance
155 __STATIC_INLINE
void LL_RNG_Disable(RNG_TypeDef
*RNGx
)
157 CLEAR_BIT(RNGx
->CR
, RNG_CR_RNGEN
);
161 * @brief Check if Random Number Generator is enabled
162 * @rmtoll CR RNGEN LL_RNG_IsEnabled
163 * @param RNGx RNG Instance
164 * @retval State of bit (1 or 0).
166 __STATIC_INLINE
uint32_t LL_RNG_IsEnabled(RNG_TypeDef
*RNGx
)
168 return (READ_BIT(RNGx
->CR
, RNG_CR_RNGEN
) == (RNG_CR_RNGEN
));
175 /** @defgroup RNG_LL_EF_FLAG_Management FLAG Management
180 * @brief Indicate if the RNG Data ready Flag is set or not
181 * @rmtoll SR DRDY LL_RNG_IsActiveFlag_DRDY
182 * @param RNGx RNG Instance
183 * @retval State of bit (1 or 0).
185 __STATIC_INLINE
uint32_t LL_RNG_IsActiveFlag_DRDY(RNG_TypeDef
*RNGx
)
187 return (READ_BIT(RNGx
->SR
, RNG_SR_DRDY
) == (RNG_SR_DRDY
));
191 * @brief Indicate if the Clock Error Current Status Flag is set or not
192 * @rmtoll SR CECS LL_RNG_IsActiveFlag_CECS
193 * @param RNGx RNG Instance
194 * @retval State of bit (1 or 0).
196 __STATIC_INLINE
uint32_t LL_RNG_IsActiveFlag_CECS(RNG_TypeDef
*RNGx
)
198 return (READ_BIT(RNGx
->SR
, RNG_SR_CECS
) == (RNG_SR_CECS
));
202 * @brief Indicate if the Seed Error Current Status Flag is set or not
203 * @rmtoll SR SECS LL_RNG_IsActiveFlag_SECS
204 * @param RNGx RNG Instance
205 * @retval State of bit (1 or 0).
207 __STATIC_INLINE
uint32_t LL_RNG_IsActiveFlag_SECS(RNG_TypeDef
*RNGx
)
209 return (READ_BIT(RNGx
->SR
, RNG_SR_SECS
) == (RNG_SR_SECS
));
213 * @brief Indicate if the Clock Error Interrupt Status Flag is set or not
214 * @rmtoll SR CEIS LL_RNG_IsActiveFlag_CEIS
215 * @param RNGx RNG Instance
216 * @retval State of bit (1 or 0).
218 __STATIC_INLINE
uint32_t LL_RNG_IsActiveFlag_CEIS(RNG_TypeDef
*RNGx
)
220 return (READ_BIT(RNGx
->SR
, RNG_SR_CEIS
) == (RNG_SR_CEIS
));
224 * @brief Indicate if the Seed Error Interrupt Status Flag is set or not
225 * @rmtoll SR SEIS LL_RNG_IsActiveFlag_SEIS
226 * @param RNGx RNG Instance
227 * @retval State of bit (1 or 0).
229 __STATIC_INLINE
uint32_t LL_RNG_IsActiveFlag_SEIS(RNG_TypeDef
*RNGx
)
231 return (READ_BIT(RNGx
->SR
, RNG_SR_SEIS
) == (RNG_SR_SEIS
));
235 * @brief Clear Clock Error interrupt Status (CEIS) Flag
236 * @rmtoll SR CEIS LL_RNG_ClearFlag_CEIS
237 * @param RNGx RNG Instance
240 __STATIC_INLINE
void LL_RNG_ClearFlag_CEIS(RNG_TypeDef
*RNGx
)
242 WRITE_REG(RNGx
->SR
, ~RNG_SR_CEIS
);
246 * @brief Clear Seed Error interrupt Status (SEIS) Flag
247 * @rmtoll SR SEIS LL_RNG_ClearFlag_SEIS
248 * @param RNGx RNG Instance
251 __STATIC_INLINE
void LL_RNG_ClearFlag_SEIS(RNG_TypeDef
*RNGx
)
253 WRITE_REG(RNGx
->SR
, ~RNG_SR_SEIS
);
260 /** @defgroup RNG_LL_EF_IT_Management IT Management
265 * @brief Enable Random Number Generator Interrupt
266 * (applies for either Seed error, Clock Error or Data ready interrupts)
267 * @rmtoll CR IE LL_RNG_EnableIT
268 * @param RNGx RNG Instance
271 __STATIC_INLINE
void LL_RNG_EnableIT(RNG_TypeDef
*RNGx
)
273 SET_BIT(RNGx
->CR
, RNG_CR_IE
);
277 * @brief Disable Random Number Generator Interrupt
278 * (applies for either Seed error, Clock Error or Data ready interrupts)
279 * @rmtoll CR IE LL_RNG_DisableIT
280 * @param RNGx RNG Instance
283 __STATIC_INLINE
void LL_RNG_DisableIT(RNG_TypeDef
*RNGx
)
285 CLEAR_BIT(RNGx
->CR
, RNG_CR_IE
);
289 * @brief Check if Random Number Generator Interrupt is enabled
290 * (applies for either Seed error, Clock Error or Data ready interrupts)
291 * @rmtoll CR IE LL_RNG_IsEnabledIT
292 * @param RNGx RNG Instance
293 * @retval State of bit (1 or 0).
295 __STATIC_INLINE
uint32_t LL_RNG_IsEnabledIT(RNG_TypeDef
*RNGx
)
297 return (READ_BIT(RNGx
->CR
, RNG_CR_IE
) == (RNG_CR_IE
));
304 /** @defgroup RNG_LL_EF_Data_Management Data Management
309 * @brief Return32-bit Random Number value
310 * @rmtoll DR RNDATA LL_RNG_ReadRandData32
311 * @param RNGx RNG Instance
312 * @retval Generated 32-bit random value
314 __STATIC_INLINE
uint32_t LL_RNG_ReadRandData32(RNG_TypeDef
*RNGx
)
316 return (uint32_t)(READ_REG(RNGx
->DR
));
323 #if defined(USE_FULL_LL_DRIVER)
324 /** @defgroup RNG_LL_EF_Init Initialization and de-initialization functions
328 ErrorStatus
LL_RNG_DeInit(RNG_TypeDef
*RNGx
);
333 #endif /* USE_FULL_LL_DRIVER */
343 #endif /* defined(RNG) */
353 #endif /* __STM32F4xx_LL_RNG_H */
355 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/