/[PAMELA software]/tracker/ground/source/trigger/trigcrc.cpp
ViewVC logotype

Contents of /tracker/ground/source/trigger/trigcrc.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1.1.1 - (show annotations) (download) (vendor branch)
Wed Mar 8 15:00:39 2006 UTC (18 years, 9 months ago) by pam-fi
Branch: MAIN, trk-ground
CVS Tags: R3v02, HEAD
Changes since 1.1: +0 -0 lines
First CVS release of tracker ground software (R3v02) 

1 #include <stdlib.h>
2 #include <stdio.h>
3 #include <string.h>
4
5 #define BLEN 8
6 extern "C"{
7 short crctrig_(short*, short*);
8 }
9 short crctrig_(short *oldCRC, short *newCRC)
10 /* void crctrig_(short *old,short *new) */
11 {
12 union crctrig_data {
13 short word;
14 struct bit_field {
15 unsigned b0:1;
16 unsigned b1:1;
17 unsigned b2:1;
18 unsigned b3:1;
19 unsigned b4:1;
20 unsigned b5:1;
21 unsigned b6:1;
22 unsigned b7:1;
23 } bit;
24 } c,d,r;
25
26 c.word = *oldCRC;
27 d.word = *newCRC;
28 r.word = 0;
29
30 r.bit.b0 = c.bit.b7 ^ c.bit.b6 ^ c.bit.b0 ^
31 d.bit.b0 ^ d.bit.b6 ^ d.bit.b7;
32
33 r.bit.b1 = c.bit.b6 ^ c.bit.b1 ^ c.bit.b0 ^
34 d.bit.b0 ^ d.bit.b1 ^ d.bit.b6;
35
36 r.bit.b2 = c.bit.b6 ^ c.bit.b2 ^ c.bit.b1 ^ c.bit.b0 ^
37 d.bit.b0 ^ d.bit.b1 ^ d.bit.b2 ^ d.bit.b6;
38
39 r.bit.b3 = c.bit.b7 ^ c.bit.b3 ^ c.bit.b2 ^ c.bit.b1 ^
40 d.bit.b1 ^ d.bit.b2 ^ d.bit.b3 ^ d.bit.b7;
41
42 r.bit.b4 = c.bit.b4 ^ c.bit.b3 ^ c.bit.b2 ^
43 d.bit.b2 ^ d.bit.b3 ^ d.bit.b4;
44
45 r.bit.b5 = c.bit.b5 ^ c.bit.b4 ^ c.bit.b3 ^
46 d.bit.b3 ^ d.bit.b4 ^ d.bit.b5;
47
48 r.bit.b6 = c.bit.b6 ^ c.bit.b5 ^ c.bit.b4 ^
49 d.bit.b4 ^ d.bit.b5 ^ d.bit.b6;
50
51 r.bit.b7 = c.bit.b7 ^ c.bit.b6 ^ c.bit.b5 ^
52 d.bit.b5 ^ d.bit.b6 ^ d.bit.b7 ;
53
54 return r.word;
55 /* *old = r.word; */
56 }
57

  ViewVC Help
Powered by ViewVC 1.1.23