Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:23:36

0001 /**
0002   ******************************************************************************
0003   * @file    stm32h7xx_hal_rng_ex.h
0004   * @author  MCD Application Team
0005   * @brief   Header file of RNG HAL Extension module.
0006   ******************************************************************************
0007   * @attention
0008   *
0009   * Copyright (c) 2017 STMicroelectronics.
0010   * All rights reserved.
0011   *
0012   * This software is licensed under terms that can be found in the LICENSE file
0013   * in the root directory of this software component.
0014   * If no LICENSE file comes with this software, it is provided AS-IS.
0015   *
0016   ******************************************************************************
0017   */
0018 
0019 /* Define to prevent recursive inclusion -------------------------------------*/
0020 #ifndef STM32H7xx_HAL_RNG_EX_H
0021 #define STM32H7xx_HAL_RNG_EX_H
0022 
0023 #ifdef __cplusplus
0024 extern "C" {
0025 #endif
0026 
0027 /* Includes ------------------------------------------------------------------*/
0028 #include "stm32h7xx_hal_def.h"
0029 
0030 /** @addtogroup STM32H7xx_HAL_Driver
0031   * @{
0032   */
0033 
0034 #if defined(RNG)
0035 #if defined(RNG_CR_CONDRST)
0036 
0037 /** @defgroup RNG_Ex RNG_Ex
0038   * @ingroup RTEMSBSPsARMSTM32H7
0039   * @brief RNG Extension HAL module driver
0040   * @{
0041   */
0042 
0043 /* Exported types ------------------------------------------------------------*/
0044 /** @defgroup RNG_Ex_Exported_Types RNG_Ex Exported Types
0045   * @ingroup RTEMSBSPsARMSTM32H7
0046   * @brief RNG_Ex Exported types
0047   * @{
0048   */
0049 
0050 /**
0051   * @brief RNG_Ex Configuration Structure definition
0052   */
0053 
0054 typedef struct
0055 {
0056   uint32_t        Config1;           /*!< Config1 must be a value between 0 and 0x3F */
0057   uint32_t        Config2;           /*!< Config2 must be a value between 0 and 0x7 */
0058   uint32_t        Config3;           /*!< Config3 must be a value between 0 and 0xF */
0059   uint32_t        ClockDivider;      /*!< Clock Divider factor.This parameter can
0060                                           be a value of @ref RNG_Ex_Clock_Divider_Factor   */
0061   uint32_t        NistCompliance;    /*!< NIST compliance.This parameter can be a
0062                                           value of @ref RNG_Ex_NIST_Compliance   */
0063 } RNG_ConfigTypeDef;
0064 
0065 /**
0066   * @}
0067   */
0068 
0069 /* Exported constants --------------------------------------------------------*/
0070 /** @defgroup RNG_Ex_Exported_Constants RNG_Ex Exported Constants
0071   * @ingroup RTEMSBSPsARMSTM32H7
0072   * @{
0073   */
0074 
0075 /** @defgroup RNG_Ex_Clock_Divider_Factor  Value used to configure an internal
0076   * @ingroup RTEMSBSPsARMSTM32H7
0077   *            programmable divider acting on the incoming RNG clock
0078   * @{
0079   */
0080 #define RNG_CLKDIV_BY_1       (0x00000000UL)      /*!< No clock division  */
0081 #define RNG_CLKDIV_BY_2       (RNG_CR_CLKDIV_0)
0082 /*!< 2 RNG clock cycles per internal RNG clock    */
0083 #define RNG_CLKDIV_BY_4       (RNG_CR_CLKDIV_1)
0084 /*!< 4 RNG clock cycles per internal RNG clock    */
0085 #define RNG_CLKDIV_BY_8       (RNG_CR_CLKDIV_1 | RNG_CR_CLKDIV_0)
0086 /*!< 8 RNG clock cycles per internal RNG clock    */
0087 #define RNG_CLKDIV_BY_16      (RNG_CR_CLKDIV_2)
0088 /*!< 16 RNG clock cycles per internal RNG clock   */
0089 #define RNG_CLKDIV_BY_32      (RNG_CR_CLKDIV_2 | RNG_CR_CLKDIV_0)
0090 /*!< 32 RNG clock cycles per internal RNG clock   */
0091 #define RNG_CLKDIV_BY_64      (RNG_CR_CLKDIV_2 | RNG_CR_CLKDIV_1)
0092 /*!< 64 RNG clock cycles per internal RNG clock   */
0093 #define RNG_CLKDIV_BY_128     (RNG_CR_CLKDIV_2 | RNG_CR_CLKDIV_1 | RNG_CR_CLKDIV_0)
0094 /*!< 128 RNG clock cycles per internal RNG clock  */
0095 #define RNG_CLKDIV_BY_256     (RNG_CR_CLKDIV_3)
0096 /*!< 256 RNG clock cycles per internal RNG clock  */
0097 #define RNG_CLKDIV_BY_512     (RNG_CR_CLKDIV_3 | RNG_CR_CLKDIV_0)
0098 /*!< 512 RNG clock cycles per internal RNG clock  */
0099 #define RNG_CLKDIV_BY_1024    (RNG_CR_CLKDIV_3 | RNG_CR_CLKDIV_1)
0100 /*!< 1024 RNG clock cycles per internal RNG clock */
0101 #define RNG_CLKDIV_BY_2048    (RNG_CR_CLKDIV_3 | RNG_CR_CLKDIV_1 | RNG_CR_CLKDIV_0)
0102 /*!< 2048 RNG clock cycles per internal RNG clock  */
0103 #define RNG_CLKDIV_BY_4096    (RNG_CR_CLKDIV_3 | RNG_CR_CLKDIV_2)
0104 /*!< 4096 RNG clock cycles per internal RNG clock  */
0105 #define RNG_CLKDIV_BY_8192    (RNG_CR_CLKDIV_3 | RNG_CR_CLKDIV_2 | RNG_CR_CLKDIV_0)
0106 /*!< 8192 RNG clock cycles per internal RNG clock  */
0107 #define RNG_CLKDIV_BY_16384   (RNG_CR_CLKDIV_3 | RNG_CR_CLKDIV_2 | RNG_CR_CLKDIV_1)
0108 /*!< 16384 RNG clock cycles per internal RNG clock */
0109 #define RNG_CLKDIV_BY_32768   (RNG_CR_CLKDIV_3 | RNG_CR_CLKDIV_2 | RNG_CR_CLKDIV_1 | RNG_CR_CLKDIV_0)
0110 /*!< 32768 RNG clock cycles per internal RNG clock */
0111 /**
0112   * @}
0113   */
0114 
0115 /** @defgroup RNG_Ex_NIST_Compliance  NIST Compliance configuration
0116   * @ingroup RTEMSBSPsARMSTM32H7
0117   * @{
0118   */
0119 #define RNG_NIST_COMPLIANT     (0x00000000UL) /*!< NIST compliant configuration*/
0120 #define RNG_CUSTOM_NIST        (RNG_CR_NISTC) /*!< Custom NIST configuration */
0121 
0122 /**
0123   * @}
0124   */
0125 
0126 /**
0127   * @}
0128   */
0129 
0130 /* Private types -------------------------------------------------------------*/
0131 /** @defgroup RNG_Ex_Private_Types RNG_Ex Private Types
0132   * @ingroup RTEMSBSPsARMSTM32H7
0133   * @{
0134   */
0135 
0136 /**
0137   * @}
0138   */
0139 
0140 /* Private variables ---------------------------------------------------------*/
0141 /** @defgroup RNG_Ex_Private_Variables RNG_Ex Private Variables
0142   * @ingroup RTEMSBSPsARMSTM32H7
0143   * @{
0144   */
0145 
0146 /**
0147   * @}
0148   */
0149 
0150 /* Private constants ---------------------------------------------------------*/
0151 /** @defgroup RNG_Ex_Private_Constants RNG_Ex Private Constants
0152   * @ingroup RTEMSBSPsARMSTM32H7
0153   * @{
0154   */
0155 
0156 /**
0157   * @}
0158   */
0159 
0160 /* Private macros ------------------------------------------------------------*/
0161 /** @defgroup RNG_Ex_Private_Macros RNG_Ex Private Macros
0162   * @ingroup RTEMSBSPsARMSTM32H7
0163   * @{
0164   */
0165 
0166 #define IS_RNG_CLOCK_DIVIDER(__CLOCK_DIV__) (((__CLOCK_DIV__) == RNG_CLKDIV_BY_1)     || \
0167                                              ((__CLOCK_DIV__) == RNG_CLKDIV_BY_2)     || \
0168                                              ((__CLOCK_DIV__) == RNG_CLKDIV_BY_4)     || \
0169                                              ((__CLOCK_DIV__) == RNG_CLKDIV_BY_8)     || \
0170                                              ((__CLOCK_DIV__) == RNG_CLKDIV_BY_16)    || \
0171                                              ((__CLOCK_DIV__) == RNG_CLKDIV_BY_32)    || \
0172                                              ((__CLOCK_DIV__) == RNG_CLKDIV_BY_64)    || \
0173                                              ((__CLOCK_DIV__) == RNG_CLKDIV_BY_128)   || \
0174                                              ((__CLOCK_DIV__) == RNG_CLKDIV_BY_256)   || \
0175                                              ((__CLOCK_DIV__) == RNG_CLKDIV_BY_512)   || \
0176                                              ((__CLOCK_DIV__) == RNG_CLKDIV_BY_1024)  || \
0177                                              ((__CLOCK_DIV__) == RNG_CLKDIV_BY_2048)  || \
0178                                              ((__CLOCK_DIV__) == RNG_CLKDIV_BY_4096)  || \
0179                                              ((__CLOCK_DIV__) == RNG_CLKDIV_BY_8192)  || \
0180                                              ((__CLOCK_DIV__) == RNG_CLKDIV_BY_16384) || \
0181                                              ((__CLOCK_DIV__) == RNG_CLKDIV_BY_32768))
0182 
0183 
0184 #define IS_RNG_NIST_COMPLIANCE(__NIST_COMPLIANCE__) (((__NIST_COMPLIANCE__) == RNG_NIST_COMPLIANT) || \
0185                                                      ((__NIST_COMPLIANCE__) == RNG_CUSTOM_NIST))
0186 
0187 #define IS_RNG_CONFIG1(__CONFIG1__) ((__CONFIG1__) <= 0x3FUL)
0188 
0189 #define IS_RNG_CONFIG2(__CONFIG2__) ((__CONFIG2__) <= 0x07UL)
0190 
0191 #define IS_RNG_CONFIG3(__CONFIG3__) ((__CONFIG3__) <= 0xFUL)
0192 
0193 
0194 /**
0195   * @}
0196   */
0197 
0198 /* Private functions ---------------------------------------------------------*/
0199 /** @defgroup RNG_Ex_Private_Functions RNG_Ex Private Functions
0200   * @ingroup RTEMSBSPsARMSTM32H7
0201   * @{
0202   */
0203 
0204 /**
0205   * @}
0206   */
0207 
0208 /* Exported functions --------------------------------------------------------*/
0209 /** @addtogroup RNG_Ex_Exported_Functions
0210   * @ingroup RTEMSBSPsARMSTM32H7
0211   * @{
0212   */
0213 
0214 /** @addtogroup RNG_Ex_Exported_Functions_Group1
0215   * @{
0216   */
0217 HAL_StatusTypeDef HAL_RNGEx_SetConfig(RNG_HandleTypeDef *hrng, const RNG_ConfigTypeDef *pConf);
0218 HAL_StatusTypeDef HAL_RNGEx_GetConfig(RNG_HandleTypeDef *hrng, RNG_ConfigTypeDef *pConf);
0219 HAL_StatusTypeDef HAL_RNGEx_LockConfig(RNG_HandleTypeDef *hrng);
0220 
0221 /**
0222   * @}
0223   */
0224 
0225 /** @addtogroup RNG_Ex_Exported_Functions_Group2
0226   * @{
0227   */
0228 HAL_StatusTypeDef HAL_RNGEx_RecoverSeedError(RNG_HandleTypeDef *hrng);
0229 
0230 /**
0231   * @}
0232   */
0233 
0234 /**
0235   * @}
0236   */
0237 
0238 /**
0239   * @}
0240   */
0241 
0242 /**
0243   * @}
0244   */
0245 
0246 #endif /* RNG_CR_CONDRST */
0247 #endif /* RNG */
0248 
0249 /**
0250   * @}
0251   */
0252 
0253 #ifdef __cplusplus
0254 }
0255 #endif
0256 
0257 
0258 #endif /* STM32H7xx_HAL_RNG_EX_H */
0259