/[PAMELA software]/yoda/techmodel/forroutines/tof/tofcrc.cpp
ViewVC logotype

Contents of /yoda/techmodel/forroutines/tof/tofcrc.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4.0 - (show annotations) (download)
Sun Mar 6 04:33:02 2005 UTC (19 years, 9 months ago) by kusanagi
Branch: MAIN
CVS Tags: YODA4_1/00, YODA4_0/04, YODA4_0/03, YODA4_0/02, YODA4_0/01, YODA4_3/02, YODA4_3/00, YODA4_3/01, YODA4_2/01, YODA4_2/00, YODA4_2/03
Branch point for: PreThermistores2
Changes since 3.0: +0 -0 lines
Stable version 4.0 - 6 March 2005 - Maurizio Nagni

1 #include <stdlib.h>
2 #include <stdio.h>
3 #include <string.h>
4
5 #define BLEN 8
6 extern "C"{
7 short crctof_(short*, short*);
8 }
9 short crctof_(short *oldCRC, short *newCRC)
10 /* void crctof_(short *old,short *new) */
11 {
12 union crctof_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