Subversion Repositories f9daq

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
111 f9daq 1
#include "wusbxx_dll.h"
2
 
3
usb_dev_handle *udev;
4
 
5
 
6
 
7
void _VI_FUNC WUSBXX_load (char* module_path)
8
{
9
 
10
  /*
11
  if (module_path == NULL)
12
    DLLHandle = LoadLibrary("libxxusb.dll");
13
   else
14
    DLLHandle = LoadLibrary(module_path);
15
 
16
  if (!(xxusb_register_read_Ptr = (void*) GetProcAddress(DLLHandle,"xxusb_register_read"))) exit(1);
17
  if (!(xxusb_stack_read_Ptr = (void*) GetProcAddress(DLLHandle,"xxusb_stack_read"))) exit(1);
18
  if (!(xxusb_stack_write_Ptr = (void*) GetProcAddress(DLLHandle,"xxusb_stack_write"))) exit(1);
19
  if (!(xxusb_stack_execute_Ptr = (void*) GetProcAddress(DLLHandle,"xxusb_stack_execute"))) exit(1);
20
  if (!(xxusb_register_write_Ptr = (void*) GetProcAddress(DLLHandle,"xxusb_register_write"))) exit(1);
21
  if (!(xxusb_usbfifo_read_Ptr = (void*) GetProcAddress(DLLHandle,"xxusb_usbfifo_read"))) exit(1);
22
  if (!(xxusb_bulk_read_Ptr = (void*) GetProcAddress(DLLHandle,"xxusb_bulk_read"))) exit(1);
23
  if (!(xxusb_bulk_write_Ptr = (void*) GetProcAddress(DLLHandle,"xxusb_bulk_write"))) exit(1);
24
  if (!(xxusb_reset_toggle_Ptr = (void*) GetProcAddress(DLLHandle,"xxusb_reset_toggle"))) exit(1);
25
 
26
  if (!(xxusb_devices_find_Ptr = (void*) GetProcAddress(DLLHandle,"xxusb_devices_find"))) exit(1);
27
  if (!(xxusb_device_close_Ptr = (void*) GetProcAddress(DLLHandle,"xxusb_device_close"))) exit(1);
28
  if (!(xxusb_device_open_Ptr = (void*) GetProcAddress(DLLHandle,"xxusb_device_open"))) exit(1);
29
  if (!(xxusb_flash_program_Ptr = (void*) GetProcAddress(DLLHandle,"xxusb_flash_program"))) exit(1);
30
  if (!(xxusb_flashblock_program_Ptr = (void*) GetProcAddress(DLLHandle,"xxusb_flashblock_program"))) exit(1);
31
  if (!(xxusb_serial_open_Ptr = (void*) GetProcAddress(DLLHandle,"xxusb_serial_open"))) exit(1);
32
 
33
  if (!(VME_register_write_Ptr = (void*) GetProcAddress(DLLHandle,"VME_register_write"))) exit(1);
34
  if (!(VME_register_read_Ptr = (void*) GetProcAddress(DLLHandle,"VME_register_read"))) exit(1);
35
  if (!(VME_LED_settings_Ptr = (void*) GetProcAddress(DLLHandle,"VME_LED_settings"))) exit(1);
36
  if (!(VME_DGG_Ptr = (void*) GetProcAddress(DLLHandle,"VME_DGG"))) exit(1);
37
  if (!(VME_Output_settings_Ptr = (void*) GetProcAddress(DLLHandle,"VME_Output_settings"))) exit(1);
38
  if (!(VME_read_16_Ptr = (void*) GetProcAddress(DLLHandle,"VME_read_16"))) exit(1);
39
  if (!(VME_read_32_Ptr = (void*) GetProcAddress(DLLHandle,"VME_read_32"))) exit(1);
40
  if (!(VME_BLT_read_32_Ptr = (void*) GetProcAddress(DLLHandle,"VME_BLT_read_32"))) exit(1);
41
  if (!(VME_write_16_Ptr = (void*) GetProcAddress(DLLHandle,"VME_write_16"))) exit(1);
42
  if (!(VME_write_32_Ptr = (void*) GetProcAddress(DLLHandle,"VME_write_32"))) exit(1);
43
 
44
  if (!(CAMAC_DGG_Ptr = (void*) GetProcAddress(DLLHandle,"CAMAC_DGG"))) exit(1);
45
  if (!(CAMAC_register_read_Ptr = (void*) GetProcAddress(DLLHandle,"CAMAC_register_read"))) exit(1);
46
  if (!(CAMAC_register_write_Ptr = (void*) GetProcAddress(DLLHandle,"CAMAC_register_write"))) exit(1);
47
  if (!(CAMAC_LED_settings_Ptr = (void*) GetProcAddress(DLLHandle,"CAMAC_LED_settings"))) exit(1);
48
  if (!(CAMAC_Output_settings_Ptr = (void*) GetProcAddress(DLLHandle,"CAMAC_Output_settings"))) exit(1);
49
  if (!(CAMAC_read_LAM_mask_Ptr = (void*) GetProcAddress(DLLHandle,"CAMAC_read_LAM_mask"))) exit(1);
50
  if (!(CAMAC_write_LAM_mask_Ptr = (void*) GetProcAddress(DLLHandle,"CAMAC_write_LAM_mask"))) exit(1);
51
  if (!(CAMAC_write_Ptr = (void*) GetProcAddress(DLLHandle,"CAMAC_write"))) exit(1);
52
  if (!(CAMAC_read_Ptr = (void*) GetProcAddress(DLLHandle,"CAMAC_read"))) exit(1);
53
  if (!(CAMAC_Z_Ptr = (void*) GetProcAddress(DLLHandle,"CAMAC_Z"))) exit(1);
54
  if (!(CAMAC_C_Ptr = (void*) GetProcAddress(DLLHandle,"CAMAC_C"))) exit(1);
55
  if (!(CAMAC_I_Ptr = (void*) GetProcAddress(DLLHandle,"CAMAC_I"))) exit(1);
56
*/
57
}
58
 
59
void _VI_FUNC WUSBXX_open (char *serial)
60
{
61
  if (serial != NULL)
62
        udev = xxusb_serial_open(serial);
63
  if (udev == NULL) printf("Cannot open device WUSBXX_open\n");
64
}
65
 
66
void _VI_FUNC WUSBXX_close (void)
67
{
68
  if (udev) xxusb_device_close(udev);
69
}
70
 
71
int _VI_FUNC WUSBXX_CCread (int n, int a, int f, unsigned long *data)
72
{
73
    long intbuf[4];  
74
    int ret;
75
    // CAMAC direct read function
76
    intbuf[0]=1;
77
    intbuf[1]=(long)(f+a*32+n*512 + 0x4000);
78
    ret = xxusb_stack_execute(udev, intbuf);
79
    if (f < 16)
80
    {
81
        *data=intbuf[0] + intbuf[1] * 0x10000;   //24-bit word 
82
//      *Q = ((intbuf[1] >> 8) & 1);
83
//      *X = ((intbuf[1] >> 9) & 1);
84
    }  
85
    return ret;
86
}
87
 
88
int _VI_FUNC WUSBXX_CCwrite (int n, int a, int f, unsigned long data)
89
{
90
    long intbuf[4];  
91
    int ret;
92
// CAMAC direct write function
93
    intbuf[0]=1;
94
    intbuf[1]=(long)(f+a*32+n*512 + 0x4000);
95
    if ((f > 15) && (f < 24))
96
    {  
97
        intbuf[0]=3;
98
        intbuf[2]=(data & 0xffff);
99
        intbuf[3]=((data >>16) & 255);
100
        ret = xxusb_stack_execute(udev, intbuf);
101
//      *Q = (intbuf[0] & 1);
102
//      *X = ((intbuf[0] >> 1) & 1);
103
    }  
104
    return ret;
105
}