#include <usb.h>
#define XXUSB_WIENER_VENDOR_ID 0x16DC /* Wiener, Plein & Baus */
#define XXUSB_VMUSB_PRODUCT_ID 0x000B /* VM-USB */
#define XXUSB_CCUSB_PRODUCT_ID 0x0001 /* CC-USB */
#define XXUSB_ENDPOINT_OUT 2 /* Endpoint 2 Out*/
#define XXUSB_ENDPOINT_IN 0x86 /* Endpoint 6 In */
#define XXUSB_FIRMWARE_REGISTER 0
#define XXUSB_GLOBAL_REGISTER 1
#define XXUSB_ACTION_REGISTER 10
#define XXUSB_DELAYS_REGISTER 2
#define XXUSB_WATCHDOG_REGISTER 3
#define XXUSB_SELLEDA_REGISTER 6
#define XXUSB_SELNIM_REGISTER 7
#define XXUSB_SELLEDB_REGISTER 4
#define XXUSB_SERIAL_REGISTER 15
#define XXUSB_LAMMASK_REGISTER 8
#define XXUSB_LAM_REGISTER 12
#define XXUSB_READOUT_STACK 2
#define XXUSB_SCALER_STACK 3
#define XXUSB_NAF_DIRECT 12
// dodal 19.4.2011 da dela na 64-bit masinah
typedef unsigned int Uint32_t;
struct XXUSB_STACK
{
Uint32_t Data;
short Hit;
short APatt;
short Num;
short HitMask;
};
struct XXUSB_CC_COMMAND_TYPE
{
short Crate;
short F;
short A;
short N;
Uint32_t Data;
short NoS2;
short LongD;
short HitPatt;
short QStop;
short LAMMode;
short UseHit;
short Repeat;
short AddrScan;
short FastCam;
short NumMod;
short AddrPatt;
Uint32_t HitMask[4];
Uint32_t Num;
};
struct xxusb_device_typ
{
struct usb_device *usbdev;
char SerialString[7];
};
typedef struct xxusb_device_typ xxusb_device_type;
typedef unsigned char UCHAR;
typedef struct usb_bus usb_busx;
int xxusb_longstack_execute(usb_dev_handle *hDev, void *DataBuffer, int lDataLen, int timeout);
int xxusb_bulk_read(usb_dev_handle *hDev, void *DataBuffer, int lDataLen, int timeout);
int xxusb_bulk_write(usb_dev_handle *hDev, void *DataBuffer, int lDataLen, int timeout);
int xxusb_usbfifo_read(usb_dev_handle *hDev, int *DataBuffer, int lDataLen, int timeout);
short xxusb_register_read(usb_dev_handle *hDev, short RegAddr, Uint32_t *RegData);
short xxusb_stack_read(usb_dev_handle *hDev, short StackAddr, Uint32_t *StackData);
short xxusb_stack_write(usb_dev_handle *hDev, short StackAddr, Uint32_t *StackData);
short xxusb_stack_execute(usb_dev_handle *hDev, Uint32_t *StackData);
short xxusb_register_write(usb_dev_handle *hDev, short RegAddr, Uint32_t RegData);
short xxusb_reset_toggle(usb_dev_handle *hDev);
short xxusb_devices_find(xxusb_device_type *xxusbDev);
short xxusb_device_close(usb_dev_handle *hDev);
usb_dev_handle* xxusb_device_open(struct usb_device *dev);
short xxusb_flash_program(usb_dev_handle *hDev, char *config, short nsect);
short xxusb_flashblock_program(usb_dev_handle *hDev, UCHAR *config);
usb_dev_handle* xxusb_serial_open(char *SerialString);
short VME_register_write(usb_dev_handle *hdev, Uint32_t VME_Address, Uint32_t Data);
short VME_register_read(usb_dev_handle *hdev, Uint32_t VME_Address, Uint32_t *Data);
short VME_LED_settings(usb_dev_handle *hdev, int LED, int code, int invert, int latch);
short VME_DGG(usb_dev_handle *hdev, unsigned short channel, unsigned short trigger,unsigned short output, Uint32_t delay, unsigned short gate, unsigned short invert, unsigned short latch);
short VME_Output_settings(usb_dev_handle *hdev, int Channel, int code, int invert, int latch);
short VME_read_16(usb_dev_handle *hdev,short Address_Modifier, Uint32_t VME_Address, Uint32_t *Data);
short VME_read_32(usb_dev_handle *hdev, short Address_Modifier, Uint32_t VME_Address, Uint32_t *Data);
short VME_BLT_read_32(usb_dev_handle *hdev, short Address_Modifier, int count, Uint32_t VME_Address, Uint32_t Data[]);
short VME_write_16(usb_dev_handle *hdev, short Address_Modifier, Uint32_t VME_Address, Uint32_t Data);
short VME_write_32(usb_dev_handle *hdev, short Address_Modifier, Uint32_t VME_Address, Uint32_t Data);
short CAMAC_DGG(usb_dev_handle *hdev, short channel, short trigger, short output, int delay, int gate, short invert, short latch);
short CAMAC_register_read(usb_dev_handle *hdev, int A, Uint32_t *Data);
short CAMAC_register_write(usb_dev_handle *hdev, int A, Uint32_t Data);
short CAMAC_LED_settings(usb_dev_handle *hdev, int LED, int code, int invert, int latch);
short CAMAC_Output_settings(usb_dev_handle *hdev, int Channel, int code, int invert, int latch);
short CAMAC_read_LAM_mask(usb_dev_handle *hdev, Uint32_t *Data);
short CAMAC_write_LAM_mask(usb_dev_handle *hdev, Uint32_t Data);
short CAMAC_write(usb_dev_handle *hdev, int N, int A, int F, Uint32_t Data, int *Q, int *X);
short CAMAC_read(usb_dev_handle *hdev, int N, int A, int F, Uint32_t *Data, int *Q, int *X);
short CAMAC_Z(usb_dev_handle *hdev);
short CAMAC_C(usb_dev_handle *hdev);
short CAMAC_I(usb_dev_handle *hdev, int inhibit);