hc32_ll_trng.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. /**
  2. *******************************************************************************
  3. * @file hc32_ll_trng.h
  4. * @brief This file contains all the functions prototypes of the TRNG driver
  5. * library.
  6. @verbatim
  7. Change Logs:
  8. Date Author Notes
  9. 2022-12-31 CDT First version
  10. @endverbatim
  11. *******************************************************************************
  12. * Copyright (C) 2022, Xiaohua Semiconductor Co., Ltd. All rights reserved.
  13. *
  14. * This software component is licensed by XHSC under BSD 3-Clause license
  15. * (the "License"); You may not use this file except in compliance with the
  16. * License. You may obtain a copy of the License at:
  17. * opensource.org/licenses/BSD-3-Clause
  18. *
  19. *******************************************************************************
  20. */
  21. #ifndef __HC32_LL_TRNG_H__
  22. #define __HC32_LL_TRNG_H__
  23. /* C binding of definitions if building with C++ compiler */
  24. #ifdef __cplusplus
  25. extern "C"
  26. {
  27. #endif
  28. /*******************************************************************************
  29. * Include files
  30. ******************************************************************************/
  31. #include "hc32_ll_def.h"
  32. #include "hc32f4xx_conf.h"
  33. /**
  34. * @addtogroup LL_Driver
  35. * @{
  36. */
  37. /**
  38. * @addtogroup LL_TRNG
  39. * @{
  40. */
  41. #if (LL_TRNG_ENABLE == DDL_ON)
  42. /*******************************************************************************
  43. * Global type definitions ('typedef')
  44. ******************************************************************************/
  45. /*******************************************************************************
  46. * Global pre-processor symbols/macros ('#define')
  47. ******************************************************************************/
  48. /**
  49. * @defgroup TRNG_Global_Macros TRNG Global Macros
  50. * @{
  51. */
  52. /**
  53. * @defgroup TRNG_Reload_Init_Value TRNG Reload Initial Value
  54. * @{
  55. */
  56. #define TRNG_RELOAD_INIT_VAL_ENABLE (TRNG_MR_LOAD) /* Enable reload new initial value. */
  57. #define TRNG_RELOAD_INIT_VAL_DISABLE (0x0U) /* Disable reload new initial value. */
  58. /**
  59. * @}
  60. */
  61. /**
  62. * @defgroup TRNG_Shift_Ctrl TRNG Shift Control
  63. * @{
  64. */
  65. #define TRNG_SHIFT_CNT32 (0x3UL << TRNG_MR_CNT_POS) /* Shift 32 times when capturing random noise. */
  66. #define TRNG_SHIFT_CNT64 (0x4UL << TRNG_MR_CNT_POS) /* Shift 64 times when capturing random noise. */
  67. #define TRNG_SHIFT_CNT128 (0x5UL << TRNG_MR_CNT_POS) /* Shift 128 times when capturing random noise. */
  68. #define TRNG_SHIFT_CNT256 (0x6UL << TRNG_MR_CNT_POS) /* Shift 256 times when capturing random noise. */
  69. /**
  70. * @}
  71. */
  72. /**
  73. * @}
  74. */
  75. /*******************************************************************************
  76. * Global variable definitions ('extern')
  77. ******************************************************************************/
  78. /*******************************************************************************
  79. Global function prototypes (definition in C source)
  80. ******************************************************************************/
  81. /**
  82. * @addtogroup TRNG_Global_Functions
  83. * @{
  84. */
  85. void TRNG_Init(uint32_t u32ShiftCount, uint32_t u32ReloadInitValueEn);
  86. /* For polling mode. */
  87. int32_t TRNG_GenerateRandom(uint32_t *pu32Random, uint8_t u8RandomLen);
  88. /* For interrupt mode. */
  89. void TRNG_Start(void);
  90. int32_t TRNG_GetRandom(uint32_t *pu32Random, uint8_t u8RandomLen);
  91. /**
  92. * @}
  93. */
  94. #endif /* LL_TRNG_ENABLE */
  95. /**
  96. * @}
  97. */
  98. /**
  99. * @}
  100. */
  101. #ifdef __cplusplus
  102. }
  103. #endif
  104. #endif /* __HC32_LL_TRNG_H__ */
  105. /*******************************************************************************
  106. * EOF (not truncated)
  107. ******************************************************************************/