Subversion Repositories f9daq

Rev

Rev 307 | Blame | Compare with Previous | Last modification | View Log | RSS feed

#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


#ifdef XXDLL
#include "xxusb_dll.h"
#else
#include "libxxusb.h"
#endif

#define CMD_WRITE 0x000
#define CMD_READ  0x100
#define CMD_A24   0x039
#define CMD_A32   0x009
#define CMD_HM    0x80000
#define CMD_HD    0x20000
#define CMD_MRK   0x2000
#define CMD_DLY   0x8000
#define CMD_BLT   0xFF000000

#define CMD_D16   1
#define CMD_D32   0


#define MAXSTACKSIZE 100000

int WIENER_VMUSB_StackInit();
void WIENER_VMUSB_StackClear();


#define  WIENER_VMUSB_StackReadA24D16( ADDR )        WIENER_VMUSB_StackAppend(CMD_READ | CMD_A24 , CMD_D16 | (ADDR) )
#define  WIENER_VMUSB_StackReadA24D32( ADDR )        WIENER_VMUSB_StackAppend(CMD_READ | CMD_A24 , CMD_D32 | (ADDR) )
#define  WIENER_VMUSB_StackReadA32D16( ADDR )        WIENER_VMUSB_StackAppend(CMD_READ | CMD_A32 , CMD_D16 | (ADDR) )
#define  WIENER_VMUSB_StackReadA32D32( ADDR )        WIENER_VMUSB_StackAppend(CMD_READ | CMD_A32 , CMD_D32 | (ADDR) )

#define  WIENER_VMUSB_StackWriteA24D16( ADDR, DATA)  WIENER_VMUSB_StackAppendData(CMD_WRITE | CMD_A24,CMD_D16 | (ADDR), (DATA))
#define  WIENER_VMUSB_StackWriteA24D32( ADDR, DATA)  WIENER_VMUSB_StackAppendData(CMD_WRITE | CMD_A24,CMD_D32 | (ADDR), (DATA))
#define  WIENER_VMUSB_StackWriteA32D16( ADDR, DATA)  WIENER_VMUSB_StackAppendData(CMD_WRITE | CMD_A32,CMD_D16 | (ADDR), (DATA))
#define  WIENER_VMUSB_StackWriteA32D32( ADDR, DATA)  WIENER_VMUSB_StackAppendData(CMD_WRITE | CMD_A32,CMD_D32 | (ADDR), (DATA))

#define WIENER_VMUSB_StackMarker(MRK) WIENER_VMUSB_StackAppend(CMD_MRK, (MRK))

  int WIENER_VMUSB_StackAppend(int cmd, uint32_t addr);
  int WIENER_VMUSB_StackAppendData(int cmd, uint32_t addr, uint32_t data);

  void WIENER_VMUSB_StackConditionalRead(int am ,int d16d32,uint32_t addr, uint32_t data);
  void WIENER_VMUSB_StackMultiRead(int addr_modifier,int d16d32, uint32_t baseaddr, int n,uint32_t increment);
  void WIENER_VMUSB_StackMultiWrite(int addr_modifier,int d16d32,uint32_t baseaddr, int n, uint32_t increment, uint32_t data);

  int WIENER_VMUSB_StackGetUInt32(int maxn, uint32_t *stack);
    int WIENER_VMUSB_StackGetUInt16(int maxn, uint16_t *stack);  
  void WIENER_VMUSB_StackPrint();

short WIENER_VMUSB_VME_DGG(unsigned short channel, unsigned short trigger,unsigned short output,
                    long delay, unsigned short gate, unsigned short invert, unsigned short latch);
short WIENER_VMUSB_VME_Output_settings( unsigned short channel, unsigned short code, unsigned short invert, unsigned short latch );
short  WIENER_VMUSB_register_write( short RegAddr, long RegData);


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);
extern usb_dev_handle *WUSB_udev;

#define WIENER_VMUSB_VME_START(NODE) WIENER_VMUSB_load(NULL);WIENER_VMUSB_open((NODE));
#define WIENER_VMUSB_VME_STOP() WIENER_VMUSB_close()
//#define VME_RESET() WIENVME_reset()
//#define VME_A24D8_R(VME,DATA) WIENVME_read8(hHandle24, 1, (VME), (DATA))
#define WIENER_VMUSB_VME_A24D16_R(VME,DATA) VME_read_16(WUSB_udev, Std_NoPriv_Data, (VME), (DATA))
#define WIENER_VMUSB_VME_A24D32_R(VME,DATA) VME_read_32(WUSB_udev, Std_NoPriv_Data, (VME), (DATA))
//#define VME_A24D8_W(VME,DATA) WIENVME_write8(hHandle24, 1, (VME), (DATA))
#define WIENER_VMUSB_VME_A24D16_W(VME,DATA) VME_write_16(WUSB_udev, Std_NoPriv_Data, (VME), (DATA))
#define WIENER_VMUSB_VME_A24D32_W(VME,DATA) VME_write_32(WUSB_udev, Std_NoPriv_Data, (VME), (DATA))
//#define VME_A32D8_R(VME,DATA) WIENVME_read8(hHandle32, 1, (VME), (DATA))
#define WIENER_VMUSB_VME_A32D16_R(VME,DATA) VME_read_16(WUSB_udev, Ext_NoPriv_Data, (VME), (DATA))
#define WIENER_VMUSB_VME_A32D32_R(VME,DATA) VME_read_32(WUSB_udev, Ext_NoPriv_Data, (VME), (DATA))
//#define VME_A32D8_W(VME,DATA) WIENVME_write8(hHandle32, 1, (VME), (DATA))
#define WIENER_VMUSB_VME_A32D16_W(VME,DATA) VME_write_16(WUSB_udev, Ext_NoPriv_Data, (VME), (DATA))
#define WIENER_VMUSB_VME_A32D32_W(VME,DATA) VME_write_32(WUSB_udev, Ext_NoPriv_Data, (VME), (DATA))


extern 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_W( uint16_t AM, uint16_t DW, uint32_t VME_Address, uint32_t Data);

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 );

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