STM CMSIS
stm32f4xx_hal_rng.h
Go to the documentation of this file.
1 
38 /* Define to prevent recursive inclusion -------------------------------------*/
39 #ifndef __STM32F4xx_HAL_RNG_H
40 #define __STM32F4xx_HAL_RNG_H
41 
42 #ifdef __cplusplus
43  extern "C" {
44 #endif
45 
46 #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) ||\
47  defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) ||\
48  defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx) || defined(STM32F469xx) ||\
49  defined(STM32F479xx) || defined(STM32F412Zx) || defined(STM32F412Vx) || defined(STM32F412Rx) ||\
50  defined(STM32F412Cx)
51 
52 /* Includes ------------------------------------------------------------------*/
53 #include "stm32f4xx_hal_def.h"
54 
64 /* Exported types ------------------------------------------------------------*/
65 
73 typedef enum
74 {
75  HAL_RNG_STATE_RESET = 0x00U,
76  HAL_RNG_STATE_READY = 0x01U,
77  HAL_RNG_STATE_BUSY = 0x02U,
78  HAL_RNG_STATE_TIMEOUT = 0x03U,
79  HAL_RNG_STATE_ERROR = 0x04U
81 }HAL_RNG_StateTypeDef;
82 
90 typedef struct
91 {
92  RNG_TypeDef *Instance;
94  HAL_LockTypeDef Lock;
96  __IO HAL_RNG_StateTypeDef State;
98  uint32_t RandomNumber;
100 }RNG_HandleTypeDef;
101 
110 /* Exported constants --------------------------------------------------------*/
111 
119 #define RNG_IT_DRDY RNG_SR_DRDY
120 #define RNG_IT_CEI RNG_SR_CEIS
121 #define RNG_IT_SEI RNG_SR_SEIS
129 #define RNG_FLAG_DRDY RNG_SR_DRDY
130 #define RNG_FLAG_CECS RNG_SR_CECS
131 #define RNG_FLAG_SECS RNG_SR_SECS
141 /* Exported macros -----------------------------------------------------------*/
142 
151 #define __HAL_RNG_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_RNG_STATE_RESET)
152 
158 #define __HAL_RNG_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= RNG_CR_RNGEN)
159 
165 #define __HAL_RNG_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~RNG_CR_RNGEN)
166 
177 #define __HAL_RNG_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->SR & (__FLAG__)) == (__FLAG__))
178 
187 #define __HAL_RNG_CLEAR_FLAG(__HANDLE__, __FLAG__) /* dummy macro */
188 
189 
190 
196 #define __HAL_RNG_ENABLE_IT(__HANDLE__) ((__HANDLE__)->Instance->CR |= RNG_CR_IE)
197 
203 #define __HAL_RNG_DISABLE_IT(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~RNG_CR_IE)
204 
215 #define __HAL_RNG_GET_IT(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->SR & (__INTERRUPT__)) == (__INTERRUPT__))
216 
227 #define __HAL_RNG_CLEAR_IT(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->SR) = ~(__INTERRUPT__))
228 
233 /* Exported functions --------------------------------------------------------*/
241 HAL_StatusTypeDef HAL_RNG_Init(RNG_HandleTypeDef *hrng);
242 HAL_StatusTypeDef HAL_RNG_DeInit (RNG_HandleTypeDef *hrng);
243 void HAL_RNG_MspInit(RNG_HandleTypeDef *hrng);
244 void HAL_RNG_MspDeInit(RNG_HandleTypeDef *hrng);
245 
253 uint32_t HAL_RNG_GetRandomNumber(RNG_HandleTypeDef *hrng); /* Obsolete, use HAL_RNG_GenerateRandomNumber() instead */
254 uint32_t HAL_RNG_GetRandomNumber_IT(RNG_HandleTypeDef *hrng); /* Obsolete, use HAL_RNG_GenerateRandomNumber_IT() instead */
255 
256 HAL_StatusTypeDef HAL_RNG_GenerateRandomNumber(RNG_HandleTypeDef *hrng, uint32_t *random32bit);
257 HAL_StatusTypeDef HAL_RNG_GenerateRandomNumber_IT(RNG_HandleTypeDef *hrng);
258 uint32_t HAL_RNG_ReadLastRandomNumber(RNG_HandleTypeDef *hrng);
259 
260 void HAL_RNG_IRQHandler(RNG_HandleTypeDef *hrng);
261 void HAL_RNG_ErrorCallback(RNG_HandleTypeDef *hrng);
262 void HAL_RNG_ReadyDataCallback(RNG_HandleTypeDef* hrng, uint32_t random32bit);
263 
271 HAL_RNG_StateTypeDef HAL_RNG_GetState(RNG_HandleTypeDef *hrng);
272 
281 /* Private types -------------------------------------------------------------*/
290 /* Private defines -----------------------------------------------------------*/
299 /* Private variables ---------------------------------------------------------*/
308 /* Private constants ---------------------------------------------------------*/
317 /* Private macros ------------------------------------------------------------*/
321 #define IS_RNG_IT(IT) (((IT) == RNG_IT_CEI) || \
322  ((IT) == RNG_IT_SEI))
323 
324 #define IS_RNG_FLAG(FLAG) (((FLAG) == RNG_FLAG_DRDY) || \
325  ((FLAG) == RNG_FLAG_CECS) || \
326  ((FLAG) == RNG_FLAG_SECS))
327 
332 /* Private functions prototypes ----------------------------------------------*/
341 /* Private functions ---------------------------------------------------------*/
358 #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F427xx || STM32F437xx ||\
359  STM32F429xx || STM32F439xx || STM32F410xx || STM32F469xx || STM32F479xx || STM32F412Zx ||\
360  STM32F412Vx || STM32F412Rx || STM32F412Cx */
361 
362 #ifdef __cplusplus
363 }
364 #endif
365 
366 
367 #endif /* __STM32F4xx_HAL_RNG_H */
368 
369 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
This file contains HAL common defines, enumeration, macros and structures definitions.
HAL_StatusTypeDef
HAL Status structures definition.
Definition: stm32f4xx_hal_def.h:57
#define __IO
Definition: core_cm0.h:213
HAL_LockTypeDef
HAL Lock structures definition.
Definition: stm32f4xx_hal_def.h:68
RNG.
Definition: stm32f405xx.h:708