GPCRC - General Purpose CRC

Description

General Purpose Cyclic Redundancy Check (GPCRC) API.

The GPCRC API functions provide full support for the GPCRC peripheral.

The GPCRC module is a peripheral that implements a Cyclic Redundancy Check (CRC) function. It supports a fixed 32-bit polynomial and a user configurable 16-bit polynomial. The fixed 32-bit polynomial is the commonly used IEEE 802.3 polynomial 0x04C11DB7.

When using a 16-bit polynomial it is up to the user to choose a polynomial that fits the application. Commonly used 16-bit polynomials are 0x1021 (CCITT-16), 0x3D65 (IEC16-MBus), and 0x8005 (ZigBee, 802.15.4, and USB). See this link for other polynomials: https://en.wikipedia.org/wiki/Cyclic_redundancy_check

Before a CRC calculation can begin it is important to call the GPCRC_Start function. This function will reset CRC calculation by copying the configured initialization value over to the CRC data register.

There are two ways of sending input data to the GPCRC. Either write the input data into the input data register using input functions GPCRC_InputU32 , GPCRC_InputU16 and GPCRC_InputU8 , or the user can configure LDMA - Linked DMA to transfer data directly to one of the GPCRC input data registers.

Examples of GPCRC usage:

A CRC-32 Calculation:

#if !defined(_SILICON_LABS_32B_SERIES_2)
/* The GPCRC is a high frequency peripheral so we need to enable the
* HFPER clock in addition to the GPCRC clock. */
#endif
uint32_t checksum;
/* Initialize GPCRC, 32-bit fixed polynomial is default */
init. initValue = 0xFFFFFFFF; // Standard CRC-32 init value
GPCRC_Init (GPCRC, &init);
GPCRC_Start (GPCRC);
GPCRC_InputU8 (GPCRC, 0xC5);
/* According to the CRC-32 specification, the end result should be inverted */
checksum = ~ GPCRC_DataRead (GPCRC);
/* The checksum is now 0x390CD9B2 */

A CRC-16 Calculation:

#if !defined(_SILICON_LABS_32B_SERIES_2)
/* The GPCRC is a high frequency peripheral so we need to enable the
* HFPER clock in addition to the GPCRC clock. */
#endif
uint16_t checksum;
/* Initialize GPCRC with the 16-bit polynomial 0x8005. */
init.