nu_trng.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /**************************************************************************//**
  2. * @file nu_trng.h
  3. * @version V1.10
  4. * @brief TRNG driver header file
  5. *
  6. * SPDX-License-Identifier: Apache-2.0
  7. * @copyright (C) 2016-2020 Nuvoton Technology Corp. All rights reserved.
  8. ******************************************************************************/
  9. #ifndef __NU_TRNG_H__
  10. #define __NU_TRNG_H__
  11. #ifdef __cplusplus
  12. extern "C"
  13. {
  14. #endif
  15. /** @addtogroup Standard_Driver Standard Driver
  16. @{
  17. */
  18. /** @addtogroup TRNG_Driver TRNG Driver
  19. @{
  20. */
  21. /** @addtogroup M480_TRNG_EXPORTED_MACROS TRNG Exported Macros
  22. @{
  23. */
  24. /*----------------------------------------------------------------------------------------------*/
  25. /* Macros */
  26. /*----------------------------------------------------------------------------------------------*/
  27. /**
  28. * @brief Let TRNG engine know the currrent PCLK frequency. The CLKPSC is the peripheral
  29. * clock frequency range for the selected value , the CLKPSC setting must be higher
  30. * than or equal to the actual peripheral clock frequency (for correct random generation).
  31. * @param clkpsc 0: PCLK is 80~100 MHz
  32. * 1: PCLK is 60~80 MHz
  33. * 2: PCLK is 50~60 MHz
  34. * 3: PCLK is 40~50 MHz
  35. * 4: PCLK is 30~40 MHz
  36. * 5: PCLK is 25~30 MHz
  37. * 6: PCLK is 20~25 MHz
  38. * 7: PCLK is 15~20 MHz
  39. * 8: PCLK is 12~15 MHz
  40. * 9: PCLK is 9~12 MHz
  41. *
  42. * @return None
  43. * \hideinitializer
  44. */
  45. #define TRNG_SET_CLKP(clkpsc) do { TRNG->CTL = (TRNG->CTL&~TRNG_CTL_CLKP_Msk)|((clkpsc & 0xf)<<TRNG_CTL_CLKP_Pos); } while(0);
  46. /*@}*/ /* end of group M480_TRNG_EXPORTED_MACROS */
  47. /** @addtogroup TRNG_EXPORTED_FUNCTIONS TRNG Exported Functions
  48. @{
  49. */
  50. /*---------------------------------------------------------------------------------------------------------*/
  51. /* Functions */
  52. /*---------------------------------------------------------------------------------------------------------*/
  53. void TRNG_Open(void);
  54. int32_t TRNG_GenWord(uint32_t *u32RndNum);
  55. int32_t TRNG_GenBignum(uint8_t u8BigNum[], int32_t i32Len);
  56. int32_t TRNG_GenBignumHex(char cBigNumHex[], int32_t i32Len);
  57. /*@}*/ /* end of group TRNG_EXPORTED_FUNCTIONS */
  58. /*@}*/ /* end of group TRNG_Driver */
  59. /*@}*/ /* end of group Standard_Driver */
  60. #ifdef __cplusplus
  61. }
  62. #endif
  63. #endif /* __NU_TRNG_H__ */
  64. /*** (C) COPYRIGHT 2019 Nuvoton Technology Corp. ***/