stm32l4xx_hal_rng_ex.h 7.9 KB

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