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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3.0 - (hide annotations) (download)
Fri Mar 4 15:54:11 2005 UTC (19 years, 9 months ago) by kusanagi
Branch: MAIN
Changes since 1.1: +0 -0 lines
Error proof version.
Implemented all detectors packets plus all the main telemetries packets.
Missing all the Init and Alarm packets.
Disabled CRC control on VarDump, ArrDump, TabDump for CPU debugging needs
(the data formats seems correct even if CRC get wrong)

1 kusanagi 1.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