/cvi/instr/WUSBVME_DLL/wusbvme_dll.c |
---|
1,21 → 1,82 |
#ifdef LINUX |
#include <dlfcn.h> |
#define LoadLibrary(x) dlopen( (x), RTLD_NOW ); |
#define GetProcAddress(x,y) dlsym((x),(y)) |
#define __stdcall |
#define UCHAR unsigned char |
#define HINSTANCE void * |
#define _VI_FUNC |
#include <stdlib.h> |
#include <stdio.h> |
#include <stdint.h> |
#include <string.h> |
#endif |
#include "wusbvme_dll.h" |
usb_dev_handle *WUSB_udev; |
static HINSTANCE DLLHandle; |
void _VI_FUNC WIENER_VMUSB_load (char* module_path) |
short __stdcall WIENER_VMUSB_VME_R( uint16_t AM, uint16_t DW, uint32_t VME_Address, uint32_t *Data); |
short __stdcall WIENER_VMUSB_VME_W( uint16_t AM, uint16_t DW, uint32_t VME_Address, uint32_t Data); |
short __stdcall WIENER_VMUSB_VME_MW( uint16_t AM, uint16_t DW, uint32_t VME_Address, uint32_t Data); |
short __stdcall WIENER_VMUSB_VME_MWRST( void ); |
short __stdcall WIENER_VMUSB_VME_MWEXEC( void ); |
short __stdcall WIENER_VMUSB_VME_MR( uint16_t AM, uint16_t DW, uint32_t VME_Address, uint32_t *Data); |
short __stdcall WIENER_VMUSB_VME_MRRST( void ); |
short __stdcall WIENER_VMUSB_VME_MREXEC( uint32_t *Data ); |
short __stdcall xxusb_register_read(usb_dev_handle *hDev, short RegAddr, long *RegData); |
short __stdcall xxusb_stack_read(usb_dev_handle *hDev, short StackAddr, long *StackData); |
short __stdcall xxusb_stack_write(usb_dev_handle *hDev, short StackAddr, long *StackData); |
short __stdcall xxusb_stack_execute(usb_dev_handle *hDev, long *StackData); |
short __stdcall xxusb_longstack_execute(usb_dev_handle *hDev, void *DataBuffer, int lDataLen, int timeout); |
short __stdcall xxusb_register_write(usb_dev_handle *hDev, short RegAddr, long RegData); |
short __stdcall xxusb_usbfifo_read(usb_dev_handle *hDev, long *DataBuffer, short lDataLen, int timeout); |
short __stdcall xxusb_bulk_read(usb_dev_handle *hDev, char *DataBuffer, short lDataLen, int timeout); |
short __stdcall xxusb_bulk_write(usb_dev_handle *hDev, char *DataBuffer, short lDataLen, int timeout); |
short __stdcall xxusb_reset_toggle(usb_dev_handle *hDev); |
short __stdcall xxusb_devices_find(xxusb_device_type *xxusbDev); |
short __stdcall xxusb_device_close(usb_dev_handle *hDev); |
usb_dev_handle* __stdcall xxusb_device_open(struct usb_device *dev); |
short __stdcall xxusb_flash_program(usb_dev_handle *hDev, char *config, short nsect); |
short __stdcall xxusb_flashblock_program(usb_dev_handle *hDev, UCHAR *config); |
usb_dev_handle* __stdcall xxusb_serial_open(char *SerialString); |
short __stdcall VME_register_write(usb_dev_handle *hdev, long VME_Address, long Data); |
short __stdcall VME_register_read(usb_dev_handle *hdev, long VME_Address, long *Data); |
short __stdcall VME_LED_settings(usb_dev_handle *hdev, int LED, int code, int invert, int latch); |
short __stdcall VME_DGG(usb_dev_handle *hdev, unsigned short channel, unsigned short trigger,unsigned short output, long delay, unsigned short gate, unsigned short invert, unsigned short latch); |
short __stdcall VME_Output_settings(usb_dev_handle *hdev, int Channel, int code, int invert, int latch); |
short __stdcall VME_read_16(usb_dev_handle *hdev,short Address_Modifier, long VME_Address, long *Data); |
short __stdcall VME_read_32(usb_dev_handle *hdev, short Address_Modifier, long VME_Address, long *Data); |
short __stdcall VME_BLT_read_32(usb_dev_handle *hdev, short Address_Modifier, int count, long VME_Address, long Data[]); |
short __stdcall VME_write_16(usb_dev_handle *hdev, short Address_Modifier, long VME_Address, long Data); |
short __stdcall VME_write_32(usb_dev_handle *hdev, short Address_Modifier, long VME_Address, long Data); |
void _VI_FUNC WIENER_VMUSB_load (const char* module_path) |
{ |
if (module_path == NULL) |
if (module_path == NULL) { |
DLLHandle = LoadLibrary("libxxusb.dll"); |
else |
} else { |
DLLHandle = LoadLibrary(module_path); |
} |
if (!DLLHandle) { |
printf ("\n\nFailed to Open libxxusb.dll \n"); |
return; |
return; |
} |
if (!(xxusb_register_read_Ptr = (void*) GetProcAddress(DLLHandle,"xxusb_register_read"))) exit(1); |
if (!(xxusb_register_read_Ptr = (void *) GetProcAddress(DLLHandle,"xxusb_register_read"))) exit(1); |
if (!(xxusb_stack_read_Ptr = (void*) GetProcAddress(DLLHandle,"xxusb_stack_read"))) exit(1); |
if (!(xxusb_stack_write_Ptr = (void*) GetProcAddress(DLLHandle,"xxusb_stack_write"))) exit(1); |
if (!(xxusb_stack_execute_Ptr = (void*) GetProcAddress(DLLHandle,"xxusb_stack_execute"))) exit(1); |
44,13 → 105,13 |
if (!(VME_write_32_Ptr = (void*) GetProcAddress(DLLHandle,"VME_write_32"))) exit(1); |
} |
void _VI_FUNC WIENER_VMUSB_open (char *serial) |
void _VI_FUNC WIENER_VMUSB_open (const char *serial) |
{ |
xxusb_device_type devices[100]; |
struct usb_device *dev; |
if (serial != NULL) |
WUSB_udev = xxusb_serial_open(serial); |
WUSB_udev = xxusb_serial_open((char *) serial); |
else { |
//Find XX_USB devices and open the first one found |
xxusb_devices_find(devices); |
189,10 → 250,10 |
if (!WUSB_udev) return -222; |
switch (DW){ |
case VME_D16: nb= VME_read_16(WUSB_udev, AM,VME_Address,Data); break; |
case VME_D32: nb= VME_read_32(WUSB_udev, AM,VME_Address,Data); break; |
default: return 0; |
} |
case VME_D16: nb= VME_read_16(WUSB_udev, AM,VME_Address,(long int *) Data); break; |
case VME_D32: nb= VME_read_32(WUSB_udev, AM,VME_Address,(long int *)Data); break; |
default: return 0; |
} |
//printf("R 0x%02x 0x%02x 0x%08x %x\n", AM , DW, VME_Address, *Data); |
if (nb<0) printf("%s %d %d %s\n",__FILE__,__LINE__,nb, strerror(-nb) ); |
/cvi/instr/WUSBVME_DLL/wusbvme_dll.h |
---|
1,12 → 1,16 |
#ifndef _WUSBVME_DLL_H |
#define _WUSBVME_DLL_H |
#ifdef _CVI_ |
#include <ansi_c.h> |
#include <windows.h> |
#include <cvidef.h> |
#include <ivi.h> |
#include "usb.h" |
#else |
#include "/usr/include/usb.h" |
#endif |
#include "usb.h" |
#include "xxusb_dll.h" |
54,8 → 58,8 |
void WIENER_VMUSB_StackPrint(); |
void _VI_FUNC WIENER_VMUSB_load (char *module_path); |
void _VI_FUNC WIENER_VMUSB_open (char *serial); |
void _VI_FUNC WIENER_VMUSB_load (const char *module_path); |
void _VI_FUNC WIENER_VMUSB_open (const char *serial); |
void _VI_FUNC WIENER_VMUSB_close (void); |
#define WIENER_VMUSB_VME_START(NODE) WIENER_VMUSB_load(NULL);WIENER_VMUSB_open((NODE)); |
75,17 → 79,17 |
#define WIENER_VMUSB_VME_A32D32_W(VME,DATA) VME_write_32(WUSB_udev, Ext_NoPriv_Data, (VME), (DATA)) |
short __stdcall WIENER_VMUSB_VME_R( uint16_t AM, uint16_t DW, uint32_t VME_Address, uint32_t *Data); |
extern short __stdcall WIENER_VMUSB_VME_R( uint16_t AM, uint16_t DW, uint32_t VME_Address, uint32_t *Data); |
short __stdcall WIENER_VMUSB_VME_W( uint16_t AM, uint16_t DW, uint32_t VME_Address, uint32_t Data); |
extern short __stdcall WIENER_VMUSB_VME_W( uint16_t AM, uint16_t DW, uint32_t VME_Address, uint32_t Data); |
short __stdcall WIENER_VMUSB_VME_MW( uint16_t AM, uint16_t DW, uint32_t VME_Address, uint32_t Data); |
short __stdcall WIENER_VMUSB_VME_MWRST( void ); |
short __stdcall WIENER_VMUSB_VME_MWEXEC( void ); |
extern short __stdcall WIENER_VMUSB_VME_MW( uint16_t AM, uint16_t DW, uint32_t VME_Address, uint32_t Data); |
extern short __stdcall WIENER_VMUSB_VME_MWRST( void ); |
extern short __stdcall WIENER_VMUSB_VME_MWEXEC( void ); |
short __stdcall WIENER_VMUSB_VME_MR( uint16_t AM, uint16_t DW, uint32_t VME_Address, uint32_t *Data); |
short __stdcall WIENER_VMUSB_VME_MRRST( void ); |
short __stdcall WIENER_VMUSB_VME_MREXEC( uint32_t *Data ); |
extern short __stdcall WIENER_VMUSB_VME_MR( uint16_t AM, uint16_t DW, uint32_t VME_Address, uint32_t *Data); |
extern short __stdcall WIENER_VMUSB_VME_MRRST( void ); |
extern short __stdcall WIENER_VMUSB_VME_MREXEC( uint32_t *Data ); |
#endif |
/cvi/instr/WUSBVME_DLL/xxusb_dll.h |
---|
54,36 → 54,36 |
#define VME_write_16 (*VME_write_16_Ptr) |
#define VME_write_32 (*VME_write_32_Ptr) |
short __stdcall xxusb_register_read(usb_dev_handle *hDev, short RegAddr, long *RegData); |
short __stdcall xxusb_stack_read(usb_dev_handle *hDev, short StackAddr, long *StackData); |
short __stdcall xxusb_stack_write(usb_dev_handle *hDev, short StackAddr, long *StackData); |
short __stdcall xxusb_stack_execute(usb_dev_handle *hDev, long *StackData); |
short __stdcall xxusb_longstack_execute(usb_dev_handle *hDev, void *DataBuffer, int lDataLen, int timeout); |
short __stdcall xxusb_register_write(usb_dev_handle *hDev, short RegAddr, long RegData); |
short __stdcall xxusb_usbfifo_read(usb_dev_handle *hDev, long *DataBuffer, short lDataLen, int timeout); |
short __stdcall xxusb_bulk_read(usb_dev_handle *hDev, char *DataBuffer, short lDataLen, int timeout); |
short __stdcall xxusb_bulk_write(usb_dev_handle *hDev, char *DataBuffer, short lDataLen, int timeout); |
short __stdcall xxusb_reset_toggle(usb_dev_handle *hDev); |
extern short __stdcall xxusb_register_read(usb_dev_handle *hDev, short RegAddr, long *RegData); |
extern short __stdcall xxusb_stack_read(usb_dev_handle *hDev, short StackAddr, long *StackData); |
extern short __stdcall xxusb_stack_write(usb_dev_handle *hDev, short StackAddr, long *StackData); |
extern short __stdcall xxusb_stack_execute(usb_dev_handle *hDev, long *StackData); |
extern short __stdcall xxusb_longstack_execute(usb_dev_handle *hDev, void *DataBuffer, int lDataLen, int timeout); |
extern short __stdcall xxusb_register_write(usb_dev_handle *hDev, short RegAddr, long RegData); |
extern short __stdcall xxusb_usbfifo_read(usb_dev_handle *hDev, long *DataBuffer, short lDataLen, int timeout); |
extern short __stdcall xxusb_bulk_read(usb_dev_handle *hDev, char *DataBuffer, short lDataLen, int timeout); |
extern short __stdcall xxusb_bulk_write(usb_dev_handle *hDev, char *DataBuffer, short lDataLen, int timeout); |
extern short __stdcall xxusb_reset_toggle(usb_dev_handle *hDev); |
short __stdcall xxusb_devices_find(xxusb_device_type *xxusbDev); |
short __stdcall xxusb_device_close(usb_dev_handle *hDev); |
usb_dev_handle* __stdcall xxusb_device_open(struct usb_device *dev); |
short __stdcall xxusb_flash_program(usb_dev_handle *hDev, char *config, short nsect); |
short __stdcall xxusb_flashblock_program(usb_dev_handle *hDev, UCHAR *config); |
usb_dev_handle* __stdcall xxusb_serial_open(char *SerialString); |
extern short __stdcall xxusb_devices_find(xxusb_device_type *xxusbDev); |
extern short __stdcall xxusb_device_close(usb_dev_handle *hDev); |
extern usb_dev_handle* __stdcall xxusb_device_open(struct usb_device *dev); |
extern short __stdcall xxusb_flash_program(usb_dev_handle *hDev, char *config, short nsect); |
extern short __stdcall xxusb_flashblock_program(usb_dev_handle *hDev, UCHAR *config); |
extern usb_dev_handle* __stdcall xxusb_serial_open(char *SerialString); |
short __stdcall VME_register_write(usb_dev_handle *hdev, long VME_Address, long Data); |
short __stdcall VME_register_read(usb_dev_handle *hdev, long VME_Address, long *Data); |
short __stdcall VME_LED_settings(usb_dev_handle *hdev, int LED, int code, int invert, int latch); |
extern short __stdcall VME_register_write(usb_dev_handle *hdev, long VME_Address, long Data); |
extern short __stdcall VME_register_read(usb_dev_handle *hdev, long VME_Address, long *Data); |
extern short __stdcall VME_LED_settings(usb_dev_handle *hdev, int LED, int code, int invert, int latch); |
short __stdcall VME_DGG(usb_dev_handle *hdev, unsigned short channel, unsigned short trigger,unsigned short output, long delay, unsigned short gate, unsigned short invert, unsigned short latch); |
extern short __stdcall VME_DGG(usb_dev_handle *hdev, unsigned short channel, unsigned short trigger,unsigned short output, long delay, unsigned short gate, unsigned short invert, unsigned short latch); |
short __stdcall VME_Output_settings(usb_dev_handle *hdev, int Channel, int code, int invert, int latch); |
extern short __stdcall VME_Output_settings(usb_dev_handle *hdev, int Channel, int code, int invert, int latch); |
short __stdcall VME_read_16(usb_dev_handle *hdev,short Address_Modifier, long VME_Address, long *Data); |
short __stdcall VME_read_32(usb_dev_handle *hdev, short Address_Modifier, long VME_Address, long *Data); |
short __stdcall VME_BLT_read_32(usb_dev_handle *hdev, short Address_Modifier, int count, long VME_Address, long Data[]); |
short __stdcall VME_write_16(usb_dev_handle *hdev, short Address_Modifier, long VME_Address, long Data); |
short __stdcall VME_write_32(usb_dev_handle *hdev, short Address_Modifier, long VME_Address, long Data); |
extern short __stdcall VME_read_16(usb_dev_handle *hdev,short Address_Modifier, long VME_Address, long *Data); |
extern short __stdcall VME_read_32(usb_dev_handle *hdev, short Address_Modifier, long VME_Address, long *Data); |
extern short __stdcall VME_BLT_read_32(usb_dev_handle *hdev, short Address_Modifier, int count, long VME_Address, long Data[]); |
extern short __stdcall VME_write_16(usb_dev_handle *hdev, short Address_Modifier, long VME_Address, long Data); |
extern short __stdcall VME_write_32(usb_dev_handle *hdev, short Address_Modifier, long VME_Address, long Data); |
#endif |