Subversion Repositories f9daq

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
145 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
}
64
 
65
void _VI_FUNC WUSBXX_close (void)
66
{
67
  if (udev) xxusb_device_close(udev);
68
}
69
 
70
int _VI_FUNC WUSBXX_CCread (int n, int a, int f, unsigned long *data)
71
{
72
    long intbuf[4];  
73
    int ret;
74
    // CAMAC direct read function
75
    intbuf[0]=1;
76
    intbuf[1]=(long)(f+a*32+n*512 + 0x4000);
77
    ret = xxusb_stack_execute(udev, intbuf);
78
    if (f < 16)
79
    {
80
        *data=intbuf[0] + intbuf[1] * 0x10000;   //24-bit word 
81
//      *Q = ((intbuf[1] >> 8) & 1);
82
//      *X = ((intbuf[1] >> 9) & 1);
83
    }  
84
    return ret;
85
}
86
 
87
int _VI_FUNC WUSBXX_CCwrite (int n, int a, int f, unsigned long data)
88
{
89
    long intbuf[4];  
90
    int ret;
91
// CAMAC direct write function
92
    intbuf[0]=1;
93
    intbuf[1]=(long)(f+a*32+n*512 + 0x4000);
94
    if ((f > 15) && (f < 24))
95
    {  
96
        intbuf[0]=3;
97
        intbuf[2]=(data & 0xffff);
98
        intbuf[3]=((data >>16) & 255);
99
        ret = xxusb_stack_execute(udev, intbuf);
100
//      *Q = (intbuf[0] & 1);
101
//      *X = ((intbuf[0] >> 1) & 1);
102
    }  
103
    return ret;
104
}