Microchip® Advanced Software Framework

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
CRC-32 calculation service

See Quick Start Guide for CRC-32.

This service enables the user to calculate 32-bit CRC using the polynomial defined in the IEEE 802.3 standard, with support for multiple data blocks of arbitrary sizes, and any alignment in memory.

Modules

 Quick Start Guide(s)
 In this section you can find a list of all Quick Start guides related to the CRC-32 calculation service.
 

Typedefs

typedef uint32_t crc32_t
 Type to contain 32-bit CRC. More...
 

Functions

static enum status_code crc32_calculate (const void *data, size_t length, crc32_t *crc)
 Calculate 32-bit CRC for initial block. More...
 
enum status_code crc32_recalculate (const void *data, size_t length, crc32_t *crc)
 Recalculate 32-bit CRC for another block. More...
 

typedef uint32_t crc32_t

Type to contain 32-bit CRC.

static enum status_code crc32_calculate ( const void *  data,
size_t  length,
crc32_t crc 
)
inlinestatic

Calculate 32-bit CRC for initial block.

This function calculates the CRC for the specified data block, which may be first of an arbitrary number of blocks.

The actual calculation is done in crc32_recalculate(), while this function just sets up the initial CRC value.

Parameters
[in]dataAddress of data.
[in]lengthLength of data.
[out]crcAddress of variable to store the calculated CRC in.
Returns
Status of calculation.
Return values
STATUS_OKif calculation succeeded.
<other>if calculation failed somehow.
Note
To calculate the CRC of multiple blocks, use this function first, then crc32_recalculate() for the following blocks.

References crc32_recalculate().

enum status_code crc32_recalculate ( const void *  data,
size_t  length,
crc32_t crc 
)

Recalculate 32-bit CRC for another block.

This function recalculates the CRC according to the polynomial CRC32_POLYNOMIAL for the specified data block and initial CRC value.

To reduce the number of databus accesses and thus speed up the calculation, the algorithm is tuned to work with words as much as possible.

Parameters
[in]dataAddress of data.
[in]lengthLength of data.
[in,out]crcAddress of variable containing current CRC, and to store recalculated CRC in.
Returns
Status of calculation.
Return values
STATUS_OKif calculation succeeded.
<other>if calculation failed or could not be started.
Note
To calculate the CRC of multiple blocks, use crc32_calculate() first, then this function for the following blocks.
Attention
This implementation assumes a little-endian architecture.

References _crc32_recalculate_bytes_helper(), COMPLEMENT_CRC, length, STATUS_OK, WORD_ALIGNMENT_MASK, and WORD_SIZE.

Referenced by crc32_calculate().