Wirepas SDK
crc.h File Reference

Detailed Description

This implementation follows the "bad CRC16-CCITT" algorithm, as described in http://srecord.sourceforge.net/crc16-ccitt.html.

Definition in file crc.h.

Go to the source code of this file.

Functions

uint16_t Crc_addByte (uint16_t crc, uint8_t byte)
 
uint16_t Crc_fromBuffer (const uint8_t *buf, uint32_t len)
 
uint16_t Crc_fromBuffer32 (const uint32_t *buf, uint32_t len)
 

Data Structures

union  crc_t
 
struct  crc_t.__unnamed__
 

Macros

#define CRC_CCITT_FAST_LUT
 
#define Crc_initValue()   0xffff
 

Function Documentation

◆ Crc_addByte()

uint16_t Crc_addByte ( uint16_t  crc,
uint8_t  byte 
)

Add byte to CRC result

Parameters
crcCumulative result of CRC calculation
byteThe byte to add to the result
Note
90.1 us for 50 bytes -> 1.80 us per byte for CRC_CCITT_FAST_LUT
96.4 us for 50 bytes -> 1.93 us per byte for CRC_CCITT_LEGACY

◆ Crc_fromBuffer()

uint16_t Crc_fromBuffer ( const uint8_t *  buf,
uint32_t  len 
)

Calculate CRC over a buffer

Parameters
bufPointer to a buffer
lenLength of the buffer in bytes
Note
63.8 us for 50 bytes -> 1.28 us per byte for CRC_CCITT_FAST_LUT
92.1 us for 50 bytes -> 1.84 us per byte for CRC_CCITT_LEGACY

◆ Crc_fromBuffer32()

uint16_t Crc_fromBuffer32 ( const uint32_t *  buf,
uint32_t  len 
)

Calculate CRC over a buffer

Parameters
bufPointer to a buffer
lenLength of the buffer in words
Note
Approximately 65% execution time compared to uint8_t version when calculating checksums from ROM contents

Data Structure Documentation

◆ crc_t

union crc_t

Definition at line 27 of file crc.h.

Data Fields
struct crc_t __unnamed__
uint16_t crc

◆ crc_t.__unnamed__

struct crc_t.__unnamed__

Definition at line 29 of file crc.h.

Data Fields
uint8_t lsb
uint8_t msb

Macro Definition Documentation

◆ CRC_CCITT_FAST_LUT

#define CRC_CCITT_FAST_LUT

Fast LUT based algorithm. Original CRC algorithm, ported 1:1 from PIC18F

Definition at line 22 of file crc.h.

◆ Crc_initValue

#define Crc_initValue ( )    0xffff

Startup value for CRC result

Definition at line 40 of file crc.h.