1.29.8.14 DMAC_ChannelCRCSetup Function

C

void DMAC_ChannelCRCSetup( DMAC_CHANNEL channel, DMAC_CRC_SETUP CRCSetup )

Summary

DMA Channel CRC setup and enable function

Description

Sets up the DMA CRC engine for a particular channel and enables it. CRC can be enabled for only one channel at a time.

Application needs to call this API with proper setup parameters every time before starting any DMA transfer. If the CRC engine is enabled and configured in Memory mode, then store the seed to be used by CRC engine in the destination address passed to the DMAC_ChannelTransfer() API.

DMAC_CRCRead() function should be used to read the Generated CRC value.

Parameters

Param Description
DMAC_CHANNEL channel The DMAC channel that should be used for CRC Calculation
DMAC_CRC_SETUP crcSetup parameter holding the crc setup information. it may vary from one device family to another.

Returns

void

Example

Example of this function varies based on device family. Refer to the one which is applicable for the device being used.

#define DMAC_TRANSFER_SIZE 13

const uint8_t srcBuffer[DMAC_TRANSFER_SIZE] = {'1', '2', '3', '4', '5', '6', '7', '8', '9', 0, 0, 0, 0};
uint8_t CACHE_ALIGN dstBuffer[DMAC_TRANSFER_SIZE] = {0};

DMAC_CRC_SETUP crcSetup = {0};

crcSetup.reverse_data_input = true;
crcSetup.polynomial_length = 32;
crcSetup.polynomial = 0x04C11DB7;
crcSetup.non_direct_seed = 0x46AF6449;
crcSetup.reverse_crc_output = true;
crcSetup.final_xor_value = 0xFFFFFFFF;
DMAC_ChannelCRCSetup(DMAC_CHANNEL_0, crcSetup);
DMAC_ChannelTransfer(DMAC_CHANNEL_0, &srcBuffer, DMAC_TRANSFER_SIZE, &dstBuffer, DMAC_TRANSFER_SIZE, DMAC_TRANSFER_SIZE);
#define DMAC_TRANSFER_SIZE 9

const uint8_t srcBuffer[DMAC_TRANSFER_SIZE] = {'1', '2', '3', '4', '5', '6', '7', '8', '9'};
uint8_t CACHE_ALIGN dstBuffer[DMAC_TRANSFER_SIZE] = {0};

DMAC_CRC_SETUP crcSetup = {0};

crcSetup.polynomial_type = DMAC_CRC_TYPE_32;
crcSetup.seed = 0xFFFFFFFF;
DMAC_ChannelCRCSetup(DMAC_CHANNEL_0, crcSetup);
DMAC_ChannelTransfer(DMAC_CHANNEL_0, &srcBuffer, &dstBuffer, DMAC_TRANSFER_SIZE);
#define DMAC_TRANSFER_SIZE 9

const uint8_t srcBuffer[DMAC_TRANSFER_SIZE] = {'1', '2', '3', '4', '5', '6', '7', '8', '9'};
uint8_t CACHE_ALIGN dstBuffer[DMAC_TRANSFER_SIZE] = {0};

DMAC_CRC_SETUP crcSetup = {0};

crcSetup.crc_mode        = DMAC_CRC_MODE_DEFAULT;
crcSetup.polynomial_type = DMAC_CRC_TYPE_32;
crcSetup.seed = 0xFFFFFFFF;
DMAC_ChannelCRCSetup(DMAC_CHANNEL_0, crcSetup);
DMAC_ChannelTransfer(DMAC_CHANNEL_0, &srcBuffer, &dstBuffer, DMAC_TRANSFER_SIZE);

Remarks

  • A non direct seed should be used while setting up the DMA CRC

  • The source buffer used for the DMA transfer should be appended with additional zero bits based on the CRC to be generated as shown in example

  • For 16 Bit CRC - Two bytes of 0's needs to be appended

  • For 32 Bit CRC - Four bytes of 0's needs to be appended

  • Currently LFSR CRC type is only supported