CRC16-CCITT

CRC16-CCITT checksum algorithm. More...

Detailed Description

CRC16-CCITT checksum algorithm.

This implementation of CRC16 is based on the CCITT specification using 0x1D0F as a start value. Using a different start value is possible by calling crc16_ccitt_update() with the desired start value instead of crc16_ccitt_calc().

There is a more generalized version in CRC16 (lightweight), that does not utilize a look-up table as this implementation does (and is thus also for more memory efficient). Its caveat however is that it is slower by about factor 8 than this version.

Files

file  crc16_ccitt.h
 

Functions

uint16_t crc16_ccitt_update (uint16_t crc, const unsigned char *buf, size_t len)
 Update CRC16-CCITT. More...
 
uint16_t crc16_ccitt_calc (const unsigned char *buf, size_t len)
 Calculate CRC16-CCITT. More...
 

Function Documentation

◆ crc16_ccitt_calc()

uint16_t crc16_ccitt_calc ( const unsigned char *  buf,
size_t  len 
)

Calculate CRC16-CCITT.

Parameters
[in]bufStart of the memory area to checksum
[in]lenNumber of bytes to checksum
Returns
Checksum of the specified memory area

◆ crc16_ccitt_update()

uint16_t crc16_ccitt_update ( uint16_t  crc,
const unsigned char *  buf,
size_t  len 
)

Update CRC16-CCITT.

Parameters
[in]crcA start value for the CRC calculation, usually the return value of a previous call to crc16_ccitt_calc() or crc16_ccitt_update()
[in]bufStart of the memory area to checksum
[in]lenNumber of bytes to checksum
Returns
Checksum of the specified memory area based on the given start value