#ifndef _CAEN_V1718_H
#define _CAEN_V1718_H
#include <CAENVMElib.h>
extern int32_t udev;
extern int VMEerrors;
int VME_start (char*);
int VME_close (int);
int VME_stop (void);
int VME_reset (void);
int VME_BltRead(long Handle, unsigned long Address, void *Data,int size, CVAddressModifier AM, CVDataWidth DW);
int VME_read(long Handle, unsigned long Address, void *Data, CVAddressModifier AM, CVDataWidth DW);
int VME_write(long Handle, unsigned long Address, void *Data, CVAddressModifier AM, CVDataWidth DW);
int VME_appendread(unsigned long Address, void *Data, CVAddressModifier AM, CVDataWidth DW);
int VME_appendwrite(unsigned long Address, void *Data, CVAddressModifier AM, CVDataWidth DW);
int VME_MultiReadReset( void);
int VME_MultiWriteReset( void);
int VME_MultiReadExecute(long Handle, uint32_t *Data);
int VME_MultiWriteExecute(long Handle);
#define VME_START(NODE) VME_start((NODE))
#define VME_STOP() CAENVME_End(udev)
#define VME_RESET() CAENVME_SystemReset(udev)
#define VME_A16D8_R(VME,DATA) VME_read( udev, (VME), (DATA) , cvA16_U_DATA, cvD8)
#define VME_A16D16_R(VME,DATA) VME_read( udev, (VME), (DATA) , cvA16_U_DATA, cvD16)
#define VME_A16D32_R(VME,DATA) VME_read( udev, (VME), (DATA) , cvA16_U_DATA, cvD32)
#define VME_A24D8_R(VME,DATA) VME_read( udev, (VME), (DATA) , cvA24_U_DATA, cvD8)
#define VME_A24D16_R(VME,DATA) VME_read( udev, (VME), (DATA) , cvA24_U_DATA, cvD16)
#define VME_A24D32_R(VME,DATA) VME_read( udev, (VME), (DATA) , cvA24_U_DATA, cvD32)
#define VME_A32D8_R(VME,DATA) VME_read( udev, (VME), (DATA) , cvA32_U_DATA, cvD8)
#define VME_A32D16_R(VME,DATA) VME_read( udev, (VME), (DATA) , cvA32_U_DATA, cvD16)
#define VME_A32D32_R(VME,DATA) VME_read( udev, (VME), (DATA) , cvA32_U_DATA, cvD32)
#define VME_A16D8_W(VME,DATA) VME_write( udev, (VME), (DATA) , cvA16_U_DATA, cvD8)
#define VME_A16D16_W(VME,DATA) VME_write( udev, (VME), (DATA) , cvA16_U_DATA, cvD16)
#define VME_A16D32_W(VME,DATA) VME_write( udev, (VME), (DATA) , cvA16_U_DATA, cvD32)
#define VME_A24D8_W(VME,DATA) VME_write( udev, (VME), (DATA) , cvA24_U_DATA, cvD8)
#define VME_A24D16_W(VME,DATA) VME_write( udev, (VME), (DATA) , cvA24_U_DATA, cvD16)
#define VME_A24D32_W(VME,DATA) VME_write( udev, (VME), (DATA) , cvA24_U_DATA, cvD32)
#define VME_A32D8_W(VME,DATA) VME_write( udev, (VME), (DATA) , cvA32_U_DATA, cvD8)
#define VME_A32D16_W(VME,DATA) VME_write( udev, (VME), (DATA) , cvA32_U_DATA, cvD16)
#define VME_A32D32_W(VME,DATA) VME_write( udev, (VME), (DATA) , cvA32_U_DATA, cvD32)
#define VME_A16D8_MR(VME,DATA) VME_appendread( (VME), (DATA) , cvA16_U_DATA, cvD8)
#define VME_A16D16_MR(VME,DATA) VME_appendread( (VME), (DATA) , cvA16_U_DATA, cvD16)
#define VME_A16D32_MR(VME,DATA) VME_appendread( (VME), (DATA) , cvA16_U_DATA, cvD32)
#define VME_A24D8_MR(VME,DATA) VME_appendread( (VME), (DATA) , cvA24_U_DATA, cvD8)
#define VME_A24D16_MR(VME,DATA) VME_appendread( (VME), (DATA) , cvA24_U_DATA, cvD16)
#define VME_A24D32_MR(VME,DATA) VME_appendread( (VME), (DATA) , cvA24_U_DATA, cvD32)
#define VME_A32D8_MR(VME,DATA) VME_appendread( (VME), (DATA) , cvA32_U_DATA, cvD8)
#define VME_A32D16_MR(VME,DATA) VME_appendread( (VME), (DATA) , cvA32_U_DATA, cvD16)
#define VME_A32D32_MR(VME,DATA) VME_appendread( (VME), (DATA) , cvA32_U_DATA, cvD32)
#define VME_A16D8_MW(VME,DATA) VME_appendwrite( (VME), (DATA) , cvA16_U_DATA, cvD8)
#define VME_A16D16_MW(VME,DATA) VME_appendwrite( (VME), (DATA) , cvA16_U_DATA, cvD16)
#define VME_A16D32_MW(VME,DATA) VME_appendwrite( (VME), (DATA) , cvA16_U_DATA, cvD32)
#define VME_A24D8_MW(VME,DATA) VME_appendwrite( (VME), (DATA) , cvA24_U_DATA, cvD8)
#define VME_A24D16_MW(VME,DATA) VME_appendwrite( (VME), (DATA) , cvA24_U_DATA, cvD16)
#define VME_A24D32_MW(VME,DATA) VME_appendwrite( (VME), (DATA) , cvA24_U_DATA, cvD32)
#define VME_A32D8_MW(VME,DATA) VME_appendwrite( (VME), (DATA) , cvA32_U_DATA, cvD8)
#define VME_A32D16_MW(VME,DATA) VME_appendwrite( (VME), (DATA) , cvA32_U_DATA, cvD16)
#define VME_A32D32_MW(VME,DATA) VME_appendwrite( (VME), (DATA) , cvA32_U_DATA, cvD32)
#define VME_MWRST() VME_MultiWriteReset()
#define VME_MWEXEC() VME_MultiWriteExecute(udev)
#define VME_MRRST() VME_MultiReadReset()
#define VME_MREXEC(DATA) VME_MultiReadExecute(udev, (DATA) )
#define VME_A32D16BLT_R(VME,DATA,SIZE) VME_BltRead( udev, (VME), (DATA) , (SIZE) , cvA32_U_BLT, cvD16)
#define VME_A24D16BLT_R(VME,DATA,SIZE) VME_BltRead( udev, (VME), (DATA) , (SIZE) , cvA24_U_BLT, cvD16)
#define VME_A32D32BLT_R(VME,DATA,SIZE) VME_BltRead( udev, (VME), (DATA) , (SIZE) , cvA32_U_BLT, cvD32)
#define VME_A24D32BLT_R(VME,DATA,SIZE) VME_BltRead( udev, (VME), (DATA) , (SIZE) , cvA24_U_DATA, cvD32)
#define VME_A24D32BLT_READ(VME,DATA,SIZE,COUNT) CAENVME_BLTReadCycle(udev, (VME), (DATA), (SIZE), cvA24_U_BLT, cvD32 , (COUNT) )
#endif