crc.h File Reference

Cyclic Redundancy Check 16 (CRC). More...

#include <cfg/compiler.h>

Go to the source code of this file.


Defines

#define UPDCRC16(c, oldcrc)   (crc16tab[((oldcrc) >> 8) ^ ((unsigned char)(c))] ^ ((oldcrc) << 8))
 Compute the updated CRC16 value for one octet (macro version).

Functions

uint16_t updcrc16 (uint8_t c, uint16_t oldcrc)
 Compute the updated CRC16 value for one octet (macro version).
uint16_t crc16 (uint16_t crc, const void *buf, size_t len)
 This function implements the CRC 16 calculation on a buffer.

Variables

const uint16_t crc16tab [256]
 crctab calculated by Mark G.

Detailed Description

Cyclic Redundancy Check 16 (CRC).

Note:
This algorithm is incompatible with the CCITT-CRC16.
This code is based on the article Copyright 1986 Stephen Satchell.

Programmers may incorporate any or all code into their programs, giving proper credit within the source. Publication of the source routines is permitted so long as proper credit is given to Stephen Satchell, Satchell Evaluations and Chuck Forsberg, Omen Technology.

Version:
Id
crc.h 2506 2009-04-15 08:29:07Z duplo
Author:
Bernie Innocenti <bernie@codewiz.org>

Definition in file crc.h.


Define Documentation

#define UPDCRC16 ( c,
oldcrc   )     (crc16tab[((oldcrc) >> 8) ^ ((unsigned char)(c))] ^ ((oldcrc) << 8))

Compute the updated CRC16 value for one octet (macro version).

Note:
This version is only intended for old/broken compilers. Use the inline function in new code.
Parameters:
c New octet (range 0-255)
oldcrc Previous CRC16 value (referenced twice, beware of side effects)

Definition at line 75 of file crc.h.


Function Documentation

uint16_t crc16 ( uint16_t  crc,
const void *  buf,
size_t  len 
)

This function implements the CRC 16 calculation on a buffer.

Parameters:
crc Current CRC16 value.
buf The buffer to perform CRC calculation on.
len The length of the Buffer.
Returns:
The updated CRC16 value.

Definition at line 80 of file crc.c.


Variable Documentation

const uint16_t crc16tab[256]

crctab calculated by Mark G.

Mendel, Network Systems Corporation

Definition at line 45 of file crc.c.