High level interface for interacting with the Cypress CRC, which provides hardware accelerated CRC computations. The CRC APIs are structured to enable usage in situations where the entire input data set is not available in memory at one time. Therefore, each conversion consists of three steps:
- A single call to cyhal_crc_start, to initialize data structures for this computation
- One or more calls to cyhal_crc_compute, to provide chunks of data.
- A single call to cyhal_crc_finish, to finalize the computation and retrieve the result.
Many of the algorithm parameters can be customized; see crc_algorithm_t for more details.
◆ crc_algorithm_t
| Data Fields |
|
uint32_t |
width |
Bit width of the CRC. |
|
uint32_t |
polynomial |
The polynomial to use. |
|
uint32_t |
lfsrInitState |
Initial state of the LFSR. |
|
uint32_t |
dataXor |
Byte mask to xor with the data. |
|
uint32_t |
remXor |
Mask to xor with the remainder. |
|
bool |
dataReverse |
The order in which data should be processed. If 0, data is processed MSB first. If 1, data is processed LSB first.
|
|
bool |
remReverse |
If 1, the remainder is reversed. If 0, it is not. |
◆ CYHAL_CRC_RSLT_ERR_BAD_ARGUMENT
◆ cyhal_crc_init()
Initialize the CRC generator. This function reserves the CRYPTO block for CRC calculations.
- Parameters
-
| [out] | obj | The CRC generator object |
- Returns
- The status of the init request.
◆ cyhal_crc_free()
Release the CRC generator.
- Parameters
-
| [in,out] | obj | The CRC generator object |
◆ cyhal_crc_start()
Initializes a CRC calculation.
- Parameters
-
| [in,out] | obj | The CRC generator object |
| [in] | algorithm | The CRC algorithm to use for computations |
- Returns
- The status of the compute request
◆ cyhal_crc_compute()
Computes the CRC for the given data. This function can be called multiple times to provide addtional data. This CRC generator will compute the CRC for including all data that was provided during previous calls.
- Parameters
-
| [in] | obj | The CRC generator object |
| [in] | data | The data to compute a CRC over |
| [in] | length | The number of bytes of data to process |
- Returns
- The status of the compute request
◆ cyhal_crc_finish()
Provides final result for a CRC calculation. This will compute the CRC for all data that was provided when during the diffrent calls to cyhal_crc_compute.
- Parameters
-
| [in] | obj | The CRC generator object |
| [out] | crc | The computed CRC |
- Returns
- The status of the compute request