PSoC 6 Hardware Abstraction Layer (HAL)
CRC (Cyclic Redundancy Check)

General Description

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:

Many of the algorithm parameters can be customized; see crc_algorithm_t for more details.

Data Structures

struct  crc_algorithm_t
 CRC algorithm parameters. More...
 

Macros

#define CYHAL_CRC_RSLT_ERR_BAD_ARGUMENT   (CY_RSLT_CREATE(CY_RSLT_TYPE_ERROR, CYHAL_RSLT_MODULE_CRC, 0))
 

Functions

cy_rslt_t cyhal_crc_init (cyhal_crc_t *obj)
 
void cyhal_crc_free (cyhal_crc_t *obj)
 
cy_rslt_t cyhal_crc_start (cyhal_crc_t *obj, const crc_algorithm_t *algorithm)
 
cy_rslt_t cyhal_crc_compute (const cyhal_crc_t *obj, const uint8_t *data, size_t length)
 
cy_rslt_t cyhal_crc_finish (const cyhal_crc_t *obj, uint32_t *crc)
 

Data Structure Documentation

◆ crc_algorithm_t

struct 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.

Macro Definition Documentation

◆ CYHAL_CRC_RSLT_ERR_BAD_ARGUMENT

#define CYHAL_CRC_RSLT_ERR_BAD_ARGUMENT   (CY_RSLT_CREATE(CY_RSLT_TYPE_ERROR, CYHAL_RSLT_MODULE_CRC, 0))

Invalid argument

Function Documentation

◆ cyhal_crc_init()

cy_rslt_t cyhal_crc_init ( cyhal_crc_t *  obj)

Initialize the CRC generator. This function reserves the CRYPTO block for CRC calculations.

Parameters
[out]objThe CRC generator object
Returns
The status of the init request.

◆ cyhal_crc_free()

void cyhal_crc_free ( cyhal_crc_t *  obj)

Release the CRC generator.

Parameters
[in,out]objThe CRC generator object

◆ cyhal_crc_start()

cy_rslt_t cyhal_crc_start ( cyhal_crc_t *  obj,
const crc_algorithm_t *  algorithm 
)

Initializes a CRC calculation.

Parameters
[in,out]objThe CRC generator object
[in]algorithmThe CRC algorithm to use for computations
Returns
The status of the compute request

◆ cyhal_crc_compute()

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. 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]objThe CRC generator object
[in]dataThe data to compute a CRC over
[in]lengthThe number of bytes of data to process
Returns
The status of the compute request

◆ cyhal_crc_finish()

cy_rslt_t cyhal_crc_finish ( const cyhal_crc_t *  obj,
uint32_t *  crc 
)

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]objThe CRC generator object
[out]crcThe computed CRC
Returns
The status of the compute request