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

Detailed Description

Low-level driver implementation for the AVR XMEGA AU CRC module.

The CRC computation is done by the hardware CRC module. Even if this hardware module computes the checksum, the CPU can still be required to read the data. In the case of 32-bit CRC computation for flash memory, the whole process can be run without support from the CPU. However, for the 16-bit computation the CPU would have to read from Flash memory and transfer data to the CRC module. For CRC computations of data in SRAM, EEPROM or peripherals, the CPU will have to transfer data to the CRC module unless a DMA transaction is setup. The CRC-CCITT polynomial is 0x1021 and the IEEE 802.3 polynomial is 0x04C11DB7. More details on the CRC implementation can be found in the XMEGA AU manual.

Note:
  • The CRC module driver requires one of the new XMEGA AU devices.
  • The CPU is locked while the CRC module is set to compute a checksum from Flash.
  • CRC32 in Flash can only check an even number of bytes.
  • When specifying Flash or EEPROM addresses, 0x000000 denotes the start of physical memory.

NVM Commands

NVMcommands related to 32-bit CRC for flash memory. This is only used by CLASSB_CRC32_Flash_HW.

#define CRC_FLASH_RANGE   NVM_CMD_FLASH_RANGE_CRC_gc
 Compute a CRC checksum on an address range.
#define CRC_BOOT   NVM_CMD_BOOT_CRC_gc
 Compute a CRC checksum on the application section.
#define CRC_APP   NVM_CMD_APP_CRC_gc
 Compute a CRC checksum on the boot section.

CRC tests

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

uint16_t CLASSB_CRC16_EEPROM_HW (eepromptr_t dataptr, const crcbytenum_t numBytes, eeprom_uint16ptr_t pchecksum)
 Compute 16-bit CRC for EEPROM address range using hardware CRC module.
uint16_t CLASSB_CRC16_Flash_HW (flashptr_t dataptr, const crcbytenum_t numBytes, eeprom_uint16ptr_t pchecksum)
 Compute 16-bit CRC for Flash address range using hardware CRC module.
uint32_t CLASSB_CRC32_EEPROM_HW (eepromptr_t dataptr, const crcbytenum_t numBytes, eeprom_uint32ptr_t pchecksum)
 Compute 32-bit CRC for EEPROM address range using hardware CRC module.
uint32_t CLASSB_CRC32_Flash_HW (NVM_CMD_t crc_type, flashptr_t dataptr, const crcbytenum_t numBytes, eeprom_uint32ptr_t pchecksum)
 Compute 32-bit CRC for Flash address range using hardware CRC module.

Function Documentation

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

Compute 16-bit CRC for EEPROM address range using hardware CRC module.

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 394 of file classb_crc_hw.c.

References CLASSB_EEMAP_BEGIN, CLASSB_EEMAP_END, and CLASSB_ERROR_HANDLER_CRC.

Referenced by ISR().

+ Here is the caller graph for this function:

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

Compute 16-bit CRC for Flash address range using hardware CRC module.

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:
16-bit flash CRC is much slower than 32-bit for flash checking.
No sanity checking of addresses is done.

Definition at line 439 of file classb_crc_hw.c.

References CLASSB_EEMAP_BEGIN, CLASSB_EEMAP_END, and CLASSB_ERROR_HANDLER_CRC.

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

Compute 32-bit CRC for EEPROM address range using hardware CRC module.

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 518 of file classb_crc_hw.c.

References CLASSB_EEMAP_BEGIN, CLASSB_EEMAP_END, and CLASSB_ERROR_HANDLER_CRC.

uint32_t CLASSB_CRC32_Flash_HW ( NVM_CMD_t  crc_type,
flashptr_t  origDataptr,
crcbytenum_t  numBytes,
eeprom_uint32ptr_t  pchecksum 
)

Compute 32-bit CRC for Flash address range using hardware CRC module.

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

Parameters:
crc_typeType of CRC computation: CRC_FLASH_RANGE, CRC_BOOT or CRC_APP.
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 560 of file classb_crc_hw.c.

References CLASSB_EEMAP_BEGIN, CLASSB_EEMAP_END, and CLASSB_ERROR_HANDLER_CRC.

Referenced by ISR().

+ Here is the caller graph for this function: