fsl_rng.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /*
  2. * Copyright 2017, 2019 NXP
  3. * All rights reserved.
  4. *
  5. * SPDX-License-Identifier: BSD-3-Clause
  6. */
  7. #ifndef _FSL_RNG_DRIVER_H_
  8. #define _FSL_RNG_DRIVER_H_
  9. #include "fsl_common.h"
  10. /*!
  11. * @addtogroup rng
  12. * @{
  13. */
  14. /*******************************************************************************
  15. * Definitions
  16. *******************************************************************************/
  17. /*! @name Driver version */
  18. /*@{*/
  19. /*! @brief RNG driver version. Version 2.0.1.
  20. *
  21. * Current version: 2.0.1
  22. *
  23. * Change log:
  24. * - Version 2.0.0
  25. * - Initial version
  26. *
  27. * - Version 2.0.1
  28. * - Fix MISRA C-2012 issue.
  29. */
  30. #define FSL_RNG_DRIVER_VERSION (MAKE_VERSION(2, 0, 1))
  31. /*@}*/
  32. /*******************************************************************************
  33. * API
  34. *******************************************************************************/
  35. #if defined(__cplusplus)
  36. extern "C" {
  37. #endif
  38. /*!
  39. * @brief Initializes the RNG.
  40. *
  41. * This function initializes the RNG.
  42. * When called, the RNG module and ring oscillator is enabled.
  43. *
  44. * @param base RNG base address
  45. * @return If successful, returns the kStatus_RNG_Success. Otherwise, it returns an error.
  46. */
  47. void RNG_Init(RNG_Type *base);
  48. /*!
  49. * @brief Shuts down the RNG.
  50. *
  51. * This function shuts down the RNG.
  52. *
  53. * @param base RNG base address.
  54. */
  55. void RNG_Deinit(RNG_Type *base);
  56. /*!
  57. * @brief Gets random data.
  58. *
  59. * This function gets random data from the RNG.
  60. *
  61. * @param base RNG base address.
  62. * @param data Pointer address used to store random data.
  63. * @param dataSize Size of the buffer pointed by the data parameter.
  64. * @return random data
  65. */
  66. status_t RNG_GetRandomData(RNG_Type *base, void *data, size_t dataSize);
  67. /*!
  68. * @brief Returns random 32-bit number.
  69. *
  70. * This function gets random number from the RNG.
  71. *
  72. * @param base RNG base address.
  73. * @return random number
  74. */
  75. static inline uint32_t RNG_GetRandomWord(RNG_Type *base)
  76. {
  77. return base->RANDOM_NUMBER;
  78. }
  79. #if defined(__cplusplus)
  80. }
  81. #endif
  82. /*! @}*/
  83. #endif /*_FSL_RNG_H_*/