CRC 16 CCITT
CANopen_301

## 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] | crc | Externally defined variable for CRC checksum. Before start of new CRC calculation, variable must be initialized (zero for xmodem).
  | chr | One 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

  block | Pointer to block of data.
  blockLength | Length of data in bytes;
  crc | Initial value (zero for xmodem). If block is split into multiple segments, previous CRC is used as initial.

Returns
  Calculated CRC.