Basic Operations of CRC
To initialize the CRC module, call CRC_DRV_Init() function and pass the user configuration data structure to it.
This is example code to configure the CRC driver:
#define INST_CRC1 (0U)
.crcWidth = CRC_BITS_16,
.polynomial = 0x1021U,
.complementChecksum = false
};
.crcWidth = CRC_BITS_16,
.polynomial = 0x1021U,
.complementChecksum = false
};
To configuration and operation CRC module: Function CRC_DRV_Configure() shall be used to write user configuration to CRC hardware module before starting operation by calling CRC_DRV_WriteData(). Finally, using CRC_DRV_GetCrcResult() function to get the result of CRC calculation.
This is example code to Configure and get CRC block:
#define INST_CRC1 (0U)
uint8_t buffer[] = { 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x30 };
uint32_t result;
- To Get result of 32-bit data then call CRC_DRV_GetCrc32() function.
#define INST_CRC1 (0U)
uint32_t seed = 0xFFFFFFFFU;
uint32_t data = 0x12345678U;
uint32_t result;
- To Get result of 16-bit data then call CRC_DRV_GetCrc16() function.
#define INST_CRC1 (0U)
uint32_t seed = 0xFFFFU;
uint16_t data = 0x1234U;
uint32_t result;
- To Get current configuration of the CRC module, just call CRC_DRV_GetConfig() function.
- To Get default configuration of the CRC module, just call CRC_DRV_GetDefaultConfig() function.