ADuCM302x Device Drivers API Reference Manual  Release 3.1.2.0
adi_rng.h
1 
51 #ifndef ADI_RNG_H
52 #define ADI_RNG_H
53 
54 #include <adi_processor.h>
55 #include <adi_callback.h>
56 
57 #if !defined(__ADUCM4x50__) && !defined(__ADUCM302x__)
58 #error "Unsupported processor"
59 #endif
60 
61 #include <adi_rng_config.h>
62 
63 #ifdef __ICCARM__
64 /* IAR MISRA C 2004 error suppressions.
65  *
66  * Pm011 (rule 6.3): The basic types of char, int, long, float cannot be used.
67  * bool is used in the APIs as it is not affending the rule. Disabling this as IAR treats it as an error.
68  */
69 #pragma diag_suppress=Pm011
70 #endif /* __ICCARM__ */
71 
72 #ifdef __cplusplus
73 extern "C" {
74 #endif /* __cplusplus */
75 
80 typedef enum
81 {
91 
96 typedef enum
97 {
100 } ADI_RNG_EVENT;
101 
102 
104 #define ADI_RNG_MEMORY_SIZE (12u)
105 
106 
108 typedef void* ADI_RNG_HANDLE;
109 
110 /*================ E X T E R N A L S ==================*/
111 
112 /*
113  * RNG API
114  */
115 
116 /* Open a random number generator device */
117 extern ADI_RNG_RESULT adi_rng_Open(
118  uint32_t const nDeviceNum,
119  void* const pMemory,
120  uint32_t const MemorySize,
121  ADI_RNG_HANDLE* const phDevice
122  );
123 
124 /* Close the RNG Device */
125 extern ADI_RNG_RESULT adi_rng_Close(ADI_RNG_HANDLE hDevice);
126 
127 /* Enable/Disable the device */
128 extern ADI_RNG_RESULT adi_rng_Enable (
129  ADI_RNG_HANDLE const hDevice,
130  bool const bFlag
131  );
132 /* Enable/Disable buffering */
133 extern ADI_RNG_RESULT adi_rng_EnableBuffering (
134  ADI_RNG_HANDLE const hDevice,
135  bool const bFlag
136  );
137 
138 /* Set the sample length */
139 extern ADI_RNG_RESULT adi_rng_SetSampleLen (
140  ADI_RNG_HANDLE const hDevice,
141  uint16_t const nLenPrescaler,
142  uint16_t const nLenReload
143  );
144 
145 /* Get whether the random number is ready */
146 extern ADI_RNG_RESULT adi_rng_GetRdyStatus (
147  ADI_RNG_HANDLE const hDevice,
148  bool* const pbFlag
149  );
150 
151 /* Get whether the ring oscillator output is stuck or not */
152 extern ADI_RNG_RESULT adi_rng_GetStuckStatus (
153  ADI_RNG_HANDLE const hDevice,
154  bool* const pbFlag
155  );
156 
157 /* Get the random number */
158 extern ADI_RNG_RESULT adi_rng_GetRngData (
159  ADI_RNG_HANDLE const hDevice,
160  uint32_t* const pRegData
161  );
162 
163 /* Get the oscillator count */
164 extern ADI_RNG_RESULT adi_rng_GetOscCount (
165  ADI_RNG_HANDLE const hDevice,
166  uint32_t* const pOscCount
167  );
168 
169 /* Get the oscillator count difference value */
170 extern ADI_RNG_RESULT adi_rng_GetOscDiff (
171  ADI_RNG_HANDLE const hDevice,
172  uint32_t const nIndex,
173  uint8_t* const pOscDiff
174  );
175 
176 /* Register a callback */
177 extern ADI_RNG_RESULT adi_rng_RegisterCallback (
178  ADI_RNG_HANDLE hDevice,
179  ADI_CALLBACK cbFunc,
180  void *pCBParam
181  );
182 
183 /* Retrieve the current RNG sample length prescale and reload value configured in the device. */
184 extern ADI_RNG_RESULT adi_rng_GetSampleLen (
185  ADI_RNG_HANDLE const hDevice,
186  uint16_t* const pLenPrescaler,
187  uint16_t* const pLenReload
188  );
189 
190 #ifdef __cplusplus
191 }
192 #endif
193 
194 #ifdef __ICCARM__
195 #pragma diag_default=Pm011
196 #endif /* __ICCARM__ */
197 #endif /* include guard */
198 
199 /*
200 ** EOF
201 */
202 
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:441
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:542
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:497
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:588
void * ADI_RNG_HANDLE
Definition: adi_rng.h:108
ADI_RNG_RESULT adi_rng_RegisterCallback(ADI_RNG_HANDLE hDevice, ADI_CALLBACK cbFunc, void *pCBParam)
RNG Application callback registration API.
Definition: adi_rng.c:710
ADI_RNG_EVENT
Definition: adi_rng.h:96
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:637
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:392
ADI_RNG_RESULT adi_rng_EnableBuffering(ADI_RNG_HANDLE const hDevice, bool const bFlag)
Enables/Disables Buffering for RNG.
Definition: adi_rng.c:294
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:336
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:140
ADI_RNG_RESULT adi_rng_Close(ADI_RNG_HANDLE hDevice)
Uninitializes and deallocates the RNG device.
Definition: adi_rng.c:216
ADI_RNG_RESULT adi_rng_Enable(ADI_RNG_HANDLE const hDevice, bool const bFlag)
Enables/Disables the RNG device.
Definition: adi_rng.c:251
ADI_RNG_RESULT
Definition: adi_rng.h:80