Xmega IEC60730 Class B Library  1.0
 All Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
CRC software implementation

Detailed Description

CRC computations implemented in software.

The CPU reads the data and computes the CRC checksum. There are two available methods:

The CRC32-polynomial is in the reflected form (0xEDB88320) in the software implementation. The initial remainder is 0xFFFFFFFF, and the generated checksum is bit-reversed and complemented (in compliance with IEE802.3). The CCITT polynomial used is 0x1021, with 0x0000 as initial remainder. In this case the checksum is neither bit reversed nor complemented.

const uint16_t CLASSB_CRC16Table [256]
const uint32_t CLASSB_CRC32Table [256]
 Table for IEE802.3 32-bit CRC, stored in Flash.

Settings for CRC software implementation

These symbols are used to choose between lookup table or direct computation. They should be defined for lookup table implementation and commented out otherwise.

#define CRC_USE_16BIT_LOOKUP_TABLE
 Select the lookup table method for 16-bit CRC.
#define CRC_USE_32BIT_LOOKUP_TABLE
 Select the lookup table method for 32-bit CRC.

CRC tests

Invariant memory tests based on CRC that are compliant with IEC60730 Class B.

uint16_t CLASSB_CRC16_EEPROM_SW (eepromptr_t dataptr, const crcbytenum_t numBytes, eeprom_uint16ptr_t pchecksum)
 Compute 16-bit CRC for EEPROM address range using table lookup.
uint16_t CLASSB_CRC16_Flash_SW (flashptr_t dataptr, const crcbytenum_t numBytes, eeprom_uint16ptr_t pchecksum)
 Compute 16-bit CRC for Flash address range using table lookup.
uint32_t CLASSB_CRC32_EEPROM_SW (eepromptr_t dataptr, const crcbytenum_t numBytes, eeprom_uint32ptr_t pchecksum)
 Compute 32-bit CRC for EEPROM address range using table lookup.
uint32_t CLASSB_CRC32_Flash_SW (flashptr_t dataptr, const crcbytenum_t numBytes, eeprom_uint32ptr_t pchecksum)
 Compute 32-bit CRC for Flash address range using table lookup.

Function Documentation

uint16_t CLASSB_CRC16_EEPROM_SW ( eepromptr_t  origDataptr,
crcbytenum_t  numBytes,
eeprom_uint16ptr_t  pchecksum 
)

Compute 16-bit CRC for EEPROM address range using table lookup.

This function returns the 16-bit CRC of the specified EEPROM address range.

Parameters:
origDataptrAddress of EEPROM location to start CRC computation at.
numBytesNumber of bytes of the data.
pchecksumPointer to the checksum stored in EEPROM.
Note:
No sanity checking of addresses is done.

Definition at line 111 of file classb_crc_sw.c.

References CLASSB_CRC16Table, CLASSB_EEMAP_BEGIN, CLASSB_EEMAP_END, and CLASSB_ERROR_HANDLER_CRC.

uint16_t CLASSB_CRC16_Flash_SW ( flashptr_t  origDataptr,
crcbytenum_t  numBytes,
eeprom_uint16ptr_t  pchecksum 
)

Compute 16-bit CRC for Flash address range using table lookup.

This function returns the 16-bit CRC of the specified Flash address range.

Parameters:
origDataptrAddress of Flash location to start CRC computation at.
numBytesNumber of bytes of the data.
pchecksumPointer to the checksum stored in EEPROM.
Note:
No sanity checking of addresses is done.

Definition at line 161 of file classb_crc_sw.c.

References CLASSB_CRC16Table, CLASSB_EEMAP_BEGIN, CLASSB_EEMAP_END, and CLASSB_ERROR_HANDLER_CRC.

uint32_t CLASSB_CRC32_EEPROM_SW ( eepromptr_t  origDataptr,
crcbytenum_t  numBytes,
eeprom_uint32ptr_t  pchecksum 
)

Compute 32-bit CRC for EEPROM address range using table lookup.

This function returns the 32-bit CRC of the specified EEPROM address range.

Parameters:
origDataptrAddress of EEPROM location to start CRC computation at.
numBytesNumber of bytes of the data.
pchecksumPointer to the checksum stored in EEPROM.
Note:
No sanity checking of addresses is done.

Definition at line 289 of file classb_crc_sw.c.

References CLASSB_CRC32Table, CLASSB_EEMAP_BEGIN, CLASSB_EEMAP_END, and CLASSB_ERROR_HANDLER_CRC.

uint32_t CLASSB_CRC32_Flash_SW ( flashptr_t  origDataptr,
crcbytenum_t  numBytes,
eeprom_uint32ptr_t  pchecksum 
)

Compute 32-bit CRC for Flash address range using table lookup.

This function returns the 32-bit CRC of the specified Flash address range.

Parameters:
origDataptrAddress of Flash location to start CRC computation at.
numBytesNumber of bytes of the data.
pchecksumPointer to the checksum stored in EEPROM.
Note:
No sanity checking of addresses is done.

Definition at line 342 of file classb_crc_sw.c.

References CLASSB_CRC32Table, CLASSB_EEMAP_BEGIN, CLASSB_EEMAP_END, and CLASSB_ERROR_HANDLER_CRC.


Variable Documentation

const uint16_t CLASSB_CRC16Table[256]

Table for CCITT 16-bit CRC, stored in Flash

Definition at line 64 of file classb_crc_sw.c.

Referenced by CLASSB_CRC16_EEPROM_SW(), and CLASSB_CRC16_Flash_SW().