Back to index

citadel  8.12
Defines | Functions | Variables
crc16.c File Reference
#include "crc16.h"

Go to the source code of this file.

Defines

#define ByteCRC16(v, crc)   (unsigned short)((crc << 8) ^ ccitt_16Table[((crc >> 8) ^ (v)) & 255])

Functions

CRC16 CalcCRC16Words (unsigned int count, short *buffer)
CRC16 CalcCRC16Bytes (unsigned int count, char *buffer)

Variables

const CRC16 ccitt_16Table []

Define Documentation

#define ByteCRC16 (   v,
  crc 
)    (unsigned short)((crc << 8) ^ ccitt_16Table[((crc >> 8) ^ (v)) & 255])

Definition at line 101 of file crc16.c.


Function Documentation

CRC16 CalcCRC16Bytes ( unsigned int  count,
char *  buffer 
)

Definition at line 138 of file crc16.c.

                                                       {

    int crc = 0;

    do {

       int value = *buffer++;
       crc = ByteCRC16(value, crc);
    }
       while (--count);
    return crc;
}

Here is the caller graph for this function:

CRC16 CalcCRC16Words ( unsigned int  count,
short *  buffer 
)

Definition at line 110 of file crc16.c.

                                                        {

    int crc = 0;

    do {

       int value = *buffer++;
#ifdef _BIG_ENDIAN
       crc = ByteCRC16(value >> 8, crc);
       crc = ByteCRC16(value, crc);
#else
       crc = ByteCRC16(value, crc);
       crc = ByteCRC16(value >> 8, crc);
#endif
    }
       while (--count);
    return (CRC16) crc;
}

Variable Documentation

Definition at line 66 of file crc16.c.