ADuCM302x Device Drivers API Reference Manual  Release 3.1.2.0
adi_crc.h
1 
45 #ifndef ADI_CRC_H
46 #define ADI_CRC_H
47 
52 #include <adi_processor.h>
53 
54 /*============= I N C L U D E S =============*/
55 #include <string.h>
56 /* Memory size check */
57 #include <assert.h>
58 
59 /* DMA Manager includes */
60 #include <drivers/dma/adi_dma.h>
61 
62 /* Include the config file for CRC */
63 #include <adi_crc_config.h>
64 
65 #ifdef __cplusplus
66 extern "C" {
67 #endif
68 
69 /*============== D E F I N E S ===============*/
70 
71 #if (ADI_CRC_CFG_ENABLE_DMA_SUPPORT == 0)
72 
73 
79 #if defined(__ICCARM__)
80 
84 #define ADI_CRC_MEMORY_SIZE (32u)
85 #else
86 
92 #define ADI_CRC_MEMORY_SIZE (32u)
93 #endif
94 
95 
96 #else /* ADI_CRC_CFG_ENABLE_DMA_SUPPORT */
97 
98 
104 #if defined(__ICCARM__)
105 
109 #define ADI_CRC_MEMORY_SIZE (32u)
110 #else
111 
117 #define ADI_CRC_MEMORY_SIZE (32u)
118 #endif
119 
121 #define ADI_CRC_VALID_DMA_CHANNEL(DMA_CHANNEL_ID) ((SIP0_CHANn<=(DMA_CHANNEL_ID)) && ((DMA_CHANNEL_ID)<=SIP7_CHANn))
122 
128 typedef enum __ADI_CRC_EVENT
129 {
131  ADI_CRC_EVENT_BUFFER_PROCESSED = ADI_DMA_EVENT_BUFFER_PROCESSED,
132 
134  ADI_CRC_EVENT_ERROR
135 } ADI_CRC_EVENT;
136 
137 #endif /* ADI_CRC_CFG_ENABLE_DMA_SUPPORT */
138 
144 typedef struct __ADI_CRC_DEVICE* ADI_CRC_HANDLE;
145 
149 typedef enum
150 {
162 
163 /*======= P U B L I C P R O T O T Y P E S ========*/
164 /* (globally-scoped functions) */
165 
166 /* Opens a CRC device instance */
167 ADI_CRC_RESULT adi_crc_Open(
168  uint32_t DeviceNum,
169  void *pMemory,
170  uint32_t MemorySize,
171  ADI_CRC_HANDLE *phDevice);
172 
173 /* Closes a CRC device instance */
174 ADI_CRC_RESULT adi_crc_Close(
175  ADI_CRC_HANDLE const hDevice);
176 
177 /* Registers or unregisters a callback, used by the CRC interrupt handler or with DMA driven operations, with the CRC device */
178 ADI_CRC_RESULT adi_crc_RegisterCallback(
179  ADI_CRC_HANDLE const hDevice,
180  ADI_CALLBACK pfCallback,
181  void *const pCBParam);
182 
183 /* Sets the 32-bit polynomial for CRC operations */
184 ADI_CRC_RESULT adi_crc_SetPolynomialVal(
185  ADI_CRC_HANDLE const hDevice,
186  uint32_t PolynomialVal);
187 
188 /* Submits data buffer for CRC operation */
189 ADI_CRC_RESULT adi_crc_Compute(
190  ADI_CRC_HANDLE const hDevice,
191  void *pCrcBuf,
192  uint32_t NumBytes,
193  uint32_t NumBits);
194 
195 /* Gets the current CRC peripheral status */
196 ADI_CRC_RESULT adi_crc_IsCrcInProgress(
197  ADI_CRC_HANDLE const hDevice,
198  bool *pbCrcInProgress);
199 
200 /* Gets the final CRC result computed for a data stream */
201 ADI_CRC_RESULT adi_crc_GetFinalCrcVal(
202  ADI_CRC_HANDLE const hDevice,
203  uint32_t *pFinalCrcVal);
204 
205 /* Gets the current/intermediate CRC result computed for a data stream */
206 ADI_CRC_RESULT adi_crc_GetCurrentCrcVal(
207  ADI_CRC_HANDLE const hDevice,
208  uint32_t *pCurrentCrcVal);
209 
210 ADI_CRC_RESULT adi_crc_SetBitMirroring(
211  ADI_CRC_HANDLE const hDevice,
212  const bool bEnable);
213 
214 ADI_CRC_RESULT adi_crc_SetByteMirroring(
215  ADI_CRC_HANDLE const hDevice,
216  const bool bEnable);
217 
218 ADI_CRC_RESULT adi_crc_EnableWordSwap(
219  ADI_CRC_HANDLE const hDevice,
220  const bool bEnable);
221 
222 ADI_CRC_RESULT adi_crc_SetCrcSeedVal(
223  ADI_CRC_HANDLE const hDevice,
224  uint32_t CrcSeedVal);
225 
226 ADI_CRC_RESULT adi_crc_SetLSBFirst(
227  ADI_CRC_HANDLE const hDevice,
228  const bool bEnable);
229 
230 #ifdef __cplusplus
231 }
232 #endif
233 
236 #endif /* ADI_CRC_H */
struct __ADI_CRC_DEVICE * ADI_CRC_HANDLE
Definition: adi_crc.h:144
ADI_CRC_RESULT adi_crc_GetCurrentCrcVal(ADI_CRC_HANDLE const hDevice, uint32_t *pCurrentCrcVal)
Gets the current/intermediate CRC result computed for a data stream.
Definition: adi_crc.c:1203
ADI_CRC_RESULT adi_crc_RegisterCallback(ADI_CRC_HANDLE const hDevice, ADI_CALLBACK pfCallback, void *const pCBParam)
Registers or unregisters a callback with the CRC device.
Definition: adi_crc.c:1249
ADI_CRC_RESULT adi_crc_SetByteMirroring(ADI_CRC_HANDLE const hDevice, const bool bEnable)
Set the byte mirroring. This function should be called only when device is disabled.
Definition: adi_crc.c:858
ADI_CRC_RESULT adi_crc_SetPolynomialVal(ADI_CRC_HANDLE const hDevice, uint32_t PolynomialVal)
Sets the 32-bit polynomial for CRC operations.
Definition: adi_crc.c:1021
ADI_CRC_RESULT adi_crc_SetLSBFirst(ADI_CRC_HANDLE const hDevice, const bool bEnable)
Enable the LSB first.
Definition: adi_crc.c:903
ADI_CRC_RESULT adi_crc_Open(uint32_t DeviceNum, void *pMemory, uint32_t MemorySize, ADI_CRC_HANDLE *phDevice)
Opens a CRC device instance.
Definition: adi_crc.c:692
ADI_CRC_RESULT adi_crc_IsCrcInProgress(ADI_CRC_HANDLE const hDevice, bool *pbCrcInProgress)
Gets the current CRC peripheral status.
Definition: adi_crc.c:1119
ADI_CRC_RESULT
Definition: adi_crc.h:149
ADI_CRC_RESULT adi_crc_Close(ADI_CRC_HANDLE const hDevice)
Closes CRC device instance opened for use.
Definition: adi_crc.c:770
ADI_CRC_RESULT adi_crc_GetFinalCrcVal(ADI_CRC_HANDLE const hDevice, uint32_t *pFinalCrcVal)
Gets the final CRC result computed for a data stream.
Definition: adi_crc.c:1170
ADI_CRC_RESULT adi_crc_EnableWordSwap(ADI_CRC_HANDLE const hDevice, const bool bEnable)
To enable/disable the word Swap. This function should be called only when device is disabled...
Definition: adi_crc.c:946
ADI_CRC_RESULT adi_crc_SetCrcSeedVal(ADI_CRC_HANDLE const hDevice, uint32_t CrcSeedVal)
Sets the initial seed value for the CRC operation that is about to take place.
Definition: adi_crc.c:985
ADI_CRC_RESULT adi_crc_Compute(ADI_CRC_HANDLE const hDevice, void *pCrcBuf, uint32_t NumBytes, uint32_t NumBits)
Submits data buffer for CRC computation.
Definition: adi_crc.c:1068
ADI_CRC_RESULT adi_crc_SetBitMirroring(ADI_CRC_HANDLE const hDevice, const bool bEnable)
Set the bit mirroring. This function should be called only when device is idle, i.e. when no data are being processd by the CRC.
Definition: adi_crc.c:815