High level interface for interacting with the 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 the same time. Therefore, each conversion consists of three steps:
Many of the algorithm parameters can be customized.
See crc_algorithm_t and Snippet1: CRC Generation for more details.
cyhal_crc_init initializes the CRC generator and passes the pointer to the CRC block through the obj object of type cyhal_crc_t.
The following snippet initializes a CRC generator and computes the CRC for a sample message.
API Reference | |
CRC HAL Results | |
CRC specific return codes. | |
Data Structures | |
struct | crc_algorithm_t |
CRC algorithm parameters. More... | |
Functions | |
cy_rslt_t | cyhal_crc_init (cyhal_crc_t *obj) |
Initialize the CRC generator. More... | |
void | cyhal_crc_free (cyhal_crc_t *obj) |
Release the CRC generator. More... | |
cy_rslt_t | cyhal_crc_start (cyhal_crc_t *obj, const crc_algorithm_t *algorithm) |
The CRC block is setup to perform CRC computation. More... | |
cy_rslt_t | cyhal_crc_compute (const cyhal_crc_t *obj, const uint8_t *data, size_t length) |
Computes the CRC for the given data and accumulates the CRC with the CRC generated from previous calls. More... | |
cy_rslt_t | cyhal_crc_finish (const cyhal_crc_t *obj, uint32_t *crc) |
Finalizes the CRC computation and returns the CRC for the complete set of data passed through a single call or multiple calls to cyhal_crc_compute. More... | |
struct crc_algorithm_t |
cy_rslt_t cyhal_crc_init | ( | cyhal_crc_t * | obj | ) |
Initialize the CRC generator.
This function reserves the CRYPTO block for CRC calculations.
[out] | obj | Pointer to a CRC generator object. The caller must allocate the memory for this object but the init function will initialize its contents. |
Returns CY_RSLT_SUCCESS if the operation was successful. Refer Snippet1: CRC Generation for more information.
void cyhal_crc_free | ( | cyhal_crc_t * | obj | ) |
Release the CRC generator.
[in,out] | obj | The CRC generator object |
cy_rslt_t cyhal_crc_start | ( | cyhal_crc_t * | obj, |
const crc_algorithm_t * | algorithm | ||
) |
The CRC block is setup to perform CRC computation.
[in,out] | obj | The CRC generator object |
[in] | algorithm | The CRC algorithm to use for computations Refer crc_algorithm_t. |
Returns CY_RSLT_SUCCESS if the operation was successful.
cy_rslt_t cyhal_crc_compute | ( | const cyhal_crc_t * | obj, |
const uint8_t * | data, | ||
size_t | length | ||
) |
Computes the CRC for the given data and accumulates the CRC with the CRC generated from previous calls.
This function can be called multiple times to provide additional data.
[in] | obj | The CRC generator object |
[in] | data | The input data |
[in] | length | The number of bytes in the data |
Returns CY_RSLT_SUCCESS if the operation was successful.
cy_rslt_t cyhal_crc_finish | ( | const cyhal_crc_t * | obj, |
uint32_t * | crc | ||
) |
Finalizes the CRC computation and returns the CRC for the complete set of data passed through a single call or multiple calls to cyhal_crc_compute.
[in] | obj | The CRC generator object |
[out] | crc | The computed CRC |
Returns CY_RSLT_SUCCESS if the operation was successful.