1 /*
2  * Copyright 2018 NXP
3  * All rights reserved.
4  *
5  *
6  * SPDX-License-Identifier: BSD-3-Clause
7  */
8 
9 #ifndef _HAL_RNG_H_
10 #define _HAL_RNG_H_
11 
12 #include "fsl_common.h"
13 /*!
14  * @addtogroup RNG_Adapter
15  * @{
16  */
17 
18 /************************************************************************************
19 *************************************************************************************
20 * Include
21 *************************************************************************************
22 ***********************************************************************************/
23 
24 /************************************************************************************
25 *************************************************************************************
26 * Public types
27 *************************************************************************************
28 ************************************************************************************/
29 
30 /*! @brief Hal rand status. */
31 typedef enum _hal_rng_status
32 {
33     kStatus_HAL_RngSuccess        = kStatus_Success,                      /*!< Success */
34     KStatus_HAL_RngNotSupport     = MAKE_STATUS(kStatusGroup_HAL_RNG, 1), /*!<Not support*/
35     kStatus_HAL_RngInternalError  = MAKE_STATUS(kStatusGroup_HAL_RNG, 2), /*!<Internal Error*/
36     kStatus_HAL_RngNullPointer    = MAKE_STATUS(kStatusGroup_HAL_RNG, 3), /*!<Null pointer*/
37     kStatus_HAL_RngMaxRequests    = MAKE_STATUS(kStatusGroup_HAL_RNG, 4), /*!<Max request*/
38     kStatus_HAL_RngInvalidArgumen = MAKE_STATUS(kStatusGroup_HAL_RNG, 5), /*!<Invalid Argumen*/
39 } hal_rng_status_t;
40 /************************************************************************************
41 *************************************************************************************
42 * Public prototypes
43 *************************************************************************************
44 ************************************************************************************/
45 #if defined(__cplusplus)
46 extern "C" {
47 #endif /* _cplusplus */
48 
49 /*!
50  * @brief Initializes the random adapter module for a random data generator basic operation.
51  *
52  * @note This API should be called at the beginning of the application using the random adapter driver.
53  *
54  * @retval kStatus_HAL_RngSuccess Rand module initialize succeed
55  */
56 hal_rng_status_t HAL_RngInit(void);
57 
58 /*!
59  * @brief DeInitilizate the random adapter module.
60  *
61  * @note This API should be called when not using the rand adapter driver anymore.
62  *
63  */
64 void HAL_RngDeinit(void);
65 
66 /*!
67  * @brief Get random value from random hardware
68  *
69  * @note This API should be called to get random data.
70  *
71  * @param pRandomNo             Pointer to random data
72  * @param dataSize            The random data size
73  * @retval kStatus_HAL_RngSuccess Rand get data succeed
74  */
75 hal_rng_status_t HAL_RngHwGetData(void *pRandomNo, uint32_t dataSize);
76 
77 /*!
78  * @brief Get a pseudo random number
79  *
80  * @note This API should be called to get random data.
81  *
82  * @param pRandomNo             Pointer to random data
83  * @param dataSize            The random data size
84  * @retval kStatus_HAL_RngSuccess Rand get data succeed
85  */
86 hal_rng_status_t HAL_RngGetData(void *pRandomNo, uint32_t dataSize);
87 
88 /*!
89  * @brief Set random seed of random generator hardware
90  *
91  * @note This API should be called to set seed before get random data.
92  *
93  * @param seed             Seed of the random hardware generator
94  * @retval kStatus_HAL_RngSuccess Rand set rand seed succeed
95  * @retval KStatus_HAL_RngNotSupport Rand set rand seed not support
96  */
97 hal_rng_status_t HAL_RngSetSeed(uint32_t seed);
98 #if defined(__cplusplus)
99 }
100 #endif
101 /*! @}*/
102 #endif /* _HAL_RNG_H_ */
103