Rev 100 | Rev 136 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 100 | Rev 125 | ||
---|---|---|---|
Line 63... | Line 63... | ||
63 | short __stdcall VME_BLT_read_32(usb_dev_handle *hdev, short Address_Modifier, int count, long VME_Address, long Data[]); |
63 | short __stdcall VME_BLT_read_32(usb_dev_handle *hdev, short Address_Modifier, int count, long VME_Address, long Data[]); |
64 | short __stdcall VME_write_16(usb_dev_handle *hdev, short Address_Modifier, long VME_Address, long Data); |
64 | short __stdcall VME_write_16(usb_dev_handle *hdev, short Address_Modifier, long VME_Address, long Data); |
65 | short __stdcall VME_write_32(usb_dev_handle *hdev, short Address_Modifier, long VME_Address, long Data); |
65 | short __stdcall VME_write_32(usb_dev_handle *hdev, short Address_Modifier, long VME_Address, long Data); |
66 | 66 | ||
67 | 67 | ||
68 | void _VI_FUNC WIENER_VMUSB_load (const char* module_path) |
68 | void _VI_FUNC WIENER_VMUSB_load (const char* module_path) { |
69 | { |
- | |
70 | if (module_path == NULL) { |
69 | if (module_path == NULL) { |
71 | DLLHandle = LoadLibrary("libxxusb.dll"); |
70 | DLLHandle = LoadLibrary("libxxusb.dll"); |
72 | } else { |
71 | } else { |
73 | DLLHandle = LoadLibrary(module_path); |
72 | DLLHandle = LoadLibrary(module_path); |
74 | } |
73 | } |
Line 103... | Line 102... | ||
103 | if (!(VME_BLT_read_32_Ptr = (void*) GetProcAddress(DLLHandle,"VME_BLT_read_32"))) exit(1); |
102 | if (!(VME_BLT_read_32_Ptr = (void*) GetProcAddress(DLLHandle,"VME_BLT_read_32"))) exit(1); |
104 | if (!(VME_write_16_Ptr = (void*) GetProcAddress(DLLHandle,"VME_write_16"))) exit(1); |
103 | if (!(VME_write_16_Ptr = (void*) GetProcAddress(DLLHandle,"VME_write_16"))) exit(1); |
105 | if (!(VME_write_32_Ptr = (void*) GetProcAddress(DLLHandle,"VME_write_32"))) exit(1); |
104 | if (!(VME_write_32_Ptr = (void*) GetProcAddress(DLLHandle,"VME_write_32"))) exit(1); |
106 | } |
105 | } |
107 | 106 | ||
108 | void _VI_FUNC WIENER_VMUSB_open (const char *serial) |
107 | void _VI_FUNC WIENER_VMUSB_open (const char *serial) { |
109 | { |
- | |
110 | 108 | ||
111 | xxusb_device_type devices[100]; |
109 | xxusb_device_type devices[100]; |
112 | struct usb_device *dev; |
110 | struct usb_device *dev; |
113 | if (serial != NULL) |
111 | if (serial != NULL) |
114 | WUSB_udev = xxusb_serial_open((char *) serial); |
112 | WUSB_udev = xxusb_serial_open((char *) serial); |
Line 127... | Line 125... | ||
127 | } |
125 | } |
128 | 126 | ||
129 | 127 | ||
130 | } |
128 | } |
131 | 129 | ||
132 | void _VI_FUNC WIENER_VMUSB_close (void) |
130 | void _VI_FUNC WIENER_VMUSB_close (void) { |
133 | { |
- | |
134 | if (WUSB_udev) xxusb_device_close(WUSB_udev); |
131 | if (WUSB_udev) xxusb_device_close(WUSB_udev); |
135 | } |
132 | } |
136 | 133 | ||
137 | 134 | ||
138 | uint32_t fStack[MAXSTACKSIZE]; |
135 | uint32_t fStack[MAXSTACKSIZE]; |
Line 150... | Line 147... | ||
150 | 147 | ||
151 | int WIENER_VMUSB_StackGetUInt16(int maxn, uint16_t *stack){ |
148 | int WIENER_VMUSB_StackGetUInt16(int maxn, uint16_t *stack) { |
152 | int i; |
149 | int i; |
153 | uint16_t * u16Stack = (uint16_t *) fStack; |
150 | uint16_t * u16Stack = (uint16_t *) fStack; |
154 | for (i=0;i< fStackSize*2;i++){ |
151 | for (i=0; i< fStackSize*2; i++) { |
155 |
|
152 | if (i<maxn) stack[i]=u16Stack[i]; |
- | 153 | else return -1; |
|
156 | } |
154 | } |
157 | return fStackSize*2; |
155 | return fStackSize*2; |
158 | } |
156 | } |
159 | 157 | ||
160 | int WIENER_VMUSB_StackGetUInt32(int maxn, uint32_t *stack){ |
158 | int WIENER_VMUSB_StackGetUInt32(int maxn, uint32_t *stack) { |
161 | int i; |
159 | int i; |
162 | uint16_t * u16Stack = (uint16_t *) fStack; |
160 | uint16_t * u16Stack = (uint16_t *) fStack; |
163 | for (i=0;i< fStackSize*2;i++){ |
161 | for (i=0; i< fStackSize*2; i++) { |
164 |
|
162 | if (i<maxn) stack[i]=u16Stack[i]; |
- | 163 | else return -1; |
|
165 | } |
164 | } |
166 | return fStackSize*2; |
165 | return fStackSize*2; |
167 | } |
166 | } |
168 | 167 | ||
169 | 168 | ||
Line 248... | Line 247... | ||
248 | short __stdcall WIENER_VMUSB_VME_R( uint16_t AM, uint16_t DW, uint32_t VME_Address, uint32_t *Data){ |
247 | short __stdcall WIENER_VMUSB_VME_R( uint16_t AM, uint16_t DW, uint32_t VME_Address, uint32_t *Data) { |
249 | int nb=0; |
248 | int nb=0; |
250 | if (!WUSB_udev) return -222; |
249 | if (!WUSB_udev) return -222; |
251 | 250 | ||
252 | switch (DW){ |
251 | switch (DW) { |
- | 252 | case VME_D16: |
|
253 |
|
253 | nb= VME_read_16(WUSB_udev, AM,VME_Address,(long int *) Data); |
- | 254 | break; |
|
- | 255 | case VME_D32: |
|
254 |
|
256 | nb= VME_read_32(WUSB_udev, AM,VME_Address,(long int *)Data); |
- | 257 | break; |
|
- | 258 | default: |
|
255 |
|
259 | return 0; |
256 | } |
260 | } |
257 | //printf("R 0x%02x 0x%02x 0x%08x %x\n", AM , DW, VME_Address, *Data); |
261 | //printf("R 0x%02x 0x%02x 0x%08x %x\n", AM , DW, VME_Address, *Data); |
258 | if (nb<0) printf("%s %d %d %s\n",__FILE__,__LINE__,nb, strerror(-nb) ); |
262 | if (nb<0) printf("%s %d %d %s\n",__FILE__,__LINE__,nb, strerror(-nb) ); |
259 | 263 | ||
260 | return nb; |
264 | return nb; |
261 | } |
265 | } |
262 | 266 | ||
263 | short __stdcall WIENER_VMUSB_VME_W( uint16_t AM, uint16_t DW, uint32_t VME_Address, uint32_t Data){ |
267 | short __stdcall WIENER_VMUSB_VME_W( uint16_t AM, uint16_t DW, uint32_t VME_Address, uint32_t Data) { |
264 | int nb=0; |
268 | int nb=0; |
265 | if (!WUSB_udev) return -222; |
269 | if (!WUSB_udev) return -222; |
266 | // printf("W 0x%02x 0x%02x 0x%08x %x\n", AM , DW, VME_Address, Data); |
270 | // printf("W 0x%02x 0x%02x 0x%08x %x\n", AM , DW, VME_Address, Data); |
267 | switch (DW){ |
271 | switch (DW) { |
- | 272 | case VME_D16: |
|
268 |
|
273 | nb= VME_write_16(WUSB_udev, AM,VME_Address,Data); |
- | 274 | break; |
|
- | 275 | case VME_D32: |
|
269 |
|
276 | nb= VME_write_32(WUSB_udev, AM,VME_Address,Data); |
- | 277 | break; |
|
- | 278 | default: |
|
270 |
|
279 | return 0; |
271 | } |
280 | } |
272 | if (nb<0) printf("%s %d %d %s\n",__FILE__,__LINE__,nb, strerror(-nb) ); |
281 | if (nb<0) printf("%s %d %d %s\n",__FILE__,__LINE__,nb, strerror(-nb) ); |
273 | 282 | ||
274 | return nb; |
283 | return nb; |
275 | } |
284 | } |
276 | 285 | ||
277 | short __stdcall WIENER_VMUSB_VME_MW( uint16_t AM, uint16_t DW, uint32_t VME_Address, uint32_t Data){ |
286 | short __stdcall WIENER_VMUSB_VME_MW( uint16_t AM, uint16_t DW, uint32_t VME_Address, uint32_t Data) { |
278 | switch (DW){ |
287 | switch (DW) { |
- | 288 | case VME_D16: |
|
279 |
|
289 | return (short) WIENER_VMUSB_StackAppendData(CMD_WRITE | AM , VME_Address | CMD_D16 , Data); |
- | 290 | case VME_D32: |
|
280 |
|
291 | return (short) WIENER_VMUSB_StackAppendData(CMD_WRITE | AM , VME_Address | CMD_D32 , Data); |
- | 292 | default: |
|
281 |
|
293 | return 0; |
282 | } |
294 | } |
283 | return 0; |
295 | return 0; |
284 | } |
296 | } |
285 | short __stdcall WIENER_VMUSB_VME_MWRST( void ){ |
297 | short __stdcall WIENER_VMUSB_VME_MWRST( void ) { |
286 | WIENER_VMUSB_StackInit(); |
298 | WIENER_VMUSB_StackInit(); |
287 | return 0; |
299 | return 0; |
288 | } |
300 | } |
289 | short __stdcall WIENER_VMUSB_VME_MWEXEC( void ){ |
301 | short __stdcall WIENER_VMUSB_VME_MWEXEC( void ) { |
290 | return WUSBXX_stack_execute (WUSB_udev, NULL); |
302 | return WUSBXX_stack_execute (WUSB_udev, NULL); |
291 | } |
303 | } |
292 | 304 | ||
293 | short __stdcall WIENER_VMUSB_VME_MR( uint16_t AM, uint16_t DW, uint32_t VME_Address, uint32_t *Data){ |
305 | short __stdcall WIENER_VMUSB_VME_MR( uint16_t AM, uint16_t DW, uint32_t VME_Address, uint32_t *Data) { |
294 | switch (DW){ |
306 | switch (DW) { |
- | 307 | case VME_D16: |
|
295 |
|
308 | return (short) WIENER_VMUSB_StackAppend(CMD_READ | AM , VME_Address | CMD_D16 ); |
- | 309 | case VME_D32: |
|
296 |
|
310 | return (short) WIENER_VMUSB_StackAppend(CMD_READ | AM , VME_Address | CMD_D32 ); |
- | 311 | default: |
|
297 |
|
312 | return 0; |
298 | } |
313 | } |
299 | return 0; |
314 | return 0; |
300 | } |
315 | } |
301 | short __stdcall WIENER_VMUSB_VME_MRRST( void ){ |
316 | short __stdcall WIENER_VMUSB_VME_MRRST( void ) { |
302 | WIENER_VMUSB_StackInit(); |
317 | WIENER_VMUSB_StackInit(); |