CANopenNode
CRC 16 CCITT

Files

file  crc16-ccitt.h
 Calculation of CRC 16 CCITT polynomial.
 

Functions

void crc16_ccitt_single (uint16_t *crc, const uint8_t chr)
 Update crc16_ccitt variable with one data byte. More...
 
uint16_t crc16_ccitt (const uint8_t block[], size_t blockLength, uint16_t crc)
 Calculate CRC sum on block of data. More...
 

Detailed Description

Calculation of CRC 16 CCITT polynomial.

Equation:

x^16 + x^12 + x^5 + 1

Function Documentation

◆ crc16_ccitt_single()

void crc16_ccitt_single ( uint16_t crc,
const uint8_t  chr 
)

Update crc16_ccitt variable with one data byte.

This function updates crc variable for one data byte using crc16 ccitt algorithm.

Parameters
[in,out]crcExternally defined variable for CRC checksum. Before start of new CRC calculation, variable must be initialized (zero for xmodem).
chrOne byte of data

◆ crc16_ccitt()

uint16_t crc16_ccitt ( const uint8_t  block[],
size_t  blockLength,
uint16_t  crc 
)

Calculate CRC sum on block of data.

Parameters
blockPointer to block of data.
blockLengthLength of data in bytes;
crcInitial value (zero for xmodem). If block is split into multiple segments, previous CRC is used as initial.
Returns
Calculated CRC.