Main Page | Class List | File List | Class Members | File Members

crc16.c File Reference

#include <stdio.h>

Go to the source code of this file.

Defines

#define GP   0x11021
#define DI   0x1021

Functions

void init_crc16 ()
void crc16 (short *crc, unsigned char m)

Variables

short crc16_table [256]
int made_table = 0


Define Documentation

#define DI   0x1021
 

Definition at line 12 of file crc16.c.

Referenced by init_crc16(), and init_crc8().

#define GP   0x11021
 

Definition at line 11 of file crc16.c.


Function Documentation

void crc16 short *  crc,
unsigned char  m
 

Definition at line 38 of file crc16.c.

References crc16_table, and init_crc16().

Referenced by get_al_pdu(), and send_closing_flag().

00043 {
00044   if (!made_table)
00045     init_crc16();
00046   *crc = crc16_table[(((*crc) >> 8) ^ m) & 0xFF] ^ ((*crc) << 8);
00047   *crc &= 0xFFFF;
00048 }

void init_crc16  )  [static]
 

Definition at line 18 of file crc16.c.

References crc16_table, DI, and made_table.

Referenced by crc16().

00022 {
00023   int i,j;
00024   short crc;
00025     
00026   if (!made_table) {
00027     for (i=0; i<256; i++) {
00028       crc = (i << 8);
00029       for (j=0; j<8; j++)
00030         crc = (crc << 1) ^ ((crc & 0x8000) ? DI : 0);
00031       crc16_table[i] = crc & 0xFFFF;
00032     }
00033     made_table=1;
00034   }
00035 }


Variable Documentation

short crc16_table[256] [static]
 

Definition at line 15 of file crc16.c.

Referenced by crc16(), and init_crc16().

int made_table = 0 [static]
 

Definition at line 16 of file crc16.c.

Referenced by init_crc16().


Generated on Sun Jul 16 16:27:45 2006 by  doxygen 1.3.9.1