ADuCM4x50 Device Drivers API Reference Manual  Release 4.0.0.0
adi_crc.h
1 
13 #ifndef ADI_CRC_H
14 #define ADI_CRC_H
15 
20 #include <adi_processor.h>
21 
22 /*============= I N C L U D E S =============*/
23 #include <string.h>
24 /* Memory size check */
25 #include <assert.h>
26 
27 /* DMA Manager includes */
28 #include <drivers/dma/adi_dma.h>
29 
30 /* Include the config file for CRC */
31 #include <adi_crc_config.h>
32 
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36 
37 /*============== D E F I N E S ===============*/
38 
39 #if (ADI_CRC_CFG_ENABLE_DMA_SUPPORT == 0)
40 
41 
47 #if defined(__ICCARM__)
48 
52 #define ADI_CRC_MEMORY_SIZE (32u)
53 #else
54 
60 #define ADI_CRC_MEMORY_SIZE (32u)
61 #endif
62 
63 
64 #else /* ADI_CRC_CFG_ENABLE_DMA_SUPPORT */
65 
66 
72 #if defined(__ICCARM__)
73 
77 #define ADI_CRC_MEMORY_SIZE (32u)
78 #else
79 
85 #define ADI_CRC_MEMORY_SIZE (32u)
86 #endif
87 
89 #define ADI_CRC_VALID_DMA_CHANNEL(DMA_CHANNEL_ID) ((SIP0_CHANn<=(DMA_CHANNEL_ID)) && ((DMA_CHANNEL_ID)<=SIP7_CHANn))
90 
96 typedef enum __ADI_CRC_EVENT
97 {
99  ADI_CRC_EVENT_BUFFER_PROCESSED = ADI_DMA_EVENT_BUFFER_PROCESSED,
100 
102  ADI_CRC_EVENT_ERROR
103 } ADI_CRC_EVENT;
104 
105 #endif /* ADI_CRC_CFG_ENABLE_DMA_SUPPORT */
106 
112 typedef struct __ADI_CRC_DEVICE* ADI_CRC_HANDLE;
113 
117 typedef enum
118 {
130 
131 /*======= P U B L I C P R O T O T Y P E S ========*/
132 /* (globally-scoped functions) */
133 
134 /* Opens a CRC device instance */
136  uint32_t DeviceNum,
137  void *pMemory,
138  uint32_t MemorySize,
139  ADI_CRC_HANDLE *phDevice);
140 
141 /* Closes a CRC device instance */
143  ADI_CRC_HANDLE const hDevice);
144 
145 /* Registers or unregisters a callback, used by the CRC interrupt handler or with DMA driven operations, with the CRC device */
147  ADI_CRC_HANDLE const hDevice,
148  ADI_CALLBACK pfCallback,
149  void *const pCBParam);
150 
151 /* Sets the 32-bit polynomial for CRC operations */
153  ADI_CRC_HANDLE const hDevice,
154  uint32_t PolynomialVal);
155 
156 /* Submits data buffer for CRC operation */
158  ADI_CRC_HANDLE const hDevice,
159  void *pCrcBuf,
160  uint32_t NumBytes,
161  uint32_t NumBits);
162 
163 /* Gets the current CRC peripheral status */
165  ADI_CRC_HANDLE const hDevice,
166  bool *pbCrcInProgress);
167 
168 /* Gets the final CRC result computed for a data stream */
170  ADI_CRC_HANDLE const hDevice,
171  uint32_t *pFinalCrcVal);
172 
173 /* Gets the current/intermediate CRC result computed for a data stream */
175  ADI_CRC_HANDLE const hDevice,
176  uint32_t *pCurrentCrcVal);
177 
179  ADI_CRC_HANDLE const hDevice,
180  const bool bEnable);
181 
183  ADI_CRC_HANDLE const hDevice,
184  const bool bEnable);
185 
187  ADI_CRC_HANDLE const hDevice,
188  const bool bEnable);
189 
191  ADI_CRC_HANDLE const hDevice,
192  uint32_t CrcSeedVal);
193 
195  ADI_CRC_HANDLE const hDevice,
196  const bool bEnable);
197 
198 #ifdef __cplusplus
199 }
200 #endif
201 
204 #endif /* ADI_CRC_H */
struct __ADI_CRC_DEVICE * ADI_CRC_HANDLE
Definition: adi_crc.h:112
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:1172
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:1218
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:827
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:990
ADI_CRC_RESULT adi_crc_SetLSBFirst(ADI_CRC_HANDLE const hDevice, const bool bEnable)
Enable the LSB first.
Definition: adi_crc.c:872
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:661
ADI_CRC_RESULT adi_crc_IsCrcInProgress(ADI_CRC_HANDLE const hDevice, bool *pbCrcInProgress)
Gets the current CRC peripheral status.
Definition: adi_crc.c:1088
ADI_CRC_RESULT
Definition: adi_crc.h:117
ADI_CRC_RESULT adi_crc_Close(ADI_CRC_HANDLE const hDevice)
Closes CRC device instance opened for use.
Definition: adi_crc.c:739
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:1139
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:915
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:954
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:1037
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....
Definition: adi_crc.c:784