forked from CMSROMA/VMEDAQ
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathvme_bridge.c
58 lines (47 loc) · 1.16 KB
/
vme_bridge.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include "vme_bridge.h"
#include <unistd.h>
#include "CAENVMElib.h"
#include "CAENVMEtypes.h"
#include "CAENVMEoslib.h"
int bridge_init(int32_t &BHandle) {
int status, caenst;
CVBoardTypes VMEBoard;
short Link, Device;
BHandle = 0;
unsigned int DataShort=0;
VMEBoard = cvV1718;
// VMEBoard = cvV2718;
Device = 0;
Link = 0;
bool debug = false;
if( CAENVME_Init(VMEBoard, Link, Device, &BHandle) != cvSuccess )
{
printf("\n\n Error opening the device\n");
return 0;
}
else{
printf("VME initialized \n");
}
CAENVME_SystemReset(BHandle);
usleep(10000);
status = 1;
caenst = CAENVME_ReadRegister(BHandle, cvStatusReg, &DataShort);
status *= (1-caenst);
if(debug) {
if(status==1){
printf("V1718 Status reg \n Bridge is Controlled = %i, USB speed = %i, ",
(DataShort & 0x2)>>1,(DataShort & 0x8000)>>16);
// int_to_binary((DataShort&0xff));
}
}
return status;
}
int bridge_deinit(int32_t BHandle) {
int caenst, status;
status = 1;
caenst = CAENVME_SystemReset(BHandle);
status *= (1-caenst);
caenst = CAENVME_End(BHandle);
status *= (1-caenst);
return status;
}