1.31.6.1 DSU_CRCCalculate Function
C
bool DSU_CRCCalculate(uint32_t startAddress, size_t length, uint32_t crcSeed, uint32_t * crc);
Summary
Calculates the CRC Value for the specified address range.
Description
This function uses the hardware CRC computation feature of the DSU to calculate the CRC on a memory block. The start address and the size of the memory block are specified by startAddress and the length parameters.
If this is the first block, the value of the crcSeed parameter should be 0xFFFFFFFF. For calculating the CRC of non-contiguous memory blocks, the CRC result from the CRC calculation of a previous memory block can be passed as the crcSeed to the CRC calculation of the next memory block.
The calculated 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
None.
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. |
crcSeed | Initial crcSeed value. This should be 0xFFFFFFFF for the first block. CRC values from the previous calculations can be passed as the CRC seed for next calculation while calculating CRC of separate CRC blocks. |
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
// Calculate the CRC of a memory block starting 0x30000 and 1024 bytes. bool crcStatus; uint32_t crcResult; crcstatus = DSU_CRCCalculate((uint32_t)(0x30000), 1024, 0xFFFFFFFF, &crcResult); if(crcStatus == true) { // This is the standard CRC result. crcResult = ~crcResult; }
// Calculate the CRC of multiple but separate blocks. Return status is // ignored in this example. Note how the intermediate result is not // inverted but the final result is. bool crcStatus; uint32_t crcResult, tempResult; DSU_CRCCalculate((uint32_t)(0x30000), 1024, 0xFFFFFFFF, &tempResult); DSU_CRCCalculate((uint32_t)(0x31000), 1024, tempResult, &crcResult); crcResult = ~crcResult;
Remarks
None.