RTEMS 6.1-rc4
Loading...
Searching...
No Matches
stm32h7xx_hal_rng.h
Go to the documentation of this file.
1
19/* Define to prevent recursive inclusion -------------------------------------*/
20#ifndef STM32H7xx_HAL_RNG_H
21#define STM32H7xx_HAL_RNG_H
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
27/* Includes ------------------------------------------------------------------*/
28#include "stm32h7xx_hal_def.h"
29
34#if defined (RNG)
35
42/* Exported types ------------------------------------------------------------*/
43
53typedef struct
54{
55 uint32_t ClockErrorDetection;
56} RNG_InitTypeDef;
57
66typedef enum
67{
68 HAL_RNG_STATE_RESET = 0x00U,
69 HAL_RNG_STATE_READY = 0x01U,
70 HAL_RNG_STATE_BUSY = 0x02U,
71 HAL_RNG_STATE_TIMEOUT = 0x03U,
72 HAL_RNG_STATE_ERROR = 0x04U
74} HAL_RNG_StateTypeDef;
75
84#if (USE_HAL_RNG_REGISTER_CALLBACKS == 1)
85typedef struct __RNG_HandleTypeDef
86#else
87typedef struct
88#endif /* USE_HAL_RNG_REGISTER_CALLBACKS */
89{
90 RNG_TypeDef *Instance;
92 RNG_InitTypeDef Init;
94 HAL_LockTypeDef Lock;
96 __IO HAL_RNG_StateTypeDef State;
98 __IO uint32_t ErrorCode;
100 uint32_t RandomNumber;
102#if (USE_HAL_RNG_REGISTER_CALLBACKS == 1)
103 void (* ReadyDataCallback)(struct __RNG_HandleTypeDef *hrng, uint32_t random32bit);
104 void (* ErrorCallback)(struct __RNG_HandleTypeDef *hrng);
106 void (* MspInitCallback)(struct __RNG_HandleTypeDef *hrng);
107 void (* MspDeInitCallback)(struct __RNG_HandleTypeDef *hrng);
108#endif /* USE_HAL_RNG_REGISTER_CALLBACKS */
109
110} RNG_HandleTypeDef;
111
112#if (USE_HAL_RNG_REGISTER_CALLBACKS == 1)
116typedef enum
117{
118 HAL_RNG_ERROR_CB_ID = 0x00U,
120 HAL_RNG_MSPINIT_CB_ID = 0x01U,
121 HAL_RNG_MSPDEINIT_CB_ID = 0x02U
123} HAL_RNG_CallbackIDTypeDef;
124
128typedef void (*pRNG_CallbackTypeDef)(RNG_HandleTypeDef *hrng);
129typedef void (*pRNG_ReadyDataCallbackTypeDef)(RNG_HandleTypeDef *hrng, uint32_t random32bit);
131#endif /* USE_HAL_RNG_REGISTER_CALLBACKS */
132
141/* Exported constants --------------------------------------------------------*/
151#define RNG_IT_DRDY RNG_SR_DRDY
152#define RNG_IT_CEI RNG_SR_CEIS
153#define RNG_IT_SEI RNG_SR_SEIS
162#define RNG_FLAG_DRDY RNG_SR_DRDY
163#define RNG_FLAG_CECS RNG_SR_CECS
164#define RNG_FLAG_SECS RNG_SR_SECS
173#define RNG_CED_ENABLE 0x00000000U
174#define RNG_CED_DISABLE RNG_CR_CED
183#define HAL_RNG_ERROR_NONE 0x00000000U
184#if (USE_HAL_RNG_REGISTER_CALLBACKS == 1)
185#define HAL_RNG_ERROR_INVALID_CALLBACK 0x00000001U
186#endif /* USE_HAL_RNG_REGISTER_CALLBACKS */
187#define HAL_RNG_ERROR_TIMEOUT 0x00000002U
188#define HAL_RNG_ERROR_BUSY 0x00000004U
189#define HAL_RNG_ERROR_SEED 0x00000008U
190#define HAL_RNG_ERROR_CLOCK 0x00000010U
199/* Exported macros -----------------------------------------------------------*/
209#if (USE_HAL_RNG_REGISTER_CALLBACKS == 1)
210#define __HAL_RNG_RESET_HANDLE_STATE(__HANDLE__) do{ \
211 (__HANDLE__)->State = HAL_RNG_STATE_RESET; \
212 (__HANDLE__)->MspInitCallback = NULL; \
213 (__HANDLE__)->MspDeInitCallback = NULL; \
214 } while(0U)
215#else
216#define __HAL_RNG_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_RNG_STATE_RESET)
217#endif /* USE_HAL_RNG_REGISTER_CALLBACKS */
218
224#define __HAL_RNG_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= RNG_CR_RNGEN)
225
231#define __HAL_RNG_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~RNG_CR_RNGEN)
232
243#define __HAL_RNG_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->SR & (__FLAG__)) == (__FLAG__))
244
253#define __HAL_RNG_CLEAR_FLAG(__HANDLE__, __FLAG__) /* dummy macro */
254
260#define __HAL_RNG_ENABLE_IT(__HANDLE__) ((__HANDLE__)->Instance->CR |= RNG_CR_IE)
261
267#define __HAL_RNG_DISABLE_IT(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~RNG_CR_IE)
268
279#define __HAL_RNG_GET_IT(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->SR & (__INTERRUPT__)) == (__INTERRUPT__))
280
291#define __HAL_RNG_CLEAR_IT(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->SR) = ~(__INTERRUPT__))
292
297#if defined (RNG_CR_CONDRST)
298/* Include RNG HAL Extended module */
299#include "stm32h7xx_hal_rng_ex.h"
300#endif /* RNG_CR_CONDRST */
301/* Exported functions --------------------------------------------------------*/
311HAL_StatusTypeDef HAL_RNG_Init(RNG_HandleTypeDef *hrng);
312HAL_StatusTypeDef HAL_RNG_DeInit(RNG_HandleTypeDef *hrng);
313void HAL_RNG_MspInit(RNG_HandleTypeDef *hrng);
314void HAL_RNG_MspDeInit(RNG_HandleTypeDef *hrng);
315
316/* Callbacks Register/UnRegister functions ***********************************/
317#if (USE_HAL_RNG_REGISTER_CALLBACKS == 1)
318HAL_StatusTypeDef HAL_RNG_RegisterCallback(RNG_HandleTypeDef *hrng, HAL_RNG_CallbackIDTypeDef CallbackID,
319 pRNG_CallbackTypeDef pCallback);
320HAL_StatusTypeDef HAL_RNG_UnRegisterCallback(RNG_HandleTypeDef *hrng, HAL_RNG_CallbackIDTypeDef CallbackID);
321
322HAL_StatusTypeDef HAL_RNG_RegisterReadyDataCallback(RNG_HandleTypeDef *hrng, pRNG_ReadyDataCallbackTypeDef pCallback);
323HAL_StatusTypeDef HAL_RNG_UnRegisterReadyDataCallback(RNG_HandleTypeDef *hrng);
324#endif /* USE_HAL_RNG_REGISTER_CALLBACKS */
325
334HAL_StatusTypeDef HAL_RNG_GenerateRandomNumber(RNG_HandleTypeDef *hrng, uint32_t *random32bit);
335HAL_StatusTypeDef HAL_RNG_GenerateRandomNumber_IT(RNG_HandleTypeDef *hrng);
336uint32_t HAL_RNG_ReadLastRandomNumber(const RNG_HandleTypeDef *hrng);
337
338void HAL_RNG_IRQHandler(RNG_HandleTypeDef *hrng);
339void HAL_RNG_ErrorCallback(RNG_HandleTypeDef *hrng);
340void HAL_RNG_ReadyDataCallback(RNG_HandleTypeDef *hrng, uint32_t random32bit);
341
350HAL_RNG_StateTypeDef HAL_RNG_GetState(const RNG_HandleTypeDef *hrng);
351uint32_t HAL_RNG_GetError(const RNG_HandleTypeDef *hrng);
360/* Private macros ------------------------------------------------------------*/
365#define IS_RNG_IT(IT) (((IT) == RNG_IT_CEI) || \
366 ((IT) == RNG_IT_SEI))
367
368#define IS_RNG_FLAG(FLAG) (((FLAG) == RNG_FLAG_DRDY) || \
369 ((FLAG) == RNG_FLAG_CECS) || \
370 ((FLAG) == RNG_FLAG_SECS))
371
377#define IS_RNG_CED(__MODE__) (((__MODE__) == RNG_CED_ENABLE) || \
378 ((__MODE__) == RNG_CED_DISABLE))
383#if defined(RNG_CR_CONDRST)
384/* Private functions ---------------------------------------------------------*/
389HAL_StatusTypeDef RNG_RecoverSeedError(RNG_HandleTypeDef *hrng);
393#endif /* RNG_CR_CONDRST */
398#endif /* RNG */
399
404#ifdef __cplusplus
405}
406#endif
407
408
409#endif /* STM32H7xx_HAL_RNG_H */
410
#define __IO
Definition: core_cm4.h:239
This file contains HAL common defines, enumeration, macros and structures definitions.
HAL_StatusTypeDef
HAL Status structures definition.
Definition: stm32h7xx_hal_def.h:47
HAL_LockTypeDef
HAL Lock structures definition.
Definition: stm32h7xx_hal_def.h:58
Header file of RNG HAL Extension module.
RNG.
Definition: stm32h723xx.h:1668