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