Subversion Repositories f9daq

Rev

Rev 82 | Rev 92 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 82 Rev 88
1
#include "wusbvme_dll.h"
1
#include "wusbvme_dll.h"
2
 
2
 
3
 
3
 
4
usb_dev_handle *WUSB_udev;
4
usb_dev_handle *WUSB_udev;
5
 
5
 
6
static HINSTANCE DLLHandle;
6
static HINSTANCE DLLHandle;
7
 
7
 
8
void _VI_FUNC WIENER_VMUSB_load (char* module_path)
8
void _VI_FUNC WIENER_VMUSB_load (char* module_path)
9
{
9
{
10
  if (module_path == NULL)
10
  if (module_path == NULL)
11
    DLLHandle = LoadLibrary("libxxusb.dll");
11
    DLLHandle = LoadLibrary("libxxusb.dll");
12
   else
12
   else
13
    DLLHandle = LoadLibrary(module_path);
13
    DLLHandle = LoadLibrary(module_path);
14
  if (!DLLHandle) return;
14
  if (!DLLHandle) {
-
 
15
       printf ("\n\nFailed to Open libxxusb.dll \n");  
-
 
16
          return;
15
 
17
  }
16
  if (!(xxusb_register_read_Ptr = (void*) GetProcAddress(DLLHandle,"xxusb_register_read"))) exit(1);
18
  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);
19
  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);
20
  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);
21
  if (!(xxusb_stack_execute_Ptr = (void*) GetProcAddress(DLLHandle,"xxusb_stack_execute"))) exit(1);
20
  if (!(xxusb_longstack_execute_Ptr = (void*) GetProcAddress(DLLHandle,"xxusb_longstack_execute"))) exit(1);
22
  if (!(xxusb_longstack_execute_Ptr = (void*) GetProcAddress(DLLHandle,"xxusb_longstack_execute"))) exit(1);
21
  if (!(xxusb_register_write_Ptr = (void*) GetProcAddress(DLLHandle,"xxusb_register_write"))) exit(1);
23
  if (!(xxusb_register_write_Ptr = (void*) GetProcAddress(DLLHandle,"xxusb_register_write"))) exit(1);
22
  if (!(xxusb_usbfifo_read_Ptr = (void*) GetProcAddress(DLLHandle,"xxusb_usbfifo_read"))) exit(1);
24
  if (!(xxusb_usbfifo_read_Ptr = (void*) GetProcAddress(DLLHandle,"xxusb_usbfifo_read"))) exit(1);
23
  if (!(xxusb_bulk_read_Ptr = (void*) GetProcAddress(DLLHandle,"xxusb_bulk_read"))) exit(1);
25
  if (!(xxusb_bulk_read_Ptr = (void*) GetProcAddress(DLLHandle,"xxusb_bulk_read"))) exit(1);
24
  if (!(xxusb_bulk_write_Ptr = (void*) GetProcAddress(DLLHandle,"xxusb_bulk_write"))) exit(1);
26
  if (!(xxusb_bulk_write_Ptr = (void*) GetProcAddress(DLLHandle,"xxusb_bulk_write"))) exit(1);
25
  if (!(xxusb_reset_toggle_Ptr = (void*) GetProcAddress(DLLHandle,"xxusb_reset_toggle"))) exit(1);
27
  if (!(xxusb_reset_toggle_Ptr = (void*) GetProcAddress(DLLHandle,"xxusb_reset_toggle"))) exit(1);
26
 
28
 
27
  if (!(xxusb_devices_find_Ptr = (void*) GetProcAddress(DLLHandle,"xxusb_devices_find"))) exit(1);
29
  if (!(xxusb_devices_find_Ptr = (void*) GetProcAddress(DLLHandle,"xxusb_devices_find"))) exit(1);
28
  if (!(xxusb_device_close_Ptr = (void*) GetProcAddress(DLLHandle,"xxusb_device_close"))) exit(1);
30
  if (!(xxusb_device_close_Ptr = (void*) GetProcAddress(DLLHandle,"xxusb_device_close"))) exit(1);
29
  if (!(xxusb_device_open_Ptr = (void*) GetProcAddress(DLLHandle,"xxusb_device_open"))) exit(1);
31
  if (!(xxusb_device_open_Ptr = (void*) GetProcAddress(DLLHandle,"xxusb_device_open"))) exit(1);
30
  if (!(xxusb_flash_program_Ptr = (void*) GetProcAddress(DLLHandle,"xxusb_flash_program"))) exit(1);
32
  if (!(xxusb_flash_program_Ptr = (void*) GetProcAddress(DLLHandle,"xxusb_flash_program"))) exit(1);
31
  if (!(xxusb_flashblock_program_Ptr = (void*) GetProcAddress(DLLHandle,"xxusb_flashblock_program"))) exit(1);
33
  if (!(xxusb_flashblock_program_Ptr = (void*) GetProcAddress(DLLHandle,"xxusb_flashblock_program"))) exit(1);
32
  if (!(xxusb_serial_open_Ptr = (void*) GetProcAddress(DLLHandle,"xxusb_serial_open"))) exit(1);
34
  if (!(xxusb_serial_open_Ptr = (void*) GetProcAddress(DLLHandle,"xxusb_serial_open"))) exit(1);
33
  if (!(VME_register_write_Ptr = (void*) GetProcAddress(DLLHandle,"VME_register_write"))) exit(1);
35
  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);
36
  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);
37
  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);
38
  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);
39
  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);
40
  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);
41
  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);
42
  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);
43
  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);
44
  if (!(VME_write_32_Ptr = (void*) GetProcAddress(DLLHandle,"VME_write_32"))) exit(1);
43
}
45
}
44
 
46
 
45
void _VI_FUNC WIENER_VMUSB_open (char *serial)
47
void _VI_FUNC WIENER_VMUSB_open (char *serial)
46
{
48
{
47
       
49
       
48
  xxusb_device_type devices[100];
50
  xxusb_device_type devices[100];
49
  struct usb_device *dev;
51
  struct usb_device *dev;
50
  if (serial != NULL)
52
  if (serial != NULL)
51
        WUSB_udev = xxusb_serial_open(serial);
53
        WUSB_udev = xxusb_serial_open(serial);
52
  else  {
54
  else  {
53
  //Find XX_USB devices and open the first one found
55
  //Find XX_USB devices and open the first one found
54
    xxusb_devices_find(devices);
56
    xxusb_devices_find(devices);
55
    dev = devices[0].usbdev;
57
    dev = devices[0].usbdev;
56
    WUSB_udev = xxusb_device_open(dev);
58
    WUSB_udev = xxusb_device_open(dev);
57
  }  
59
  }  
58
  // Make sure VM_USB opened OK
60
  // Make sure VM_USB opened OK
59
  if(!WUSB_udev) {
61
  if(!WUSB_udev) {
60
    printf ("\n\nFailed to Open VM_USB \n\n");
62
    printf ("\n\nFailed to Open VM_USB \n\n");
61
    return ;
63
    return ;
62
  } else {
64
  } else {
63
    printf("VM-USB Device open.!\n");
65
    printf("VM-USB Device open.!\n");
64
  }  
66
  }  
65
 
67
 
66
 
68
 
67
}
69
}
68
 
70
 
69
void _VI_FUNC WIENER_VMUSB_close (void)
71
void _VI_FUNC WIENER_VMUSB_close (void)
70
{
72
{
71
  if (WUSB_udev) xxusb_device_close(WUSB_udev);
73
  if (WUSB_udev) xxusb_device_close(WUSB_udev);
72
}
74
}
73
 
75
 
74
 
76
 
75
uint16_t fStack[MAXSTACKSIZE];
77
uint16_t fStack[MAXSTACKSIZE];
76
 
78
 
77
 
79
 
78
int WIENER_VMUSB_StackInit(){
80
int WIENER_VMUSB_StackInit(){
79
        fStack[0]=1;
81
        fStack[0]=1;
80
        fStack[1]=0;
82
        fStack[1]=0;
81
   return fStack[0];
83
   return fStack[0];
82
}
84
}
83
 
85
 
84
void WIENER_VMUSB_StackClear(){
86
void WIENER_VMUSB_StackClear(){
85
        WIENER_VMUSB_StackInit();
87
        WIENER_VMUSB_StackInit();
86
}
88
}
87
 
89
 
88
int WIENER_VMUSB_StackGetUInt16(int maxn, uint16_t *stack){
90
int WIENER_VMUSB_StackGetUInt16(int maxn, uint16_t *stack){
89
  int i;
91
  int i;
90
  for (i=0;i< fStack[0]+1;i++){
92
  for (i=0;i< fStack[0]+1;i++){
91
                        if (i<maxn) stack[i]=fStack[i]; else return -1;
93
                        if (i<maxn) stack[i]=fStack[i]; else return -1;
92
  }
94
  }
93
  return fStack[0]+1;
95
  return fStack[0]+1;
94
}
96
}
95
 
97
 
96
int WIENER_VMUSB_StackGetUInt32(int maxn, uint32_t *stack){
98
int WIENER_VMUSB_StackGetUInt32(int maxn, uint32_t *stack){
97
  int i;
99
  int i;
98
  for (i=0;i< fStack[0]+1;i++){
100
  for (i=0;i< fStack[0]+1;i++){
99
                        if (i<maxn) stack[i]=fStack[i]; else return -1;
101
                        if (i<maxn) stack[i]=fStack[i]; else return -1;
100
  }
102
  }
101
  return fStack[0]+1;
103
  return fStack[0]+1;
102
}
104
}
103
 
105
 
104
 
106
 
105
int WIENER_VMUSB_StackAppend(int cmd, uint32_t addr ){
107
int WIENER_VMUSB_StackAppend(int cmd, uint32_t addr ){
106
  int i= fStack[0]+1;
108
  int i= fStack[0]+1;
107
  if (i+4 >= MAXSTACKSIZE) {
109
  if (i+4 >= MAXSTACKSIZE) {
108
    fprintf(stderr,"WIENER_VMUSB_StackAppend Maximum stack size reached! Increase....%d\n", i+4);
110
    fprintf(stderr,"WIENER_VMUSB_StackAppend Maximum stack size reached! Increase....%d\n", i+4);
109
    return -1;
111
    return -1;
110
  }
112
  }
111
  fStack[i]   = (cmd & 0xFFFF);
113
  fStack[i]   = (cmd & 0xFFFF);
112
  fStack[i+1] = (cmd >> 16);
114
  fStack[i+1] = (cmd >> 16);
113
  fStack[i+2] = addr&0xFFFF;
115
  fStack[i+2] = addr&0xFFFF;
114
  fStack[i+3] = (addr >> 16)& 0xFFFF;
116
  fStack[i+3] = (addr >> 16)& 0xFFFF;
115
  fStack[0]+=4;
117
  fStack[0]+=4;
116
  return fStack[0];
118
  return fStack[0];
117
}
119
}
118
 
120
 
119
int WIENER_VMUSB_StackAppendData(int cmd,uint32_t addr ,uint32_t data){
121
int WIENER_VMUSB_StackAppendData(int cmd,uint32_t addr ,uint32_t data){
120
  int i=0;
122
  int i=0;
121
  WIENER_VMUSB_StackAppend( cmd, addr );
123
  WIENER_VMUSB_StackAppend( cmd, addr );
122
  i = fStack[0]+1;
124
  i = fStack[0]+1;
123
  if (i+2 >= MAXSTACKSIZE) {
125
  if (i+2 >= MAXSTACKSIZE) {
124
    fprintf(stderr,"WIENER_VMUSB_StackAppendData Maximum stack size reached! Increase....%d\n", i+4);
126
    fprintf(stderr,"WIENER_VMUSB_StackAppendData Maximum stack size reached! Increase....%d\n", i+4);
125
    return -1;
127
    return -1;
126
  }
128
  }
127
  fStack[i]  =  data & 0xFFFF;
129
  fStack[i]  =  data & 0xFFFF;
128
  fStack[i+1] = (data >> 16)&0xFFFF;
130
  fStack[i+1] = (data >> 16)&0xFFFF;
129
  fStack[0]+=2;
131
  fStack[0]+=2;
130
  return fStack[0];
132
  return fStack[0];
131
}
133
}
132
 
134
 
133
void WIENER_VMUSB_StackConditionalRead(int adr_mod,int d16d32, uint32_t addr,uint32_t bmask){
135
void WIENER_VMUSB_StackConditionalRead(int adr_mod,int d16d32, uint32_t addr,uint32_t bmask){
134
        WIENER_VMUSB_StackAppend(CMD_READ| CMD_HD | adr_mod ,addr);
136
        WIENER_VMUSB_StackAppend(CMD_READ| CMD_HD | adr_mod ,addr);
135
        WIENER_VMUSB_StackAppendData(CMD_READ| CMD_HD | CMD_HM |adr_mod, d16d32 |addr,bmask);
137
        WIENER_VMUSB_StackAppendData(CMD_READ| CMD_HD | CMD_HM |adr_mod, d16d32 |addr,bmask);
136
}
138
}
137
 
139
 
138
void WIENER_VMUSB_StackMultiRead(int adr_mod,int d16d32,uint32_t baseaddr, int n, uint32_t increment){
140
void WIENER_VMUSB_StackMultiRead(int adr_mod,int d16d32,uint32_t baseaddr, int n, uint32_t increment){
139
        int i;
141
        int i;
140
        for (i=0;i<n;i++) WIENER_VMUSB_StackAppend( adr_mod | CMD_READ, d16d32 +baseaddr + i*increment);
142
        for (i=0;i<n;i++) WIENER_VMUSB_StackAppend( adr_mod | CMD_READ, d16d32 +baseaddr + i*increment);
141
}
143
}
142
void WIENER_VMUSB_StackMultiWrite(int adr_mod,int d16d32,uint32_t baseaddr, int n, uint32_t increment, uint32_t data){
144
void WIENER_VMUSB_StackMultiWrite(int adr_mod,int d16d32,uint32_t baseaddr, int n, uint32_t increment, uint32_t data){
143
        int i;
145
        int i;
144
        for (i=0;i<n;i++)  WIENER_VMUSB_StackAppendData( adr_mod | CMD_WRITE,d16d32 + baseaddr+i*increment, data);
146
        for (i=0;i<n;i++)  WIENER_VMUSB_StackAppendData( adr_mod | CMD_WRITE,d16d32 + baseaddr+i*increment, data);
145
}
147
}
146
 
148
 
147
void WIENER_VMUSB_StackPrint(){
149
void WIENER_VMUSB_StackPrint(){
148
   uint32_t i;
150
   uint32_t i;
149
   for (i=0; i < fStack[0]+1;i++) printf("0x%04x\n",fStack[i]);
151
   for (i=0; i < fStack[0]+1;i++) printf("0x%04x\n",fStack[i]);
150
   printf("size of stack %d __________________________________\n",fStack[0]+1);
152
   printf("size of stack %d __________________________________\n",fStack[0]+1);
151
}
153
}
152
 
154
 
153
 
155
 
154
char wusbcc_stack[MAXSTACKSIZE*4];
156
char wusbcc_stack[MAXSTACKSIZE*4];
155
 
157
 
156
 
158
 
157
int _VI_FUNC WUSBXX_stack_execute (usb_dev_handle * dev, char * stack){
159
int _VI_FUNC WUSBXX_stack_execute (usb_dev_handle * dev, char * stack){
158
  int i, nb=0;
160
  int i, nb=0;
159
  if (!dev) return -1;
161
  if (!dev) return -1;
160
  uint16_t * exstack = (uint16_t *) wusbcc_stack;
162
  uint16_t * exstack = (uint16_t *) wusbcc_stack;
161
  exstack[0]=0;
163
  exstack[0]=0;
162
  nb = WIENER_VMUSB_StackGetUInt16(MAXSTACKSIZE, &exstack[1] );
164
  nb = WIENER_VMUSB_StackGetUInt16(MAXSTACKSIZE, &exstack[1] );
163
  //printf("WUSBXX_stack_execute stack size %d ", nb);
165
  //printf("WUSBXX_stack_execute stack size %d ", nb);
164
  //WIENER_VMUSB_StackPrint();
166
  //WIENER_VMUSB_StackPrint();
165
  nb = xxusb_longstack_execute (dev,  exstack, nb, 1000);
167
  nb = xxusb_longstack_execute (dev,  exstack, nb, 1000);
166
 
168
 
167
         
169
         
168
  if (nb<0 ) printf("%s line:%d err=%d %s\n",__FILE__,__LINE__,nb, strerror(-nb) );
170
  if (nb<0 ) printf("%s line:%d err=%d %s\n",__FILE__,__LINE__,nb, strerror(-nb) );
169
  if (stack!=NULL) for ( i=0;i<nb;i++) stack[i]=wusbcc_stack[i];
171
  if (stack!=NULL) for ( i=0;i<nb;i++) stack[i]=wusbcc_stack[i];
170
  return nb/sizeof(uint32_t);
172
  return nb/sizeof(uint32_t);
171
}
173
}
172
 
174
 
173
 
175
 
174
 
176
 
175
#ifndef VME_D32
177
#ifndef VME_D32
176
 
178
 
177
#define VME_D8  0x1
179
#define VME_D8  0x1
178
#define VME_D16 0x2
180
#define VME_D16 0x2
179
#define VME_D32 0x4
181
#define VME_D32 0x4
180
#endif
182
#endif
181
 
183
 
182
 
184
 
183
short __stdcall WIENER_VMUSB_VME_R( uint16_t AM, uint16_t DW,  uint32_t VME_Address, uint32_t *Data){
185
short __stdcall WIENER_VMUSB_VME_R( uint16_t AM, uint16_t DW,  uint32_t VME_Address, uint32_t *Data){
184
        int nb=0;
186
        int nb=0;
185
        if (!WUSB_udev) return -222;
187
        if (!WUSB_udev) return -222;
186
       
188
       
187
    switch (DW){
189
    switch (DW){
188
        case VME_D16: nb=  VME_read_16(WUSB_udev, AM,VME_Address,Data);  break;
190
        case VME_D16: nb=  VME_read_16(WUSB_udev, AM,VME_Address,Data);  break;
189
   case VME_D32: nb=  VME_read_32(WUSB_udev, AM,VME_Address,Data); break;
191
   case VME_D32: nb=  VME_read_32(WUSB_udev, AM,VME_Address,Data); break;
190
   default: return 0;
192
   default: return 0;
191
}
193
}
192
//printf("R 0x%02x 0x%02x 0x%08x %x\n", AM , DW, VME_Address, *Data);
194
//printf("R 0x%02x 0x%02x 0x%08x %x\n", AM , DW, VME_Address, *Data);
193
if (nb<0)  printf("%s %d %d %s\n",__FILE__,__LINE__,nb, strerror(-nb) );
195
if (nb<0)  printf("%s %d %d %s\n",__FILE__,__LINE__,nb, strerror(-nb) );
194
 
196
 
195
return nb;
197
return nb;
196
}
198
}
197
 
199
 
198
short __stdcall WIENER_VMUSB_VME_W( uint16_t AM, uint16_t DW, uint32_t VME_Address, uint32_t Data){
200
short __stdcall WIENER_VMUSB_VME_W( uint16_t AM, uint16_t DW, uint32_t VME_Address, uint32_t Data){
199
        int nb=0;
201
        int nb=0;
200
        if (!WUSB_udev) return -222;
202
        if (!WUSB_udev) return -222;
201
//      printf("W 0x%02x 0x%02x 0x%08x %x\n", AM , DW, VME_Address, Data);
203
//      printf("W 0x%02x 0x%02x 0x%08x %x\n", AM , DW, VME_Address, Data);
202
 switch (DW){
204
 switch (DW){
203
   case VME_D16: nb=    VME_write_16(WUSB_udev, AM,VME_Address,Data); break;
205
   case VME_D16: nb=    VME_write_16(WUSB_udev, AM,VME_Address,Data); break;
204
   case VME_D32: nb=    VME_write_32(WUSB_udev, AM,VME_Address,Data); break;
206
   case VME_D32: nb=    VME_write_32(WUSB_udev, AM,VME_Address,Data); break;
205
   default: return 0;
207
   default: return 0;
206
}
208
}
207
if (nb<0)  printf("%s %d %d %s\n",__FILE__,__LINE__,nb, strerror(-nb) );
209
if (nb<0)  printf("%s %d %d %s\n",__FILE__,__LINE__,nb, strerror(-nb) );
208
 
210
 
209
return nb;
211
return nb;
210
}
212
}
211
 
213
 
212
short __stdcall WIENER_VMUSB_VME_MW( uint16_t AM, uint16_t DW, uint32_t VME_Address, uint32_t Data){
214
short __stdcall WIENER_VMUSB_VME_MW( uint16_t AM, uint16_t DW, uint32_t VME_Address, uint32_t Data){
213
switch (DW){
215
switch (DW){
214
   case VME_D16: return  (short) WIENER_VMUSB_StackAppendData(CMD_WRITE | AM , VME_Address | CMD_D16 , Data);
216
   case VME_D16: return  (short) WIENER_VMUSB_StackAppendData(CMD_WRITE | AM , VME_Address | CMD_D16 , Data);
215
   case VME_D32: return  (short) WIENER_VMUSB_StackAppendData(CMD_WRITE | AM , VME_Address | CMD_D32 , Data);
217
   case VME_D32: return  (short) WIENER_VMUSB_StackAppendData(CMD_WRITE | AM , VME_Address | CMD_D32 , Data);
216
   default: return 0;
218
   default: return 0;
217
}
219
}
218
return 0;
220
return 0;
219
}
221
}
220
short __stdcall WIENER_VMUSB_VME_MWRST( void ){
222
short __stdcall WIENER_VMUSB_VME_MWRST( void ){
221
  WIENER_VMUSB_StackInit();
223
  WIENER_VMUSB_StackInit();
222
return 0;
224
return 0;
223
}
225
}
224
short __stdcall WIENER_VMUSB_VME_MWEXEC( void ){
226
short __stdcall WIENER_VMUSB_VME_MWEXEC( void ){
225
 WUSBXX_stack_execute (WUSB_udev, NULL);
227
 WUSBXX_stack_execute (WUSB_udev, NULL);
226
return 0;
228
return 0;
227
}
229
}
228
 
230
 
229
short __stdcall WIENER_VMUSB_VME_MR( uint16_t AM, uint16_t DW, uint32_t VME_Address, uint32_t *Data){
231
short __stdcall WIENER_VMUSB_VME_MR( uint16_t AM, uint16_t DW, uint32_t VME_Address, uint32_t *Data){
230
switch (DW){
232
switch (DW){
231
   case VME_D16: return  (short) WIENER_VMUSB_StackAppendData(CMD_READ | AM , VME_Address | CMD_D16 , *Data);
233
   case VME_D16: return  (short) WIENER_VMUSB_StackAppendData(CMD_READ | AM , VME_Address | CMD_D16 , *Data);
232
   case VME_D32: return  (short) WIENER_VMUSB_StackAppendData(CMD_READ | AM , VME_Address | CMD_D32 , *Data);
234
   case VME_D32: return  (short) WIENER_VMUSB_StackAppendData(CMD_READ | AM , VME_Address | CMD_D32 , *Data);
233
   default: return 0;
235
   default: return 0;
234
}
236
}
235
return 0;      
237
return 0;      
236
}
238
}
237
short __stdcall WIENER_VMUSB_VME_MRRST( void ){
239
short __stdcall WIENER_VMUSB_VME_MRRST( void ){
238
    WIENER_VMUSB_StackInit();
240
    WIENER_VMUSB_StackInit();
239
return 0;
241
return 0;
240
}
242
}
241
short __stdcall WIENER_VMUSB_VME_MREXEC(  uint32_t *Data  ){
243
short __stdcall WIENER_VMUSB_VME_MREXEC(  uint32_t *Data  ){
242
 WUSBXX_stack_execute (WUSB_udev,(char *) Data);
244
 WUSBXX_stack_execute (WUSB_udev,(char *) Data);
243
return 0;      
245
return 0;      
244
}
246
}
245
 
247