1.41.3.2 CRCCUx_CRCCalculate Function
C
// x - Instance of the CRCCU peripheral bool CRCCUx_CRCCalculate ( uint32_t startAddress, uint16_t length, uint32_t * crc, bool chain );
Summary
Calculates the CRC Value for the specified address range.
Description
This function uses the CRCCU to calculate the CRC on a memory block. The start address and the size of the memory block are specified by startAddress and the size parameters.
For calculating the CRC of non-contiguous memory blocks, the chain parameter must be set to true.
The calcualted CRC is returned in the crc parameter. This should be inverted to match standard CRC implementations. It should be kept non-inverted if used as a starting point for subsequent CRC calculations.
Precondition
CRCCU_Initialize() function must have been called first for the associated instance.
Parameters
Param | Description |
---|---|
startAddress | the starting location of the memory block on which the CRC calculation needs to be performed. This needs to be aligned on a 4 byte boundary. |
length | size of the memory block in terms of 32-bit word. |
chain | indicates if the transaction is a new transaction or calculation over non-contiguous memory block |
crc | pointer to the return parameter where the calculated CRC result is stored. This should be inverted to match standard CRC implementations. This should be kept non-inverted if used a starting point for subsequent CRC calculations. |
Returns
true - The CRC was calculated successfully.
false - A fault occurred while calculating the CRC.
Example
const uint8_t crc_data[16] = {0xf0, 0x7f, 0x00, 0x20, 0x19,0x0c, 0x00, 0x00, 0x39, 0x0e, 0x00, 0x00, 0x3b, 0x0e, 0x00, 0x00} uint32_t crc = 0; CRCCU_Initialize(); if (CRCCU_CRCCalculate((uint32_t)&crc_data, 16, &crc, false) == true) { //application specific code }
Remarks
None.