STM32G474xx HAL User Manual
stm32g4xx_hal_rng.h
Go to the documentation of this file.
00001 /**
00002   ******************************************************************************
00003   * @file    stm32g4xx_hal_rng.h
00004   * @author  MCD Application Team
00005   * @brief   Header file of RNG HAL module.
00006   ******************************************************************************
00007   * @attention
00008   *
00009   * Copyright (c) 2019 STMicroelectronics.
00010   * All rights reserved.
00011   *
00012   * This software is licensed under terms that can be found in the LICENSE file
00013   * in the root directory of this software component.
00014   * If no LICENSE file comes with this software, it is provided AS-IS.
00015   *
00016   ******************************************************************************
00017   */
00018 
00019 /* Define to prevent recursive inclusion -------------------------------------*/
00020 #ifndef STM32G4xx_HAL_RNG_H
00021 #define STM32G4xx_HAL_RNG_H
00022 
00023 #ifdef __cplusplus
00024 extern "C" {
00025 #endif
00026 
00027 /* Includes ------------------------------------------------------------------*/
00028 #include "stm32g4xx_hal_def.h"
00029 
00030 /** @addtogroup STM32G4xx_HAL_Driver
00031   * @{
00032   */
00033 
00034 #if defined (RNG)
00035 
00036 /** @defgroup RNG RNG
00037   * @brief RNG HAL module driver
00038   * @{
00039   */
00040 
00041 /* Exported types ------------------------------------------------------------*/
00042 
00043 /** @defgroup RNG_Exported_Types RNG Exported Types
00044   * @{
00045   */
00046 
00047 /** @defgroup RNG_Exported_Types_Group1 RNG Init Structure definition
00048   * @{
00049   */
00050 typedef struct
00051 {
00052   uint32_t                    ClockErrorDetection; /*!< CED Clock error detection */
00053 } RNG_InitTypeDef;
00054 
00055 /**
00056   * @}
00057   */
00058 
00059 /** @defgroup RNG_Exported_Types_Group2 RNG State Structure definition
00060   * @{
00061   */
00062 typedef enum
00063 {
00064   HAL_RNG_STATE_RESET     = 0x00U,  /*!< RNG not yet initialized or disabled */
00065   HAL_RNG_STATE_READY     = 0x01U,  /*!< RNG initialized and ready for use   */
00066   HAL_RNG_STATE_BUSY      = 0x02U,  /*!< RNG internal process is ongoing     */
00067   HAL_RNG_STATE_TIMEOUT   = 0x03U,  /*!< RNG timeout state                   */
00068   HAL_RNG_STATE_ERROR     = 0x04U   /*!< RNG error state                     */
00069 
00070 } HAL_RNG_StateTypeDef;
00071 
00072 /**
00073   * @}
00074   */
00075 
00076 /** @defgroup RNG_Exported_Types_Group3 RNG Handle Structure definition
00077   * @{
00078   */
00079 #if (USE_HAL_RNG_REGISTER_CALLBACKS == 1)
00080 typedef struct  __RNG_HandleTypeDef
00081 #else
00082 typedef struct
00083 #endif /* USE_HAL_RNG_REGISTER_CALLBACKS */
00084 {
00085   RNG_TypeDef                 *Instance;    /*!< Register base address   */
00086 
00087   RNG_InitTypeDef             Init;         /*!< RNG configuration parameters */
00087 
00089   HAL_LockTypeDef             Lock;         /*!< RNG locking object      */
00090 
00091   __IO HAL_RNG_StateTypeDef   State;        /*!< RNG communication state */
00092 
00093   __IO  uint32_t              ErrorCode;    /*!< RNG Error code          */
00094 
00095   uint32_t                    RandomNumber; /*!< Last Generated RNG Data */
00096 
00097 #if (USE_HAL_RNG_REGISTER_CALLBACKS == 1)
00098   void (* ReadyDataCallback)(struct __RNG_HandleTypeDef *hrng, uint32_t random32bit);  /*!< RNG Data Ready Callback    */
00099   void (* ErrorCallback)(struct __RNG_HandleTypeDef *hrng);                            /*!< RNG Error Callback         */
00100 
00101   void (* MspInitCallback)(struct __RNG_HandleTypeDef *hrng);                          /*!< RNG Msp Init callback      */
00102   void (* MspDeInitCallback)(struct __RNG_HandleTypeDef *hrng);                        /*!< RNG Msp DeInit callback    */
00103 #endif  /* USE_HAL_RNG_REGISTER_CALLBACKS */
00104 
00105 } RNG_HandleTypeDef;
00106 
00107 #if (USE_HAL_RNG_REGISTER_CALLBACKS == 1)
00108 /**
00109   * @brief  HAL RNG Callback ID enumeration definition
00110   */
00111 typedef enum
00112 {
00113   HAL_RNG_ERROR_CB_ID                   = 0x00U,     /*!< RNG Error Callback ID          */
00114 
00115   HAL_RNG_MSPINIT_CB_ID                 = 0x01U,     /*!< RNG MspInit callback ID        */
00116 
00117   HAL_RNG_MSPDEINIT_CB_ID               = 0x02U      /*!< RNG MspDeInit callback ID      */
00118 
00119 } HAL_RNG_CallbackIDTypeDef;
00120 
00121 /**
00122   * @brief  HAL RNG Callback pointer definition
00123   */
00124 typedef  void (*pRNG_CallbackTypeDef)(RNG_HandleTypeDef *hrng);                                  /*!< pointer to a common RNG callback function */
00125 typedef  void (*pRNG_ReadyDataCallbackTypeDef)(RNG_HandleTypeDef *hrng, uint32_t random32bit);   /*!< pointer to an RNG Data Ready specific callback function */
00126 
00127 #endif /* USE_HAL_RNG_REGISTER_CALLBACKS */
00128 
00129 /**
00130   * @}
00131   */
00132 
00133 /**
00134   * @}
00135   */
00136 /* Exported constants --------------------------------------------------------*/
00137 /** @defgroup RNG_Exported_Constants RNG Exported Constants
00138   * @{
00139   */
00140 
00141 /** @defgroup RNG_Exported_Constants_Group1 RNG Interrupt definition
00142   * @{
00143   */
00144 #define RNG_IT_DRDY  RNG_SR_DRDY  /*!< Data Ready interrupt  */
00145 #define RNG_IT_CEI   RNG_SR_CEIS