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

crc4.h File Reference

#include "standard.h"
#include "bits.h"

Go to the source code of this file.

Functions

unsigned int makecrc4 (unsigned int b)
int checkcrc4 (unsigned int b)


Function Documentation

int checkcrc4 unsigned int  b  ) 
 

Definition at line 33 of file crc4.c.

References GENPOLY, and getbitint().

00039 {
00040   int i;
00041         
00042   i=1;
00043   while (b>=16) { /* >= than 2^4, so degree(b) >= degree(genpoly) */
00044   if (getbitint(b,i) == 1)
00045     b ^= GENPOLY << (12-i); /* reduce with GENPOLY */
00046   i++;
00047   }
00048 /*  printf("b: %d\n",b); */
00049   return (b==0);
00050 }

unsigned int makecrc4 unsigned int  b  ) 
 

Definition at line 14 of file crc4.c.

References GENPOLY, and getbitint().

Referenced by make_backward_control(), and make_forward_control().

00021 {
00022   int i;
00023         
00024   i=1;
00025   while (b>=16) { /* >= 2^4, so degree(b) >= degree(genpoly) */
00026     if (getbitint(b,i) == 1)
00027       b ^= GENPOLY << (12-i); /* reduce with GENPOLY */
00028     i++;
00029   }
00030   return b;
00031 }


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