 routines for CRC8, CRC16 and CRC32 More... Collaboration diagram for CRC:

file  BCDS_CRC.h

## Macros

#define CRC32_EATH_STD_INIT(x)   (x = (~0UL))

#define CRC32_ETHERNET_REVERSE_POLYNOMIAL   UINT32_C(0xEDB88320)

#define CRC32_INVERSE(x)   (x = x ^ (~0UL))

## Functions

Retcode_T CRC_16 (uint16_t poly, uint16_t *shifter, uint8_t *data_p, uint16_t len)
Calculates CRC16 for a given message, or data, using a a given polynomial and initial value. No frills: no bit-reversing, no final XOR. More...

Retcode_T CRC_32 (uint32_t poly, uint32_t *shifter, uint8_t *data_p, uint16_t len)
Calculates CRC32 for a given message, or data, using a a given polynomial and initial value. No frills: no bit-reversing, no final XOR. More...

Retcode_T CRC_32_Reverse (uint32_t poly, uint32_t *shifter, uint8_t *data_p, uint16_t len)
Calculates CRC32 with reverse polynomial for a given message, or data and initial value. More...

Retcode_T CRC_8 (uint8_t poly, uint8_t *shifter, uint8_t *data_p, uint16_t len)
Calculates CRC8 for a given message, or data, using a a given polynomial and initial value. No frills: no bit-reversing, no final XOR. More...

## Detailed Description

General desciption of how CRC is calculated: source: https://en.wikipedia.org/wiki/Cyclic_redundancy_check (2017-08-14)

2 Shifter set to zero (or initial value)
3  as long as bits remain in data stream:
4  if leftmost bit (that is set to 1) in shifter a is not equal to next bit in data stream
5  shifter := (left shift shifter by one) xor crc polynomial
6  else
7  shifter := (left shift shifter by one)
8  next bit in data stream
9 result in shifter

## Macro Definition Documentation

 #define CRC32_EATH_STD_INIT ( x ) (x = (~0UL))
 #define CRC32_ETHERNET_REVERSE_POLYNOMIAL   UINT32_C(0xEDB88320)

CRC32 polynomial for Ethernet standard IEEE 802.3

 #define CRC32_INVERSE ( x ) (x = x ^ (~0UL))

## Function Documentation

 Retcode_T CRC_16 ( uint16_t poly, uint16_t * shifter, uint8_t * data_p, uint16_t len )
Parameters
 [in] poly - polynomial to be used [in,out] shifter - initial value when called; calculated CRC16 when done [in] data_p - pointer to start of data CRC16 shall be calculated for [in] len - number of octets in data
Return values
 RETCODE_OK when successful RETCODE_FAILURE when any of the input pointers is NULL
 Retcode_T CRC_32 ( uint32_t poly, uint32_t * shifter, uint8_t * data_p, uint16_t len )
Parameters
 [in] poly - polynomial to be used [in,out] shifter - initial value when called; calculated CRC32 when done [in] data_p - pointer to start of data CRC32 shall be calculated for [in] len - number of octets in data
Return values
 RETCODE_OK when successful RETCODE_FAILURE when any of the input pointers is NULL
 Retcode_T CRC_32_Reverse ( uint32_t poly, uint32_t * shifter, uint8_t * data_p, uint16_t len )
Parameters
 [in] poly - polynomial to be used [in,out] shifter - initial value when called; calculated CRC32 when done [in] data_p - pointer to start of data CRC32 shall be calculated for [in] len - number of octets in data
Return values
 RETCODE_OK when successful RETCODE_FAILURE when any of the input pointers is NULL
Note
For the first time shifter value will initialize with 0xFFFFFFFF, Call CRC32_EATH_STD_INIT(shifter) macro for initialize This api won't support final CRC32 inversion, manually to do the final CRC32 inversion in application. Call CRC32_INVERSE(shifter) macro for invert the final CRC32 value. Here is the caller graph for this function:

 Retcode_T CRC_8 ( uint8_t poly, uint8_t * shifter, uint8_t * data_p, uint16_t len )
Parameters
 [in] poly - polynomial to be used [in,out] shifter - initial value when called; calculated CRC8 when done [in] data_p - pointer to start of data CRC8 shall be calculated for [in] len - number of octets in data
Return values
 RETCODE_OK when successful RETCODE_FAILURE when any of the input pointers is NULL

This documentation file has been automatically generated on Wed May 6 2020 20:45:22 by doxygen 1.8.8 