trng_reg.h 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. /**************************************************************************//**
  2. * @file trng_reg.h
  3. * @version V1.00
  4. * @brief TRNG register definition header file
  5. *
  6. * SPDX-License-Identifier: Apache-2.0
  7. * @copyright (C) 2017-2020 Nuvoton Technology Corp. All rights reserved.
  8. *****************************************************************************/
  9. #ifndef __TRNG_REG_H__
  10. #define __TRNG_REG_H__
  11. /** @addtogroup REGISTER Control Register
  12. @{
  13. */
  14. /*---------------------- True Random Number Generator -------------------------*/
  15. /**
  16. @addtogroup TRNG True Random Number Generator(TRNG)
  17. Memory Mapped Structure for TRNG Controller
  18. @{ */
  19. typedef struct
  20. {
  21. /**
  22. * @var TRNG_T::CTL
  23. * Offset: 0x00 TRNG Control Register and Status
  24. * ---------------------------------------------------------------------------------------------------
  25. * |Bits |Field |Descriptions
  26. * | :----: | :----: | :---- |
  27. * |[0] |TRNGEN |Random Number Generator Enable Bit
  28. * | | |This bit can be set to 1 only after ACT (TRNG_ACT[7]) bit was set to 1 and READY (TRNG_CTL[7]) bit became 1.
  29. * | | |0 = TRNG disabled.
  30. * | | |1 = TRNG enabled.
  31. * | | |Note: TRNGEN is an enable bit of digital part
  32. * | | |When TRNG is not required to generate random number, TRNGEN bit and ACT (TRNG_ACT[7]) bit should be set to 0 to reduce power consumption.
  33. * |[1] |DVIF |Data Valid (Read Only)
  34. * | | |0 = Data is not valid. Reading from RNGD returns 0x00000000.
  35. * | | |1 = Data is valid. A valid random number can be read form RNGD.
  36. * | | |This bit is cleared to u20180u2019 by read TRNG_DATA.
  37. * |[5:2] |CLKP |Clock Prescaler
  38. * | | |The CLKP is the peripheral clock frequency range for the selected value , the CLKP must higher than or equal to the actual peripheral clock frequency (for correct random bit generation)
  39. * | | |To change the CLKP contents, first set TRNGEN bit to 0 and then change CLKP; finally, set TRNGEN bit to 1 to re-enable the TRNG module.
  40. * | | |0000 = 80 ~ 100 MHz.
  41. * | | |0001 = 60 ~ 80 MHz.
  42. * | | |0010 = 50 ~60 MHz.
  43. * | | |0011 = 40 ~50 MHz.
  44. * | | |0100 = 30 ~40 MHz.
  45. * | | |0101 = 25 ~30 MHz.
  46. * | | |0110 = 20 ~25 MHz.
  47. * | | |0111 = 15 ~20 MHz.
  48. * | | |1000 = 12 ~15 MHz.
  49. * | | |1001 = 9 ~12 MHz.
  50. * | | |1010 = 7 ~9 MHz.
  51. * | | |1011 = 6 ~7 MHz.
  52. * | | |1100 = 5 ~6 MHz.
  53. * | | |1101 = 4 ~5 MHz.
  54. * | | |1111 = Reserved.
  55. * |[6] |DVIEN |Data Valid Interrupt Enable Bit
  56. * | | |0 = Interrupt disabled..
  57. * | | |1 = Interrupt enabled.
  58. * |[7] |READY |Random Number Generator Ready (Read Only)
  59. * | | |After ACT (TRNG_ACT[7]) bit is set, the READY bit become to 1 after a delay of 90us~120us.
  60. * | | |0 = RNG is not ready or was not activated.
  61. * | | |1 = RNG is ready to be enabled..
  62. * |[31:8] |Reversed |Reversed
  63. * @var TRNG_T::DATA
  64. * Offset: 0x04 TRNG Data Register
  65. * ---------------------------------------------------------------------------------------------------
  66. * |Bits |Field |Descriptions
  67. * | :----: | :----: | :---- |
  68. * |[7:0] |DATA |Random Number Generator Data (Read Only)
  69. * | | |The DATA store the random number generated by TRNG and can be read only once.
  70. * @var TRNG_T::ACT
  71. * Offset: 0x0C TRNG Activation Register
  72. * ---------------------------------------------------------------------------------------------------
  73. * |Bits |Field |Descriptions
  74. * | :----: | :----: | :---- |
  75. * |[6:0] |VER |TRNG Version
  76. * | | |TRNG version number is dependent on TRNG module.
  77. * | | |0x02:(Current Version Number)
  78. * |[7] |ACT |Random Number Generator Activation
  79. * | | |After enable the ACT bit, it will active the TRNG module and wait the READY (TRNG_CTL[7]) bit to become 1.
  80. * | | |0 = TRNG inactive.
  81. * | | |1 = TRNG active.
  82. * | | |Note: ACT is an enable bit of analog part
  83. * | | |When TRNG is not required to generate random number, TRNGEN (TRNG_CTL[0]) bit and ACT bit should be set to 0 to reduce power consumption.
  84. */
  85. __IO uint32_t CTL; /*!< [0x0000] TRNG Control Register and Status */
  86. __I uint32_t DATA; /*!< [0x0004] TRNG Data Register */
  87. /// @cond HIDDEN_SYMBOLS
  88. __I uint32_t RESERVE0[1];
  89. /// @endcond //HIDDEN_SYMBOLS
  90. __IO uint32_t ACT; /*!< [0x000c] TRNG Activation Register */
  91. } TRNG_T;
  92. /**
  93. @addtogroup TRNG_CONST TRNG Bit Field Definition
  94. Constant Definitions for TRNG Controller
  95. @{ */
  96. #define TRNG_CTL_TRNGEN_Pos (0) /*!< TRNG_T::CTL: TRNGEN Position */
  97. #define TRNG_CTL_TRNGEN_Msk (0x1ul << TRNG_CTL_TRNGEN_Pos) /*!< TRNG_T::CTL: TRNGEN Mask */
  98. #define TRNG_CTL_DVIF_Pos (1) /*!< TRNG_T::CTL: DVIF Position */
  99. #define TRNG_CTL_DVIF_Msk (0x1ul << TRNG_CTL_DVIF_Pos) /*!< TRNG_T::CTL: DVIF Mask */
  100. #define TRNG_CTL_CLKP_Pos (2) /*!< TRNG_T::CTL: CLKP Position */
  101. #define TRNG_CTL_CLKP_Msk (0xful << TRNG_CTL_CLKP_Pos) /*!< TRNG_T::CTL: CLKP Mask */
  102. #define TRNG_CTL_DVIEN_Pos (6) /*!< TRNG_T::CTL: DVIEN Position */
  103. #define TRNG_CTL_DVIEN_Msk (0x1ul << TRNG_CTL_DVIEN_Pos) /*!< TRNG_T::CTL: DVIEN Mask */
  104. #define TRNG_CTL_READY_Pos (7) /*!< TRNG_T::CTL: READY Position */
  105. #define TRNG_CTL_READY_Msk (0x1ul << TRNG_CTL_READY_Pos) /*!< TRNG_T::CTL: READY Mask */
  106. #define TRNG_CTL_Reversed_Pos (8) /*!< TRNG_T::CTL: Reversed Position */
  107. #define TRNG_CTL_Reversed_Msk (0xfffffful << TRNG_CTL_Reversed_Pos) /*!< TRNG_T::CTL: Reversed Mask */
  108. #define TRNG_DATA_DATA_Pos (0) /*!< TRNG_T::DATA: DATA Position */
  109. #define TRNG_DATA_DATA_Msk (0xfful << TRNG_DATA_DATA_Pos) /*!< TRNG_T::DATA: DATA Mask */
  110. #define TRNG_ACT_VER_Pos (0) /*!< TRNG_T::ACT: VER Position */
  111. #define TRNG_ACT_VER_Msk (0x7ful << TRNG_ACT_VER_Pos) /*!< TRNG_T::ACT: VER Mask */
  112. #define TRNG_ACT_ACT_Pos (7) /*!< TRNG_T::ACT: ACT Position */
  113. #define TRNG_ACT_ACT_Msk (0x1ul << TRNG_ACT_ACT_Pos) /*!< TRNG_T::ACT: ACT Mask */
  114. /**@}*/ /* TRNG_CONST */
  115. /**@}*/ /* end of TRNG register group */
  116. /**@}*/ /* end of REGISTER group */
  117. #endif /* __TRNG_REG_H__ */