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.
uint16_t | PROGMEM_DECLARE (CLASSB_CRC16Table[256]) |
Table for CCITT 16-bit CRC, stored in Flash. More... | |
uint32_t | PROGMEM_DECLARE (CLASSB_CRC32Table[256]) |
Table for IEE802.3 32-bit CRC, stored in Flash. More... | |
Configuration settings for CRC software implementation | |
Symbols 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. More... | |
#define | CRC_USE_32BIT_LOOKUP_TABLE |
Select the lookup table method for 32-bit CRC. More... | |
Constants for internal use | |
This options make sure that the CRC computation complies with the standard 16-bit CCITT CRC and IEE802.3 32-bit CRC.
| |
#define | CRC16_POLYNOMIAL (uint16_t)0x1021 |
Polynomial used for computation of CRC16 (software, not lookup table) More... | |
#define | CRC32_POLYNOMIAL (uint32_t)0xEDB88320UL |
Polynomial used for computation of CRC32 (software, not lookup table) More... | |
#define | CRC32_FINAL_XOR_VALUE (uint32_t)0xFFFFFFFF |
Final XOR Value for CRC32. More... | |
Internal macros used for CRC computation | |
#define | CLASSB_CRC(data, crc, poly, crcbits) |
Update CRC value for one input byte. More... | |
#define | CLASSB_CRC_REFL(data, crc, poly, crcbits) |
Update CRC value for one input byte (reflected polynomial). More... | |
#define | CLASSB_CRC_REFL_TABLE_32(data, crc, table) |
Update 32-bit CRC value for one input byte (reflected polynomial). More... | |
#define | CLASSB_CRC_TABLE_16(data, crc, table) |
Update 16-bit CRC value for one input byte. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
#define CLASSB_CRC | ( | data, | |
crc, | |||
poly, | |||
crcbits | |||
) |
Update CRC value for one input byte.
data | Input data byte. |
crc | Variable that holds the CRC value. |
poly | CRC polynomial. |
crcbits | Number of CRC bits. |
Referenced by CLASSB_CRC16_EEPROM_SW(), and CLASSB_CRC16_Flash_SW().
#define CLASSB_CRC_REFL | ( | data, | |
crc, | |||
poly, | |||
crcbits | |||
) |
Update CRC value for one input byte (reflected polynomial).
data | Input data byte. |
crc | Variable that holds the CRC value. |
poly | CRC polynomial. |
crcbits | Number of CRC bits. |
Referenced by CLASSB_CRC32_EEPROM_SW(), and CLASSB_CRC32_Flash_SW().
#define CLASSB_CRC_REFL_TABLE_32 | ( | data, | |
crc, | |||
table | |||
) |
Update 32-bit CRC value for one input byte (reflected polynomial).
data | Input data byte. |
crc | Variable that holds the CRC value. |
table | Table that contains pre-calculated CRC values. |
Referenced by CLASSB_CRC32_EEPROM_SW(), and CLASSB_CRC32_Flash_SW().
#define CLASSB_CRC_TABLE_16 | ( | data, | |
crc, | |||
table | |||
) |
Update 16-bit CRC value for one input byte.
data | Input data byte. |
crc | Variable that holds the CRC value. |
table | Table that contains pre-calculated CRC values. |
Referenced by CLASSB_CRC16_EEPROM_SW(), and CLASSB_CRC16_Flash_SW().
#define CRC16_POLYNOMIAL (uint16_t)0x1021 |
Polynomial used for computation of CRC16 (software, not lookup table)
Referenced by CLASSB_CRC16_EEPROM_SW(), and CLASSB_CRC16_Flash_SW().
#define CRC32_FINAL_XOR_VALUE (uint32_t)0xFFFFFFFF |
Final XOR Value for CRC32.
Referenced by CLASSB_CRC32_EEPROM_SW(), and CLASSB_CRC32_Flash_SW().
#define CRC32_POLYNOMIAL (uint32_t)0xEDB88320UL |
Polynomial used for computation of CRC32 (software, not lookup table)
Referenced by CLASSB_CRC32_EEPROM_SW(), and CLASSB_CRC32_Flash_SW().
#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.
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.
origDataptr | Address of EEPROM location to start CRC computation at. |
numBytes | Number of bytes of the data. |
pchecksum | Pointer to the checksum stored in EEPROM. |
References CLASSB_CRC, CLASSB_CRC_TABLE_16, CLASSB_EEMAP_BEGIN, CLASSB_EEMAP_END, CLASSB_ERROR_HANDLER_CRC, CRC16_INITIAL_REMAINDER, and CRC16_POLYNOMIAL.
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.
origDataptr | Address of Flash location to start CRC computation at. |
numBytes | Number of bytes of the data. |
pchecksum | Pointer to the checksum stored in EEPROM. |
References CLASSB_CRC, CLASSB_CRC_TABLE_16, CLASSB_EEMAP_BEGIN, CLASSB_EEMAP_END, CLASSB_ERROR_HANDLER_CRC, CRC16_INITIAL_REMAINDER, CRC16_POLYNOMIAL, and PROGMEM_READ_BYTE.
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.
origDataptr | Address of EEPROM location to start CRC computation at. |
numBytes | Number of bytes of the data. |
pchecksum | Pointer to the checksum stored in EEPROM. |
References CLASSB_CRC_REFL, CLASSB_CRC_REFL_TABLE_32, CLASSB_EEMAP_BEGIN, CLASSB_EEMAP_END, CLASSB_ERROR_HANDLER_CRC, CRC32_FINAL_XOR_VALUE, CRC32_INITIAL_REMAINDER, and CRC32_POLYNOMIAL.
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.
origDataptr | Address of Flash location to start CRC computation at. |
numBytes | Number of bytes of the data. |
pchecksum | Pointer to the checksum stored in EEPROM. |
References CLASSB_CRC_REFL, CLASSB_CRC_REFL_TABLE_32, CLASSB_EEMAP_BEGIN, CLASSB_EEMAP_END, CLASSB_ERROR_HANDLER_CRC, CRC32_FINAL_XOR_VALUE, CRC32_INITIAL_REMAINDER, CRC32_POLYNOMIAL, and PROGMEM_READ_BYTE.
uint16_t PROGMEM_DECLARE | ( | CLASSB_CRC16Table | [256] | ) |
Table for CCITT 16-bit CRC, stored in Flash.
uint32_t PROGMEM_DECLARE | ( | CLASSB_CRC32Table | [256] | ) |
Table for IEE802.3 32-bit CRC, stored in Flash.