Merge pull request #11189 from klutvott123/move-telemetry-displayport-init
[betaflight.git] / lib / main / STM32G4 / Drivers / STM32G4xx_HAL_Driver / Inc / stm32g4xx_ll_rng.h
blob0a5f636dd789f6eff46a116cbb290a5371c35d44
1 /**
2 ******************************************************************************
3 * @file stm32g4xx_ll_rng.h
4 * @author MCD Application Team
5 * @brief Header file of RNG LL module.
6 ******************************************************************************
7 * @attention
9 * <h2><center>&copy; Copyright (c) 2018 STMicroelectronics.
10 * All rights reserved.</center></h2>
12 * This software component is licensed by ST under BSD 3-Clause license,
13 * the "License"; You may not use this file except in compliance with the
14 * License. You may obtain a copy of the License at:
15 * opensource.org/licenses/BSD-3-Clause
17 ******************************************************************************
20 /* Define to prevent recursive inclusion -------------------------------------*/
21 #ifndef STM32G4xx_LL_RNG_H
22 #define STM32G4xx_LL_RNG_H
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
28 /* Includes ------------------------------------------------------------------*/
29 #include "stm32g4xx.h"
31 /** @addtogroup STM32G4xx_LL_Driver
32 * @{
35 #if defined (RNG)
37 /** @defgroup RNG_LL RNG
38 * @{
41 /* Private types -------------------------------------------------------------*/
42 /* Private variables ---------------------------------------------------------*/
43 /* Private constants ---------------------------------------------------------*/
44 /* Private macros ------------------------------------------------------------*/
46 /* Exported types ------------------------------------------------------------*/
47 #if defined(USE_FULL_LL_DRIVER)
48 /** @defgroup RNG_LL_ES_Init_Struct RNG Exported Init structures
49 * @{
53 /**
54 * @brief LL RNG Init Structure Definition
56 typedef struct
58 uint32_t ClockErrorDetection; /*!< Clock error detection.
59 This parameter can be one value of @ref RNG_LL_CED.
61 This parameter can be modified using unitary functions @ref LL_RNG_EnableClkErrorDetect(). */
62 } LL_RNG_InitTypeDef;
64 /**
65 * @}
67 #endif /* USE_FULL_LL_DRIVER */
68 /* Exported constants --------------------------------------------------------*/
69 /** @defgroup RNG_LL_Exported_Constants RNG Exported Constants
70 * @{
73 /** @defgroup RNG_LL_CED Clock Error Detection
74 * @{
76 #define LL_RNG_CED_ENABLE 0x00000000U /*!< Clock error detection enabled */
77 #define LL_RNG_CED_DISABLE RNG_CR_CED /*!< Clock error detection disabled */
78 /**
79 * @}
82 /** @defgroup RNG_LL_EC_GET_FLAG Get Flags Defines
83 * @brief Flags defines which can be used with LL_RNG_ReadReg function
84 * @{
86 #define LL_RNG_SR_DRDY RNG_SR_DRDY /*!< Register contains valid random data */
87 #define LL_RNG_SR_CECS RNG_SR_CECS /*!< Clock error current status */
88 #define LL_RNG_SR_SECS RNG_SR_SECS /*!< Seed error current status */
89 #define LL_RNG_SR_CEIS RNG_SR_CEIS /*!< Clock error interrupt status */
90 #define LL_RNG_SR_SEIS RNG_SR_SEIS /*!< Seed error interrupt status */
91 /**
92 * @}
95 /** @defgroup RNG_LL_EC_IT IT Defines
96 * @brief IT defines which can be used with LL_RNG_ReadReg and LL_RNG_WriteReg macros
97 * @{
99 #define LL_RNG_CR_IE RNG_CR_IE /*!< RNG Interrupt enable */
101 * @}
105 * @}
108 /* Exported macro ------------------------------------------------------------*/
109 /** @defgroup RNG_LL_Exported_Macros RNG Exported Macros
110 * @{
113 /** @defgroup RNG_LL_EM_WRITE_READ Common Write and read registers Macros
114 * @{
118 * @brief Write a value in RNG register
119 * @param __INSTANCE__ RNG Instance
120 * @param __REG__ Register to be written
121 * @param __VALUE__ Value to be written in the register
122 * @retval None
124 #define LL_RNG_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
127 * @brief Read a value in RNG register
128 * @param __INSTANCE__ RNG Instance
129 * @param __REG__ Register to be read
130 * @retval Register value
132 #define LL_RNG_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
134 * @}
138 * @}
142 /* Exported functions --------------------------------------------------------*/
143 /** @defgroup RNG_LL_Exported_Functions RNG Exported Functions
144 * @{
146 /** @defgroup RNG_LL_EF_Configuration RNG Configuration functions
147 * @{
151 * @brief Enable Random Number Generation
152 * @rmtoll CR RNGEN LL_RNG_Enable
153 * @param RNGx RNG Instance
154 * @retval None
156 __STATIC_INLINE void LL_RNG_Enable(RNG_TypeDef *RNGx)
158 SET_BIT(RNGx->CR, RNG_CR_RNGEN);
162 * @brief Disable Random Number Generation
163 * @rmtoll CR RNGEN LL_RNG_Disable
164 * @param RNGx RNG Instance
165 * @retval None
167 __STATIC_INLINE void LL_RNG_Disable(RNG_TypeDef *RNGx)
169 CLEAR_BIT(RNGx->CR, RNG_CR_RNGEN);
173 * @brief Check if Random Number Generator is enabled
174 * @rmtoll CR RNGEN LL_RNG_IsEnabled
175 * @param RNGx RNG Instance
176 * @retval State of bit (1 or 0).
178 __STATIC_INLINE uint32_t LL_RNG_IsEnabled(RNG_TypeDef *RNGx)
180 return ((READ_BIT(RNGx->CR, RNG_CR_RNGEN) == (RNG_CR_RNGEN)) ? 1UL : 0UL);
184 * @brief Enable Clock Error Detection
185 * @rmtoll CR CED LL_RNG_EnableClkErrorDetect
186 * @param RNGx RNG Instance
187 * @retval None
189 __STATIC_INLINE void LL_RNG_EnableClkErrorDetect(RNG_TypeDef *RNGx)
191 CLEAR_BIT(RNGx->CR, RNG_CR_CED);
195 * @brief Disable RNG Clock Error Detection
196 * @rmtoll CR CED LL_RNG_DisableClkErrorDetect
197 * @param RNGx RNG Instance
198 * @retval None
200 __STATIC_INLINE void LL_RNG_DisableClkErrorDetect(RNG_TypeDef *RNGx)
202 SET_BIT(RNGx->CR, RNG_CR_CED);
206 * @brief Check if RNG Clock Error Detection is enabled
207 * @rmtoll CR CED LL_RNG_IsEnabledClkErrorDetect
208 * @param RNGx RNG Instance
209 * @retval State of bit (1 or 0).
211 __STATIC_INLINE uint32_t LL_RNG_IsEnabledClkErrorDetect(RNG_TypeDef *RNGx)
213 return ((READ_BIT(RNGx->CR, RNG_CR_CED) != (RNG_CR_CED)) ? 1UL : 0UL);
217 * @}
220 /** @defgroup RNG_LL_EF_FLAG_Management FLAG Management
221 * @{
225 * @brief Indicate if the RNG Data ready Flag is set or not
226 * @rmtoll SR DRDY LL_RNG_IsActiveFlag_DRDY
227 * @param RNGx RNG Instance
228 * @retval State of bit (1 or 0).
230 __STATIC_INLINE uint32_t LL_RNG_IsActiveFlag_DRDY(RNG_TypeDef *RNGx)
232 return ((READ_BIT(RNGx->SR, RNG_SR_DRDY) == (RNG_SR_DRDY)) ? 1UL : 0UL);
236 * @brief Indicate if the Clock Error Current Status Flag is set or not
237 * @rmtoll SR CECS LL_RNG_IsActiveFlag_CECS
238 * @param RNGx RNG Instance
239 * @retval State of bit (1 or 0).
241 __STATIC_INLINE uint32_t LL_RNG_IsActiveFlag_CECS(RNG_TypeDef *RNGx)
243 return ((READ_BIT(RNGx->SR, RNG_SR_CECS) == (RNG_SR_CECS)) ? 1UL : 0UL);
247 * @brief Indicate if the Seed Error Current Status Flag is set or not
248 * @rmtoll SR SECS LL_RNG_IsActiveFlag_SECS
249 * @param RNGx RNG Instance
250 * @retval State of bit (1 or 0).
252 __STATIC_INLINE uint32_t LL_RNG_IsActiveFlag_SECS(RNG_TypeDef *RNGx)
254 return ((READ_BIT(RNGx->SR, RNG_SR_SECS) == (RNG_SR_SECS)) ? 1UL : 0UL);
258 * @brief Indicate if the Clock Error Interrupt Status Flag is set or not
259 * @rmtoll SR CEIS LL_RNG_IsActiveFlag_CEIS
260 * @param RNGx RNG Instance
261 * @retval State of bit (1 or 0).
263 __STATIC_INLINE uint32_t LL_RNG_IsActiveFlag_CEIS(RNG_TypeDef *RNGx)
265 return ((READ_BIT(RNGx->SR, RNG_SR_CEIS) == (RNG_SR_CEIS)) ? 1UL : 0UL);
269 * @brief Indicate if the Seed Error Interrupt Status Flag is set or not
270 * @rmtoll SR SEIS LL_RNG_IsActiveFlag_SEIS
271 * @param RNGx RNG Instance
272 * @retval State of bit (1 or 0).
274 __STATIC_INLINE uint32_t LL_RNG_IsActiveFlag_SEIS(RNG_TypeDef *RNGx)
276 return ((READ_BIT(RNGx->SR, RNG_SR_SEIS) == (RNG_SR_SEIS)) ? 1UL : 0UL);
280 * @brief Clear Clock Error interrupt Status (CEIS) Flag
281 * @rmtoll SR CEIS LL_RNG_ClearFlag_CEIS
282 * @param RNGx RNG Instance
283 * @retval None
285 __STATIC_INLINE void LL_RNG_ClearFlag_CEIS(RNG_TypeDef *RNGx)
287 WRITE_REG(RNGx->SR, ~RNG_SR_CEIS);
291 * @brief Clear Seed Error interrupt Status (SEIS) Flag
292 * @rmtoll SR SEIS LL_RNG_ClearFlag_SEIS
293 * @param RNGx RNG Instance
294 * @retval None
296 __STATIC_INLINE void LL_RNG_ClearFlag_SEIS(RNG_TypeDef *RNGx)
298 WRITE_REG(RNGx->SR, ~RNG_SR_SEIS);
302 * @}
305 /** @defgroup RNG_LL_EF_IT_Management IT Management
306 * @{
310 * @brief Enable Random Number Generator Interrupt
311 * (applies for either Seed error, Clock Error or Data ready interrupts)
312 * @rmtoll CR IE LL_RNG_EnableIT
313 * @param RNGx RNG Instance
314 * @retval None
316 __STATIC_INLINE void LL_RNG_EnableIT(RNG_TypeDef *RNGx)
318 SET_BIT(RNGx->CR, RNG_CR_IE);
322 * @brief Disable Random Number Generator Interrupt
323 * (applies for either Seed error, Clock Error or Data ready interrupts)
324 * @rmtoll CR IE LL_RNG_DisableIT
325 * @param RNGx RNG Instance
326 * @retval None
328 __STATIC_INLINE void LL_RNG_DisableIT(RNG_TypeDef *RNGx)
330 CLEAR_BIT(RNGx->CR, RNG_CR_IE);
334 * @brief Check if Random Number Generator Interrupt is enabled
335 * (applies for either Seed error, Clock Error or Data ready interrupts)
336 * @rmtoll CR IE LL_RNG_IsEnabledIT
337 * @param RNGx RNG Instance
338 * @retval State of bit (1 or 0).
340 __STATIC_INLINE uint32_t LL_RNG_IsEnabledIT(RNG_TypeDef *RNGx)
342 return ((READ_BIT(RNGx->CR, RNG_CR_IE) == (RNG_CR_IE)) ? 1UL : 0UL);
346 * @}
349 /** @defgroup RNG_LL_EF_Data_Management Data Management
350 * @{
354 * @brief Return32-bit Random Number value
355 * @rmtoll DR RNDATA LL_RNG_ReadRandData32
356 * @param RNGx RNG Instance
357 * @retval Generated 32-bit random value
359 __STATIC_INLINE uint32_t LL_RNG_ReadRandData32(RNG_TypeDef *RNGx)
361 return (uint32_t)(READ_REG(RNGx->DR));
365 * @}
368 #if defined(USE_FULL_LL_DRIVER)
369 /** @defgroup RNG_LL_EF_Init Initialization and de-initialization functions
370 * @{
372 ErrorStatus LL_RNG_Init(RNG_TypeDef *RNGx, LL_RNG_InitTypeDef *RNG_InitStruct);
373 void LL_RNG_StructInit(LL_RNG_InitTypeDef *RNG_InitStruct);
374 ErrorStatus LL_RNG_DeInit(RNG_TypeDef *RNGx);
377 * @}
379 #endif /* USE_FULL_LL_DRIVER */
382 * @}
386 * @}
389 #endif /* RNG */
392 * @}
395 #ifdef __cplusplus
397 #endif
399 #endif /* __STM32G4xx_LL_RNG_H */
401 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/