1 /** 2 ****************************************************************************** 3 * @file stm32l4xx_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) 2017 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 STM32L4xx_HAL_RNG_EX_H 21 #define STM32L4xx_HAL_RNG_EX_H 22 23 #ifdef __cplusplus 24 extern "C" { 25 #endif 26 27 /* Includes ------------------------------------------------------------------*/ 28 #include "stm32l4xx_hal_def.h" 29 30 /** @addtogroup STM32L4xx_HAL_Driver 31 * @{ 32 */ 33 34 #if defined (RNG) 35 36 /** @defgroup RNGEx RNGEx 37 * @brief RNG Extension HAL module driver 38 * @{ 39 */ 40 41 /* Exported types ------------------------------------------------------------*/ 42 /** @defgroup RNGEx_Exported_Types RNGEx Exported Types 43 * @brief RNGEx Exported types 44 * @{ 45 */ 46 47 /** 48 * @brief RNGEX Configuration Structure definition 49 */ 50 51 typedef struct 52 { 53 uint32_t Config1; /*!< Config1 must be a value between 0 and 0x3F */ 54 uint32_t Config2; /*!< Config2 must be a value between 0 and 0x7 */ 55 uint32_t Config3; /*!< Config3 must be a value between 0 and 0xF */ 56 uint32_t ClockDivider; /*!< Clock Divider factor.This parameter can 57 be a value of @ref RNGEX_Clock_Divider_Factor */ 58 uint32_t NistCompliance; /*!< NIST compliance.This parameter can be a 59 value of @ref RNGEX_NIST_Compliance */ 60 } RNG_ConfigTypeDef; 61 62 /** 63 * @} 64 */ 65 66 /* Exported constants --------------------------------------------------------*/ 67 /** @defgroup RNGEX_Exported_Constants RNGEX Exported Constants 68 * @{ 69 */ 70 71 /** @defgroup RNGEX_Clock_Divider_Factor Value used to configure an internal 72 * programmable divider acting on the incoming RNG clock 73 * @{ 74 */ 75 #define RNG_CLKDIV_BY_1 (0x00000000UL) /*!< No clock division */ 76 #define RNG_CLKDIV_BY_2 (RNG_CR_CLKDIV_0) 77 /*!< 2 RNG clock cycles per internal RNG clock */ 78 #define RNG_CLKDIV_BY_4 (RNG_CR_CLKDIV_1) 79 /*!< 4 RNG clock cycles per internal RNG clock */ 80 #define RNG_CLKDIV_BY_8 (RNG_CR_CLKDIV_1 | RNG_CR_CLKDIV_0) 81 /*!< 8 RNG clock cycles per internal RNG clock */ 82 #define RNG_CLKDIV_BY_16 (RNG_CR_CLKDIV_2) 83 /*!< 16 RNG clock cycles per internal RNG clock */ 84 #define RNG_CLKDIV_BY_32 (RNG_CR_CLKDIV_2 | RNG_CR_CLKDIV_0) 85 /*!< 32 RNG clock cycles per internal RNG clock */ 86 #define RNG_CLKDIV_BY_64 (RNG_CR_CLKDIV_2 | RNG_CR_CLKDIV_1) 87 /*!< 64 RNG clock cycles per internal RNG clock */ 88 #define RNG_CLKDIV_BY_128 (RNG_CR_CLKDIV_2 | RNG_CR_CLKDIV_1 | RNG_CR_CLKDIV_0) 89 /*!< 128 RNG clock cycles per internal RNG clock */ 90 #define RNG_CLKDIV_BY_256 (RNG_CR_CLKDIV_3) 91 /*!< 256 RNG clock cycles per internal RNG clock */ 92 #define RNG_CLKDIV_BY_512 (RNG_CR_CLKDIV_3 | RNG_CR_CLKDIV_0) 93 /*!< 512 RNG clock cycles per internal RNG clock */ 94 #define RNG_CLKDIV_BY_1024 (RNG_CR_CLKDIV_3 | RNG_CR_CLKDIV_1) 95 /*!< 1024 RNG clock cycles per internal RNG clock */ 96 #define RNG_CLKDIV_BY_2048 (RNG_CR_CLKDIV_3 | RNG_CR_CLKDIV_1 | RNG_CR_CLKDIV_0) 97 /*!< 2048 RNG clock cycles per internal RNG clock */ 98 #define RNG_CLKDIV_BY_4096 (RNG_CR_CLKDIV_3 | RNG_CR_CLKDIV_2) 99 /*!< 4096 RNG clock cycles per internal RNG clock */ 100 #define RNG_CLKDIV_BY_8192 (RNG_CR_CLKDIV_3 | RNG_CR_CLKDIV_2 | RNG_CR_CLKDIV_0) 101 /*!< 8192 RNG clock cycles per internal RNG clock */ 102 #define RNG_CLKDIV_BY_16384 (RNG_CR_CLKDIV_3 | RNG_CR_CLKDIV_2 | RNG_CR_CLKDIV_1) 103 /*!< 16384 RNG clock cycles per internal RNG clock */ 104 #define RNG_CLKDIV_BY_32768 (RNG_CR_CLKDIV_3 | RNG_CR_CLKDIV_2 | RNG_CR_CLKDIV_1 | RNG_CR_CLKDIV_0) 105 /*!< 32768 RNG clock cycles per internal RNG clock */ 106 /** 107 * @} 108 */ 109 110 /** @defgroup RNGEX_NIST_Compliance NIST Compliance configuration 111 * @{ 112 */ 113 #define RNG_NIST_COMPLIANT (0x00000000UL) /*!< NIST compliant configuration*/ 114 #define RNG_CUSTOM_NIST (RNG_CR_NISTC) /*!< Custom NIST configuration */ 115 116 /** 117 * @} 118 */ 119 120 /** 121 * @} 122 */ 123 124 /* Private types -------------------------------------------------------------*/ 125 /** @defgroup RNGEx_Private_Types RNGEx Private Types 126 * @{ 127 */ 128 129 /** 130 * @} 131 */ 132 133 /* Private variables ---------------------------------------------------------*/ 134 /** @defgroup RNGEx_Private_Variables RNGEx Private Variables 135 * @{ 136 */ 137 138 /** 139 * @} 140 */ 141 142 /* Private macros ------------------------------------------------------------*/ 143 /** @defgroup RNGEx_Private_Macros RNGEx Private Macros 144 * @{ 145 */ 146 147 #define IS_RNG_CLOCK_DIVIDER(__CLOCK_DIV__) (((__CLOCK_DIV__) == RNG_CLKDIV_BY_1) || \ 148 ((__CLOCK_DIV__) == RNG_CLKDIV_BY_2) || \ 149 ((__CLOCK_DIV__) == RNG_CLKDIV_BY_4) || \ 150 ((__CLOCK_DIV__) == RNG_CLKDIV_BY_8) || \ 151 ((__CLOCK_DIV__) == RNG_CLKDIV_BY_16) || \ 152 ((__CLOCK_DIV__) == RNG_CLKDIV_BY_32) || \ 153 ((__CLOCK_DIV__) == RNG_CLKDIV_BY_64) || \ 154 ((__CLOCK_DIV__) == RNG_CLKDIV_BY_128) || \ 155 ((__CLOCK_DIV__) == RNG_CLKDIV_BY_256) || \ 156 ((__CLOCK_DIV__) == RNG_CLKDIV_BY_512) || \ 157 ((__CLOCK_DIV__) == RNG_CLKDIV_BY_1024) || \ 158 ((__CLOCK_DIV__) == RNG_CLKDIV_BY_2048) || \ 159 ((__CLOCK_DIV__) == RNG_CLKDIV_BY_4096) || \ 160 ((__CLOCK_DIV__) == RNG_CLKDIV_BY_8192) || \ 161 ((__CLOCK_DIV__) == RNG_CLKDIV_BY_16384) || \ 162 ((__CLOCK_DIV__) == RNG_CLKDIV_BY_32768)) 163 164 165 #define IS_RNG_NIST_COMPLIANCE(__NIST_COMPLIANCE__) (((__NIST_COMPLIANCE__) == RNG_NIST_COMPLIANT) || \ 166 ((__NIST_COMPLIANCE__) == RNG_CUSTOM_NIST)) 167 168 #define IS_RNG_CONFIG1(__CONFIG1__) ((__CONFIG1__) <= 0x3FUL) 169 170 #define IS_RNG_CONFIG2(__CONFIG2__) ((__CONFIG2__) <= 0x07UL) 171 172 #define IS_RNG_CONFIG3(__CONFIG3__) ((__CONFIG3__) <= 0xFUL) 173 174 175 /** 176 * @} 177 */ 178 179 /* Private functions ---------------------------------------------------------*/ 180 /** @defgroup RNGEx_Private_Functions RNGEx Private Functions 181 * @{ 182 */ 183 184 /** 185 * @} 186 */ 187 188 /* Exported functions --------------------------------------------------------*/ 189 /** @defgroup RNGEx_Exported_Functions RNGEx Exported Functions 190 * @{ 191 */ 192 193 /** @addtogroup RNGEx_Exported_Functions_Group1 194 * @{ 195 */ 196 HAL_StatusTypeDef HAL_RNGEx_SetConfig(RNG_HandleTypeDef *hrng, RNG_ConfigTypeDef *pConf); 197 HAL_StatusTypeDef HAL_RNGEx_GetConfig(RNG_HandleTypeDef *hrng, RNG_ConfigTypeDef *pConf); 198 HAL_StatusTypeDef HAL_RNGEx_LockConfig(RNG_HandleTypeDef *hrng); 199 200 /** 201 * @} 202 */ 203 204 /** 205 * @} 206 */ 207 208 /** 209 * @} 210 */ 211 212 /** 213 * @} 214 */ 215 216 #endif /* RNG */ 217 218 /** 219 * @} 220 */ 221 222 #ifdef __cplusplus 223 } 224 #endif 225 226 227 #endif /* STM32L4xx_HAL_RNGEX_H */ 228