SLAU131V October 2004 – February 2020
/*****************************************************************************/
/* crc_tbl.h v##### */
/* Copyright (c) 2010@%%%% Texas Instruments Incorporated */
/* */
/* Specification of CRC table data structures which can be automatically */
/* generated by the linker (using the crc_table() operator in the linker */
/* command file). */
/*****************************************************************************/
/*****************************************************************************/
/* */
/* The CRC generator used by the linker is based on concepts from the */
/* document: */
/* "A Painless Guide to CRC Error Detection Algorithms" */
/* */
/* Author : Ross Williams (ross@guest.adelaide.edu.au.). */
/* Date : 3 June 1993. */
/* Status : Public domain (C code). */
/* */
/* Description : For more information on the Rocksoft^tm Model CRC */
/* Algorithm, see the document titled "A Painless Guide to CRC Error */
/* Detection Algorithms" by Ross Williams (ross@guest.adelaide.edu.au.). */
/* This document is likely to be in "ftp.adelaide.edu.au/pub/rocksoft" or */
/* at http:www.ross.net/crc/download/crc_v3.txt. */
/* */
/* Note: Rocksoft is a trademark of Rocksoft Pty Ltd, Adelaide, Australia. */
/*****************************************************************************/
#include <stdint.h> /* For uintXX_t */
/*****************************************************************************/
/* CRC Algorithm Specifiers */
/* */
/* The following specifications, based on the above cited document, are used */
/* by the linker to generate CRC values. */
/* */
/* */
/* ID Name Order Polynomial Initial Ref Ref CRC XOR Zero */
/* Value In Out Value Pad */
/*-------------------------------------------------------------------------- */
/* 0, "CRC32_PRIME", 32, 0x04c11db7, 0x00000000, 0, 0, 0x00000000, 1 */
/* 1, "CRC16_802_15_4", 16, 0x00001021, 0x00000000, 0, 0, 0x00000000, 1 */
/* 2, "CRC16_ALT", 16, 0x00008005, 0x00000000, 0, 0, 0x00000000, 1 */
/* 3, "CRC8_PRIME", 8, 0x00000007, 0x00000000, 0, 0, 0x00000000, 1 */
/* 11,"CRC32", 32, 0x1edc6f41, 0x00000000, 0, 0, 0x00000000, 1 */
/* */
/* Users should specify the name, such as CRC32_PRIME, in the linker command */
/* file. The resulting CRC_RECORD structure will contain the corresponding */
/* ID value in the crc_alg_ID field. The ID needs to match the enum value */
/* CRC_CONFIG_TYPE in crc.h, which is the index into the crc_configs_m table.*/
/*****************************************************************************/
#define CRC32_PRIME 0 /* Poly = 0x04c11db7 */
#define CRC16_802_15_4 1 /* Poly = 0x00001021 */ /* DEFAULT ALGORITHM */
#define CRC16_ALT 2 /* Poly = 0x00008005 */
#define CRC8_PRIME 3 /* Poly = 0x00000007 */
#define CRC32_C 11 /* Poly = 0x1edc6f41 */
#define CRC_CCITT CRC16_802_15_4
#define CRC32_ISO3309 CRC32_PRIME
/****************************************************************************/
/* CRC Record Data Structure */
/* NOTE: The list of fields and the size of each field varies by target */
/* and memory model. */
/****************************************************************************/
typedef struct crc_record
{
uint32_t crc_value;
uint16_t crc_alg_ID; /* CRC algorithm ID */
uintptr_t addr; /* Starting address */
#if defined(__LARGE_CODE_MODEL__) || defined(__LARGE_DATA_MODEL__)
uint32_t size; /* size of data in 8-bit addressable units */
#else
uint16_t size; /* size of data in 8-bit addressable units */
#endif
} CRC_RECORD;
/**********************************************************/
/* CRC Table Data Structure */
/**********************************************************/
typedef struct crc_table
{
uint16_t rec_size; /* 8-bit addressable units */
uint16_t num_recs;
CRC_RECORD recs[1];
} CRC_TABLE;
In the CRC_TABLE struct, the array recs[1] is dynamically sized by the linker to accommodate the number of records contained in the table (num_recs). A user-supplied routine to verify CRC values should take a table name and check the CRC values for all entries in the table. An outline of such a routine is shown in Section C.