Code Confidencebuild 3.0.0.201402161939

Chapter 68. CRC Functions

CRC API

The package implements a number of CRC functions as described below. The API to these functions is in the include file cyg/crc/crc.h.

cyg_posix_crc32

This function implements a 32 bit CRC which is compliant to the POSIX 1008.2 Standard. This is the same as the Linux cksum program.

cyg_uint32 cyg_posix_crc32(unsigned char * s, int len);

The CRC calculation is run over the data pointed to by s, of length len. The CRC is returned as an unsigned long.

cyg_crc32

These functions implement a 32 bit CRC by Gary S. Brown. They use the polynomial X^32+X^26+X^23+X^22+X^16+X^12+X^11+X^10+X^8+X^7+X^5+X^4+X^2+X^1+X^0.

cyg_uint32 cyg_crc32(unsigned char * s, int len);
cyg_uint32 cyg_crc32_accumulate(cyg_uint32 crc, unsigned char * s, int len);

The CRC calculation is run over the data pointed to by s, of length len. The CRC is returned as an unsigned long.

The CRC can be calculated over data separated into multiple buffers by using the function cyg_crc32_accumulate(). The parameter crc should be the result from the previous CRC calculation.

cyg_ether_crc32

These functions implement the 32 bit CRC used by the Ethernet FCS word.

cyg_uint32 cyg_ether_crc32(unsigned char * s, int len);
cyg_uint32 cyg_ether_crc32_accumulate(cyg_uint32 crc, unsigned char * s, int len);

The CRC calculation is run over the data pointed to by s, of length len. The CRC is returned as an unsigned long.

The CRC can be calculated over data separated into multiple buffers by using the function cyg_ether_crc32_accumulate(). The parameter crc should be the result from the previous CRC calculation.

cyg_crc16

This function implements a 16 bit CRC. It uses the polynomial x^16+x^12+x^5+1.

cyg_uint16 cyg_crc16(unsigned char * s, int len);

The CRC calculation is run over the data pointed to by s, of length len. The CRC is returned as an unsigned short.