Cyclic Redundancy Check Function Documentation

 

Sys_Set_CRC_Config

void Sys_Set_CRC_Config(CRC_Type * crc, uint32_t config)

 

Location: crc.h:52

 

Configure the CRC generator type, endianness of the input data, and standard vs non-standard CRC behavior.

 

Assumptions

Note that D_CRC supports only CRC_CCITT mode, hence no configuration is applied for this instance.

 

Example Code for Sys_Set_CRC_Config

    // Configure CRC block to CRC-32 (IEEE 802.3) algorithm,

    // using little endian and non-standard (opposite) bit order

    Sys_Set_CRC_Config(CRC, CRC_32 | CRC_LITTLE_ENDIAN |

                       CRC_BIT_ORDER_NON_STANDARD);

 

Parameters

Direction Name Description

in

crc

Pointer to the CRC instance

in

config

CRC generator configuration; use CRC_[CCITT | 32], CRC_[BIG | LITTLE]_ENDIAN, CRC_BIT_ORDER_[STANDARD | NON_STANDARD], CRC_FINAL_REVERSE_[STANDARD | NON_STANDARD], and CRC_FINAL_XOR_[STANDARD | NON_STANDARD]

 

Sys_CRC_32InitValue

void Sys_CRC_32InitValue(CRC_Type * crc)

 

Location: crc.h:68

 

Initialize CRC for CRC-32.

 

Assumptions

Note that D_CRC supports only CRC_CCITT mode, hence no configuration is applied for this instance.

 

Example Code for Sys_CRC_32InitValue

    // Initialize the CRC block for CRC-32

    Sys_CRC_32InitValue(CRC);

 

Parameters

Direction Name Description

in

crc

Pointer to the CRC instance

 

Sys_CRC_CCITTInitValue

void Sys_CRC_CCITTInitValue(CRC_Type * crc)

 

Location: crc.h:83

 

Initialize CRC for CRC-CCITT.

 

Assumptions

CRC is configured to work in CRC-CCITT mode.

 

Example Code for Sys_CRC_CCITTInitValue

    // Initialize the CRC block for CRC-CCITT

    Sys_CRC_CCITTInitValue(CRC);

 

Parameters

Direction Name Description

in

crc

Pointer to the CRC instance

 

Sys_CRC_GetCurrentValue

uint32_t Sys_CRC_GetCurrentValue(const CRC_Type * crc)

 

Location: crc.h:95

 

Retrieve current value from CRC.

 


Returns:
Current CRC value.

 

Example Code for Sys_CRC_GetCurrentValue

    // Retrieve current value from the CRC block

    value = Sys_CRC_GetCurrentValue(CRC);

 

Parameters

Direction Name Description

in

crc

Pointer to the CRC instance

 

Sys_CRC_GetFinalValue

uint32_t Sys_CRC_GetFinalValue(const CRC_Type * crc)

 

Location: crc.h:111

 

Initialize final CRC value.

 


Returns:
CRC final value.

Assumptions

D_CRC only supports CRC-CCITT mode. Use Sys_CRC_GetCurrentValue instead. Returns initial value of CRC if D_CRC is passed or any other unknown instance.

 

Example Code for Sys_CRC_GetFinalValue

    // Retrieve final value from the CRC block

    Sys_CRC_GetFinalValue(CRC);

 

Parameters

Direction Name Description

in

crc

Pointer to the CRC instance

 

Sys_CRC_Add

void Sys_CRC_Add(CRC_Type * crc, uint32_t data, uint32_t size)

 

Location: crc.h:138

 

Add data to the current CRC calculation, based on size.

 

 

Example Code for Sys_CRC_Add

    // Add 8 bits of data to the current CRC block

    Sys_CRC_Add(CRC, 0xF1, 8);

 

Parameters

Direction Name Description

in

crc

Pointer to the CRC instance

in

data

Data to add

in

size

Size of data to add, 1, 8, 16, 24, 32 are valid.