/[PAMELA software]/yoda/techmodel/forroutines/anticounter/ACcalib.c
ViewVC logotype

Contents of /yoda/techmodel/forroutines/anticounter/ACcalib.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (show annotations) (download)
Wed Aug 25 10:14:28 2004 UTC (20 years, 3 months ago) by kusanagi
Branch: MAIN
CVS Tags: Rev040826
Changes since 1.2: +10 -16 lines
File MIME type: text/plain
*** empty log message ***

1 #include <stdio.h>
2 #include "ACcalib.h"
3
4 // Program to read AC calibration data
5 // 0408 Petter Hofverberg, petter@particle.kth.se
6
7 int ACcalib(int length, unsigned short* datapointer, struct datastruct* calibpointer)
8 {
9 int iter=2;
10
11 //point struc-pointer to calibdata
12 *calibpointer=calibdata;
13
14 //look for header 0xACCA
15 while(found==0 && iter<length)
16 {
17 tmp1=*datapointer;
18 tmp2=*(datapointer+1);
19 if(tmp1==0xCAAC)
20 {
21 found=1;
22 for(i=0;i<8256;i++)
23 {
24 buffer[i]=*datapointer;
25 datapointer++;
26 }
27 tmp1=0x0000;
28 }
29 else if((tmp1&0x00FF) + (tmp2&0xFF00)==0xACCA)
30 {
31 found=1;
32 for(i=0;i<8256;i++)
33 {
34 buffer[i]=(tmp1&0x00FF) + (tmp2&0xFF00);
35 datapointer++;
36 tmp1=tmp2;
37 tmp2=*(datapointer+1);
38 }
39 }
40 else{
41 datapointer++;
42 iter=iter+2;}
43 }
44
45 //check errors
46 if(iter>=length)
47 err=2;
48 else if(buffer[8254]==0x22AC)
49 err=0;
50 else
51 err=1;
52
53 //Fill calibdata from buffer
54 calibdata.header=buffer[0];
55 for(i=0;i<5;i++) calibdata.status[i]=buffer[1+i];
56 for(i=0;i<8;i++) calibdata.temp[i]=buffer[6+i];
57 for(i=0;i<8;i++) calibdata.DAC1[i]=buffer[14+i];
58 for(i=0;i<8;i++) calibdata.DAC2[i]=buffer[22+i];
59 for(i=0;i<6;i++) calibdata.regist[i]=buffer[30+i];
60 for(i=0;i<8;i++) calibdata.time[i]=buffer[36+i];
61 calibdata.n_tr=buffer[44];
62 for(i=0;i<16;i++) calibdata.hitmap_tr[i]=buffer[45+i];
63 for(i=0;i<4096;i++) calibdata.curve1[i]=buffer[61+i];
64 for(i=0;i<4096;i++) calibdata.curve2[i]=buffer[4157+i];
65 calibdata.iCRC=buffer[8253];
66 calibdata.tail=buffer[8254];
67 calibdata.CRC=buffer[8255];
68
69 /*
70 //debug
71 printf("header: %hx\n",calibdata.header);
72 printf("status: %hx\n",calibdata.status[0]);
73 printf("temp: %hx\n",calibdata.temp[0]);
74 printf("DAC1: %hx\n",calibdata.DAC1[0]);
75 printf("DAC2: %hx\n",calibdata.DAC2[0]);
76 printf("regist: %hx\n",calibdata.regist[0]);
77 printf("time: %hx\n",calibdata.time[0]);
78 printf("n_tr: %hx\n",calibdata.n_tr);
79 printf("hitmap_tr: %hx\n",calibdata.hitmap_tr[0]);
80 printf("curve1: %hx\n",calibdata.curve1[0]);
81 printf("curve2: %hx\n",calibdata.curve2[0]);
82 printf("iCRC: %hx\n",calibdata.iCRC);
83 printf("tail: %hx\n",calibdata.tail);
84 printf("CRC: %hx\n",calibdata.CRC);
85 printf("err: %d\n",err);
86 */
87
88 return err;
89 }
90

  ViewVC Help
Powered by ViewVC 1.1.23