You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

242 lines
7.9 KiB

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