Subversion Repositories f9daq

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
187 f9daq 1
#include <ansi_c.h>
2
#include "CAENV830.h"
3
#include "CAENV830_DEF.h"
4
 
5
#ifdef SISVME
6
#include "sisvme_dll.h"
7
#endif
8
#ifdef WIENVME
9
#include "wienvme_dll.h"
10
#endif
11
 
12
static unsigned long ModuleAddress[10];
13
 
14
 
15
int _VI_FUNC V830_map (int ModuleNumber, unsigned long ModuleOffset, int print)
16
{
17
  unsigned short geo, fw;
18
  unsigned short boardid1, boardid2, boardid3;
19
  unsigned short serial1, serial2 ;
20
 
21
  ModuleAddress[ModuleNumber] = ModuleOffset;
22
  VME_A24D16_R(ModuleAddress[ModuleNumber] + CAENV830_FW, &fw);
23
  geo=0;
24
  VME_A24D16_R(ModuleAddress[ModuleNumber] + CAENV830_GEO, &geo);
25
  VME_A24D16_R(ModuleAddress[ModuleNumber] + 0x4000 + 0x8036 ,&boardid1 ) ;
26
  VME_A24D16_R(ModuleAddress[ModuleNumber] + 0x4000 + 0x803A,&boardid2 ) ;
27
  VME_A24D16_R(ModuleAddress[ModuleNumber] + 0x4000 + 0x803E,&boardid3 ) ;
28
  VME_A24D16_R(ModuleAddress[ModuleNumber] + 0x4000 + 0x8F02, &serial1 ) ;
29
  VME_A24D16_R(ModuleAddress[ModuleNumber] + 0x4000 + 0x8F06, &serial2 ) ;
30
  if (print) {
31
    printf("firmware = %d.%d\n", (fw>>4)&0xF, fw&0xF);
32
    printf("geo      = %d,%d,%d,%d,%d\n",
33
            geo>>4&0x1,geo>>3&0x1,geo>>2&0x1,geo>>1&0x1,geo&0x1 );
34
 
35
    printf ( "board ID: 0x%02X%02X%02X\n",
36
              boardid1&0xFF,boardid2&0xFF,boardid3&0xFF) ;
37
    printf ( "serial #: 0x%02X%02X\n",
38
              serial1&0xFF,serial2&0xFF) ;
39
  }
40
  return 0;
41
}
42
 
43
 
44
int _VI_FUNC V830_init (int ModuleNumber)
45
{
46
  unsigned short dum16;
47
  unsigned int dum32;
48
  dum16=0xFFFF;
49
  VME_A24D16_W(ModuleAddress[ModuleNumber] + 0x1120, &dum16); // module reset
50
  VME_A24D16_W(ModuleAddress[ModuleNumber] + 0x1122,  &dum16); // software clear
51
 
52
  dum16=0;     
53
  VME_A24D16_W(ModuleAddress[ModuleNumber] + 0x1108, &dum16) ;  // auto reset,beer|periodic trigger
54
                                                          // 1001|0010
55
 
56
  dum32= 2500000;                                                      
57
  VME_A24D32_W(ModuleAddress[ModuleNumber] + 0x1104, &dum32) ; // period=2.5M*400ns
58
 
59
  dum32=0xFFFFFFFF;
60
  VME_A24D32_W(ModuleAddress[ModuleNumber] + 0x1100, &dum32) ; //enable all channels
61
 
62
  printf ( "Module %d initialized!\n", ModuleNumber ) ;
63
  return 0;
64
}
65
 
66
int _VI_FUNC V830_clear (int ModuleNumber)
67
{
68
  unsigned short dum16=0xFFFF;
69
  VME_A24D16_W(ModuleAddress[ModuleNumber] + 0x1122,&dum16); // software clear
70
 
71
  return 0;
72
 
73
}
74
 
75
 
76
int _VI_FUNC V830_status (int ModuleNumber)
77
{
78
 
79
 int status=0; 
80
 VME_A24D16_W(ModuleAddress[ModuleNumber] + 0x110E, &status); //status reg.
81
 return status;
82
}
83
 
84
 
85
 
86
int _VI_FUNC V830_read (int ModuleNumber, unsigned long whereto[])
87
{
88
  int status, ndata;
89
  int i ;
90
 
91
  ndata = 0;
92
 
93
//  status = V830_status ( ModuleNumber ) ;
94
//  if (!(status & 0x1)) return 0; //ce ni dredy
95
 
96
  for ( i=32; --i>0; ) {
97
   VME_A24D32_R(ModuleAddress[ModuleNumber] + 0x1000 + i*0x4, &whereto[i] ) ;
98
    //printf ( "%2d - %d\n", i, whereto[i] ) ;
99
  }
100
//  V830_init ( ModuleNumber ) ;
101
 
102
  return 32;  
103
 
104
}
105