ADuCM4x50 Device Drivers API Reference Manual  Release 4.0.0.0
adi_rng.h
1 
19 #ifndef ADI_RNG_H
20 #define ADI_RNG_H
21 
22 #include <adi_processor.h>
23 #include <adi_callback.h>
24 
25 #if !defined(__ADUCM4x50__) && !defined(__ADUCM302x__)
26 #error "Unsupported processor"
27 #endif
28 
29 #include <adi_rng_config.h>
30 
31 #ifdef __ICCARM__
32 /* IAR MISRA C 2004 error suppressions.
33  *
34  * Pm011 (rule 6.3): The basic types of char, int, long, float cannot be used.
35  * bool is used in the APIs as it is not affending the rule. Disabling this as IAR treats it as an error.
36  */
37 #pragma diag_suppress=Pm011
38 #endif /* __ICCARM__ */
39 
40 #ifdef __cplusplus
41 extern "C" {
42 #endif /* __cplusplus */
43 
48 typedef enum
49 {
59 
64 typedef enum
65 {
69 
70 
72 #define ADI_RNG_MEMORY_SIZE (12u)
73 
74 
76 typedef void* ADI_RNG_HANDLE;
77 
78 /*================ E X T E R N A L S ==================*/
79 
80 /*
81  * RNG API
82  */
83 
84 /* Open a random number generator device */
86  uint32_t const nDeviceNum,
87  void* const pMemory,
88  uint32_t const MemorySize,
89  ADI_RNG_HANDLE* const phDevice
90  );
91 
92 /* Close the RNG Device */
94 
95 /* Enable/Disable the device */
97  ADI_RNG_HANDLE const hDevice,
98  bool const bFlag
99  );
100 /* Enable/Disable buffering */
102  ADI_RNG_HANDLE const hDevice,
103  bool const bFlag
104  );
105 
106 /* Set the sample length */
108  ADI_RNG_HANDLE const hDevice,
109  uint16_t const nLenPrescaler,
110  uint16_t const nLenReload
111  );
112 
113 /* Get whether the random number is ready */
115  ADI_RNG_HANDLE const hDevice,
116  bool* const pbFlag
117  );
118 
119 /* Get whether the ring oscillator output is stuck or not */
121  ADI_RNG_HANDLE const hDevice,
122  bool* const pbFlag
123  );
124 
125 /* Get the random number */
127  ADI_RNG_HANDLE const hDevice,
128  uint32_t* const pRegData
129  );
130 
131 /* Get the oscillator count */
133  ADI_RNG_HANDLE const hDevice,
134  uint32_t* const pOscCount
135  );
136 
137 /* Get the oscillator count difference value */
139  ADI_RNG_HANDLE const hDevice,
140  uint32_t const nIndex,
141  uint8_t* const pOscDiff
142  );
143 
144 /* Register a callback */
146  ADI_RNG_HANDLE hDevice,
147  ADI_CALLBACK cbFunc,
148  void *pCBParam
149  );
150 
151 /* Retrieve the current RNG sample length prescale and reload value configured in the device. */
153  ADI_RNG_HANDLE const hDevice,
154  uint16_t* const pLenPrescaler,
155  uint16_t* const pLenReload
156  );
157 
158 #ifdef __cplusplus
159 }
160 #endif
161 
162 #ifdef __ICCARM__
163 #pragma diag_default=Pm011
164 #endif /* __ICCARM__ */
165 #endif /* include guard */
166 
167 /*
168 ** EOF
169 */
170 
ADI_RNG_RESULT adi_rng_GetStuckStatus(ADI_RNG_HANDLE const hDevice, bool *const pbFlag)
Retrieve whether the RNG oscillator output is stuck at a constant value.
Definition: adi_rng.c:408
ADI_RNG_RESULT adi_rng_GetOscCount(ADI_RNG_HANDLE const hDevice, uint32_t *const pOscCount)
Retrieve the current RNG Oscillator count.
Definition: adi_rng.c:509
ADI_RNG_RESULT adi_rng_GetRngData(ADI_RNG_HANDLE const hDevice, uint32_t *const pRegData)
Retrieve the current value of the RNG data register.
Definition: adi_rng.c:464
ADI_RNG_RESULT adi_rng_GetOscDiff(ADI_RNG_HANDLE const hDevice, uint32_t const nIndex, uint8_t *const pOscDiff)
Retrieve the current RNG Oscillator difference value for the given index.
Definition: adi_rng.c:555
void * ADI_RNG_HANDLE
Definition: adi_rng.h:76
ADI_RNG_RESULT adi_rng_RegisterCallback(ADI_RNG_HANDLE hDevice, ADI_CALLBACK cbFunc, void *pCBParam)
RNG Application callback registration API.
Definition: adi_rng.c:677
ADI_RNG_EVENT
Definition: adi_rng.h:64
ADI_RNG_RESULT adi_rng_GetSampleLen(ADI_RNG_HANDLE const hDevice, uint16_t *const pLenPrescaler, uint16_t *const pLenReload)
Retrieve the current RNG sample length prescale and reload value configured in the device.
Definition: adi_rng.c:604
ADI_RNG_RESULT adi_rng_GetRdyStatus(ADI_RNG_HANDLE const hDevice, bool *const pbFlag)
Retrieves the current state of RNG data/CRC accumulator register.
Definition: adi_rng.c:359
ADI_RNG_RESULT adi_rng_EnableBuffering(ADI_RNG_HANDLE const hDevice, bool const bFlag)
Enables/Disables Buffering for RNG.
Definition: adi_rng.c:261
ADI_RNG_RESULT adi_rng_SetSampleLen(ADI_RNG_HANDLE const hDevice, uint16_t const nLenPrescaler, uint16_t const nLenReload)
Sets the reload and prescale value for the sample counter. The Sample Length will be nLenReload*2^nLe...
Definition: adi_rng.c:303
ADI_RNG_RESULT adi_rng_Open(uint32_t const nDeviceNum, void *const pMemory, uint32_t const MemorySize, ADI_RNG_HANDLE *const phDevice)
Opena a Random Number Generator Device.
Definition: adi_rng.c:107
ADI_RNG_RESULT adi_rng_Close(ADI_RNG_HANDLE hDevice)
Uninitializes and deallocates the RNG device.
Definition: adi_rng.c:183
ADI_RNG_RESULT adi_rng_Enable(ADI_RNG_HANDLE const hDevice, bool const bFlag)
Enables/Disables the RNG device.
Definition: adi_rng.c:218
ADI_RNG_RESULT
Definition: adi_rng.h:48