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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by kusanagi, Thu Jul 8 12:48:23 2004 UTC revision 2.0 by kusanagi, Tue Sep 21 20:51:02 2004 UTC
# Line 1  Line 1 
1  #include <stdio.h>  #include <stdio.h>
2  #include "ACcalib.h"  #include "ACcalib.h"
3    
4    // Program to read AC calibration data
5    // 0408 Petter Hofverberg, petter@particle.kth.se
6    
7  int ACcalib(unsigned short* datapointer, struct datastruct* calibpointer)  int ACcalib(int length, unsigned short* datapointer, struct datastruct* calibpointer)
8  {  {
9      int iter=2;
10    
11    //point struc-pointer to calibdata    //point struc-pointer to calibdata
12    *calibpointer=calibdata;      *calibpointer=calibdata;  
13    
14    //look for header 0xACCA    //look for header 0xACCA
15    while(found==0)    while(found==0 && iter<length)
16      {      {
17        tmp1=*datapointer;        tmp1=*datapointer;
18        tmp2=*(datapointer+1);        tmp2=*(datapointer+1);
# Line 23  int ACcalib(unsigned short* datapointer, Line 26  int ACcalib(unsigned short* datapointer,
26              }              }
27            tmp1=0x0000;            tmp1=0x0000;
28          }          }
29        if((tmp1&0x00FF) + (tmp2&0xFF00)==0xACCA)        else if((tmp1&0x00FF) + (tmp2&0xFF00)==0xACCA)
30          {          {
31            found=1;            found=1;
32            for(i=0;i<8256;i++)            for(i=0;i<8256;i++)
# Line 34  int ACcalib(unsigned short* datapointer, Line 37  int ACcalib(unsigned short* datapointer,
37                tmp2=*(datapointer+1);                tmp2=*(datapointer+1);
38              }              }
39          }          }
40          else{
41        datapointer++;        datapointer++;
42          iter=iter+2;}
43      }      }
44    
45    //check tail. CHANGE!    //check errors
46    if(buffer[8253]==0xAC22)    if(iter>=length)
47        err=2;
48      else if(buffer[8254]==0x22AC)
49      err=0;      err=0;
50    else    else
51      err=1;      err=1;
# Line 48  int ACcalib(unsigned short* datapointer, Line 54  int ACcalib(unsigned short* datapointer,
54    calibdata.header=buffer[0];    calibdata.header=buffer[0];
55    for(i=0;i<5;i++) calibdata.status[i]=buffer[1+i];    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];    for(i=0;i<8;i++) calibdata.temp[i]=buffer[6+i];
57    for(i=0;i<16;i++) calibdata.DAC[i]=buffer[14+i];    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];    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];    for(i=0;i<8;i++) calibdata.time[i]=buffer[36+i];
61    calibdata.n_tr=buffer[44];    calibdata.n_tr=buffer[44];
# Line 58  int ACcalib(unsigned short* datapointer, Line 65  int ACcalib(unsigned short* datapointer,
65    calibdata.iCRC=buffer[8253];    calibdata.iCRC=buffer[8253];
66    calibdata.tail=buffer[8254];    calibdata.tail=buffer[8254];
67    calibdata.CRC=buffer[8255];    calibdata.CRC=buffer[8255];
68      
69    /*    /*  
70    //debug    //debug
71    printf("header: %hx\n",calibdata.header);    printf("header: %hx\n",calibdata.header);
72    printf("status: %hx\n",calibdata.status[0]);    printf("status: %hx\n",calibdata.status[0]);
73    printf("temp: %hx\n",calibdata.temp[0]);    printf("temp: %hx\n",calibdata.temp[0]);
74    printf("DAC: %hx\n",calibdata.DAC[0]);    printf("DAC1: %hx\n",calibdata.DAC1[0]);
75      printf("DAC2: %hx\n",calibdata.DAC2[0]);
76    printf("regist: %hx\n",calibdata.regist[0]);    printf("regist: %hx\n",calibdata.regist[0]);
77    printf("time: %hx\n",calibdata.time[0]);    printf("time: %hx\n",calibdata.time[0]);
78    printf("n_tr: %hx\n",calibdata.n_tr);    printf("n_tr: %hx\n",calibdata.n_tr);

Legend:
Removed from v.1.1  
changed lines
  Added in v.2.0

  ViewVC Help
Powered by ViewVC 1.1.23