1 /** 2 ****************************************************************************** 3 * @file stm32h5xx_hal_rng_ex.h 4 * @author MCD Application Team 5 * @brief Header file of RNG HAL Extension module. 6 ****************************************************************************** 7 * @attention 8 * 9 * Copyright (c) 2022 STMicroelectronics. 10 * All rights reserved. 11 * 12 * This software is licensed under terms that can be found in the LICENSE file 13 * in the root directory of this software component. 14 * If no LICENSE file comes with this software, it is provided AS-IS. 15 * 16 ****************************************************************************** 17 */ 18 19 /* Define to prevent recursive inclusion -------------------------------------*/ 20 #ifndef STM32H5xx_HAL_RNG_EX_H 21 #define STM32H5xx_HAL_RNG_EX_H 22 23 #ifdef __cplusplus 24 extern "C" { 25 #endif 26 27 /* Includes ------------------------------------------------------------------*/ 28 #include "stm32h5xx_hal_def.h" 29 30 /** @addtogroup STM32H5xx_HAL_Driver 31 * @{ 32 */ 33 34 #if defined(RNG) 35 #if defined(RNG_CR_CONDRST) 36 37 /** @defgroup RNG_Ex RNG_Ex 38 * @brief RNG Extension HAL module driver 39 * @{ 40 */ 41 42 /* Exported types ------------------------------------------------------------*/ 43 /** @defgroup RNG_Ex_Exported_Types RNG_Ex Exported Types 44 * @brief RNG_Ex Exported types 45 * @{ 46 */ 47 48 /** 49 * @brief RNG_Ex Configuration Structure definition 50 */ 51 52 typedef struct 53 { 54 uint32_t Config1; /*!< Config1 must be a value between 0 and 0x3F */ 55 uint32_t Config2; /*!< Config2 must be a value between 0 and 0x7 */ 56 uint32_t Config3; /*!< Config3 must be a value between 0 and 0xF */ 57 uint32_t ClockDivider; /*!< Clock Divider factor.This parameter can 58 be a value of @ref RNG_Ex_Clock_Divider_Factor */ 59 uint32_t NistCompliance; /*!< NIST compliance.This parameter can be a 60 value of @ref RNG_Ex_NIST_Compliance */ 61 uint32_t AutoReset; /*!< automatic reset When a noise source error occurs 62 value of @ref RNG_Ex_Auto_Reset */ 63 uint32_t HealthTest; /*!< RNG health test control must be a value 64 between 0x0FFCABFF and 0x00005200 */ 65 } RNG_ConfigTypeDef; 66 67 /** 68 * @} 69 */ 70 71 /* Exported constants --------------------------------------------------------*/ 72 /** @defgroup RNG_Ex_Exported_Constants RNG_Ex Exported Constants 73 * @{ 74 */ 75 76 /** @defgroup RNG_Ex_Clock_Divider_Factor Value used to configure an internal 77 * programmable divider acting on the incoming RNG clock 78 * @{ 79 */ 80 #define RNG_CLKDIV_BY_1 (0x00000000UL) /*!< No clock division */ 81 #define RNG_CLKDIV_BY_2 (RNG_CR_CLKDIV_0) 82 /*!< 2 RNG clock cycles per internal RNG clock */ 83 #define RNG_CLKDIV_BY_4 (RNG_CR_CLKDIV_1) 84 /*!< 4 RNG clock cycles per internal RNG clock */ 85 #define RNG_CLKDIV_BY_8 (RNG_CR_CLKDIV_1 | RNG_CR_CLKDIV_0) 86 /*!< 8 RNG clock cycles per internal RNG clock */ 87 #define RNG_CLKDIV_BY_16 (RNG_CR_CLKDIV_2) 88 /*!< 16 RNG clock cycles per internal RNG clock */ 89 #define RNG_CLKDIV_BY_32 (RNG_CR_CLKDIV_2 | RNG_CR_CLKDIV_0) 90 /*!< 32 RNG clock cycles per internal RNG clock */ 91 #define RNG_CLKDIV_BY_64 (RNG_CR_CLKDIV_2 | RNG_CR_CLKDIV_1) 92 /*!< 64 RNG clock cycles per internal RNG clock */ 93 #define RNG_CLKDIV_BY_128 (RNG_CR_CLKDIV_2 | RNG_CR_CLKDIV_1 | RNG_CR_CLKDIV_0) 94 /*!< 128 RNG clock cycles per internal RNG clock */ 95 #define RNG_CLKDIV_BY_256 (RNG_CR_CLKDIV_3) 96 /*!< 256 RNG clock cycles per internal RNG clock */ 97 #define RNG_CLKDIV_BY_512 (RNG_CR_CLKDIV_3 | RNG_CR_CLKDIV_0) 98 /*!< 512 RNG clock cycles per internal RNG clock */ 99 #define RNG_CLKDIV_BY_1024 (RNG_CR_CLKDIV_3 | RNG_CR_CLKDIV_1) 100 /*!< 1024 RNG clock cycles per internal RNG clock */ 101 #define RNG_CLKDIV_BY_2048 (RNG_CR_CLKDIV_3 | RNG_CR_CLKDIV_1 | RNG_CR_CLKDIV_0) 102 /*!< 2048 RNG clock cycles per internal RNG clock */ 103 #define RNG_CLKDIV_BY_4096 (RNG_CR_CLKDIV_3 | RNG_CR_CLKDIV_2) 104 /*!< 4096 RNG clock cycles per internal RNG clock */ 105 #define RNG_CLKDIV_BY_8192 (RNG_CR_CLKDIV_3 | RNG_CR_CLKDIV_2 | RNG_CR_CLKDIV_0) 106 /*!< 8192 RNG clock cycles per internal RNG clock */ 107 #define RNG_CLKDIV_BY_16384 (RNG_CR_CLKDIV_3 | RNG_CR_CLKDIV_2 | RNG_CR_CLKDIV_1) 108 /*!< 16384 RNG clock cycles per internal RNG clock */ 109 #define RNG_CLKDIV_BY_32768 (RNG_CR_CLKDIV_3 | RNG_CR_CLKDIV_2 | RNG_CR_CLKDIV_1 | RNG_CR_CLKDIV_0) 110 /*!< 32768 RNG clock cycles per internal RNG clock */ 111 /** 112 * @} 113 */ 114 115 /** @defgroup RNG_Ex_NIST_Compliance NIST Compliance configuration 116 * @{ 117 */ 118 #define RNG_NIST_COMPLIANT (0x00000000UL) /*!< NIST compliant configuration*/ 119 #define RNG_CUSTOM_NIST (RNG_CR_NISTC) /*!< Custom NIST configuration */ 120 121 /** 122 * @} 123 */ 124 /** @defgroup RNG_Ex_Auto_Reset Auto Reset configuration 125 * @{ 126 */ 127 #define RNG_ARDIS_ENABLE (0x00000000UL) /*!< automatic reset after seed error*/ 128 #define RNG_ARDIS_DISABLE (RNG_CR_ARDIS) /*!< Disable automatic reset after seed error */ 129 130 /** 131 * @} 132 */ 133 134 /** 135 * @} 136 */ 137 138 /* Private types -------------------------------------------------------------*/ 139 /** @defgroup RNG_Ex_Private_Types RNG_Ex Private Types 140 * @{ 141 */ 142 143 /** 144 * @} 145 */ 146 147 /* Private variables ---------------------------------------------------------*/ 148 /** @defgroup RNG_Ex_Private_Variables RNG_Ex Private Variables 149 * @{ 150 */ 151 152 /** 153 * @} 154 */ 155 156 /* Private constants ---------------------------------------------------------*/ 157 /** @defgroup RNG_Ex_Private_Constants RNG_Ex Private Constants 158 * @{ 159 */ 160 161 /** 162 * @} 163 */ 164 165 /* Private macros ------------------------------------------------------------*/ 166 /** @defgroup RNG_Ex_Private_Macros RNG_Ex Private Macros 167 * @{ 168 */ 169 170 #define IS_RNG_CLOCK_DIVIDER(__CLOCK_DIV__) (((__CLOCK_DIV__) == RNG_CLKDIV_BY_1) || \ 171 ((__CLOCK_DIV__) == RNG_CLKDIV_BY_2) || \ 172 ((__CLOCK_DIV__) == RNG_CLKDIV_BY_4) || \ 173 ((__CLOCK_DIV__) == RNG_CLKDIV_BY_8) || \ 174 ((__CLOCK_DIV__) == RNG_CLKDIV_BY_16) || \ 175 ((__CLOCK_DIV__) == RNG_CLKDIV_BY_32) || \ 176 ((__CLOCK_DIV__) == RNG_CLKDIV_BY_64) || \ 177 ((__CLOCK_DIV__) == RNG_CLKDIV_BY_128) || \ 178 ((__CLOCK_DIV__) == RNG_CLKDIV_BY_256) || \ 179 ((__CLOCK_DIV__) == RNG_CLKDIV_BY_512) || \ 180 ((__CLOCK_DIV__) == RNG_CLKDIV_BY_1024) || \ 181 ((__CLOCK_DIV__) == RNG_CLKDIV_BY_2048) || \ 182 ((__CLOCK_DIV__) == RNG_CLKDIV_BY_4096) || \ 183 ((__CLOCK_DIV__) == RNG_CLKDIV_BY_8192) || \ 184 ((__CLOCK_DIV__) == RNG_CLKDIV_BY_16384) || \ 185 ((__CLOCK_DIV__) == RNG_CLKDIV_BY_32768)) 186 187 188 #define IS_RNG_NIST_COMPLIANCE(__NIST_COMPLIANCE__) (((__NIST_COMPLIANCE__) == RNG_NIST_COMPLIANT) || \ 189 ((__NIST_COMPLIANCE__) == RNG_CUSTOM_NIST)) 190 191 #define IS_RNG_CONFIG1(__CONFIG1__) ((__CONFIG1__) <= 0x3FUL) 192 193 #define IS_RNG_CONFIG2(__CONFIG2__) ((__CONFIG2__) <= 0x07UL) 194 195 #define IS_RNG_CONFIG3(__CONFIG3__) ((__CONFIG3__) <= 0xFUL) 196 #define IS_RNG_ARDIS(__ARDIS__) (((__ARDIS__) == RNG_ARDIS_ENABLE) || \ 197 ((__ARDIS__) == RNG_ARDIS_DISABLE)) 198 199 200 /** 201 * @} 202 */ 203 204 /* Private functions ---------------------------------------------------------*/ 205 /** @defgroup RNG_Ex_Private_Functions RNG_Ex Private Functions 206 * @{ 207 */ 208 209 /** 210 * @} 211 */ 212 213 /* Exported functions --------------------------------------------------------*/ 214 /** @defgroup RNG_Ex_Exported_Functions RNG_Ex Exported Functions 215 * @{ 216 */ 217 218 /** @addtogroup RNG_Ex_Exported_Functions_Group1 219 * @{ 220 */ 221 HAL_StatusTypeDef HAL_RNGEx_SetConfig(RNG_HandleTypeDef *hrng, RNG_ConfigTypeDef *pConf); 222 HAL_StatusTypeDef HAL_RNGEx_GetConfig(RNG_HandleTypeDef *hrng, RNG_ConfigTypeDef *pConf); 223 HAL_StatusTypeDef HAL_RNGEx_LockConfig(RNG_HandleTypeDef *hrng); 224 225 /** 226 * @} 227 */ 228 229 /** @addtogroup RNG_Ex_Exported_Functions_Group2 230 * @{ 231 */ 232 HAL_StatusTypeDef HAL_RNGEx_RecoverSeedError(RNG_HandleTypeDef *hrng); 233 234 /** 235 * @} 236 */ 237 238 /** 239 * @} 240 */ 241 242 /** 243 * @} 244 */ 245 246 /** 247 * @} 248 */ 249 250 #endif /* RNG_CR_CONDRST */ 251 #endif /* RNG */ 252 253 /** 254 * @} 255 */ 256 257 #ifdef __cplusplus 258 } 259 #endif 260 261 262 #endif /* STM32H5xx_HAL_RNG_EX_H */ 263