Subversion Repositories f9daq

Compare Revisions

Regard whitespace Rev 168 → Rev 169

/cvi/instr/SIS3153/sis3153.c
0,0 → 1,103
//==============================================================================
//
// Title: sis3153.c
// Purpose: A short description of the implementation.
//
// Created on: 10.7.2016 at 8:53:29 by Samo Korpar.
// Copyright: . All Rights Reserved.
//
//==============================================================================
 
//==============================================================================
// Include files
 
#include <ansi_c.h>
#include <stdint.h>
//#include <wtypes.h>
#include "sis3153.h"
#include "sis3153w.h"
 
//==============================================================================
// Constants
#define MAX_SIS_DEV 5
//==============================================================================
// Types
 
//==============================================================================
// Static global variables
static unsigned int SISndev;
static SIS3153W_STATUS SISstat;
static struct SIS3153USB_Device_Struct SISdevs[MAX_SIS_DEV];
static HANDLE SIShandle=NULL;
 
//==============================================================================
// Static functions
 
//==============================================================================
// Global variables
 
//==============================================================================
// Global functions
 
/// HIFN What does your function do?
/// HIPAR x/What inputs does your function expect?
/// HIRET What does your function return?
 
int SIS3153_USB_VME_START (char *node)
{
SISstat=FindAll_SIS3153USB_Devices(SISdevs,&SISndev,MAX_SIS_DEV);
printf("SISndev=%d\n",SISndev);
SISstat=Sis3153usb_OpenDriver(&SISdevs[0]);
SIShandle=SISdevs[0].hUsb;
return 0;
}
 
int SIS3153_USB_VME_STOP (void)
{
SISstat=Sis3153usb_CloseDriver(SIShandle);
return 0;
}
 
short __stdcall SIS3153_USB_VME_R(uint16_t AM, uint16_t DW, uint32_t VME_Address, uint32_t *Data)
{
SISstat=sis3153Usb_Vme_Single_Read(SIShandle,VME_Address,AM,DW,Data);
return 0;
}
 
short __stdcall SIS3153_USB_VME_W(uint16_t AM, uint16_t DW, uint32_t VME_Address, uint32_t Data)
{
SISstat=sis3153Usb_Vme_Single_Write(SIShandle,VME_Address,AM,DW,Data);
return 0;
}
 
short __stdcall SIS3153_USB_VME_MWRST(void)
{
return 0;
}
 
short __stdcall SIS3153_USB_VME_MW(uint16_t AM, uint16_t DW, uint32_t VME_Address, uint32_t Data)
{
SISstat=sis3153Usb_Vme_Single_Write(SIShandle,VME_Address,AM,DW,Data);
return 0;
}
 
short __stdcall SIS3153_USB_VME_MWEXEC(void)
{
return 0;
}
 
short __stdcall SIS3153_USB_VME_MRRST(void)
{
return 0;
}
 
short __stdcall SIS3153_USB_VME_MR(uint16_t AM, uint16_t DW, uint32_t VME_Address, uint32_t *Data)
{
SISstat=sis3153Usb_Vme_Single_Read(SIShandle,VME_Address,AM,DW,Data);
return 0;
}
 
short __stdcall SIS3153_USB_VME_MREXEC(uint32_t *Data)
{
return 0;
}
/cvi/instr/SIS3153/sis3153.h
0,0 → 1,53
//==============================================================================
//
// Title: sis3153.h
// Purpose: A short description of the interface.
//
// Created on: 10.7.2016 at 8:53:29 by Samo Korpar.
// Copyright: . All Rights Reserved.
//
//==============================================================================
 
#ifndef __sis3153_H__
#define __sis3153_H__
 
#ifdef __cplusplus
extern "C" {
#endif
 
//==============================================================================
// Include files
 
#include "cvidef.h"
 
//==============================================================================
// Constants
 
//==============================================================================
// Types
 
//==============================================================================
// External variables
 
//==============================================================================
// Global functions
 
int SIS3153_USB_VME_START (char *node);
int SIS3153_USB_VME_STOP (void);
 
short __stdcall SIS3153_USB_VME_R(uint16_t AM, uint16_t DW, uint32_t VME_Address, uint32_t *Data);
short __stdcall SIS3153_USB_VME_W(uint16_t AM, uint16_t DW, uint32_t VME_Address, uint32_t Data);
 
short __stdcall SIS3153_USB_VME_MWRST(void);
short __stdcall SIS3153_USB_VME_MW(uint16_t AM, uint16_t DW, uint32_t VME_Address, uint32_t Data);
short __stdcall SIS3153_USB_VME_MWEXEC(void);
 
short __stdcall SIS3153_USB_VME_MRRST(void);
short __stdcall SIS3153_USB_VME_MR(uint16_t AM, uint16_t DW, uint32_t VME_Address, uint32_t *Data);
short __stdcall SIS3153_USB_VME_MREXEC(uint32_t *Data);
 
#ifdef __cplusplus
}
#endif
 
#endif /* ndef __sis3153_H__ */
/cvi/instr/SIS3153/sis3153w.h
0,0 → 1,101
#ifndef SIS3153W_H_
#define SIS3153W_H_
 
/***************************************************************************/
/* Filename: sis3153w.h */
/* */
/* Funktion: */
/* */
/* Autor: TH */
/* date: 01.07.2013 */
/* last modification: 19.01.2015 */
/* */
/* - 19.01.2015 */
/* add sis3153Usb_read_fx3_phy_info_counters */
/* */
/* ----------------------------------------------------------------------- */
/* */
/* SIS Struck Innovative Systeme GmbH */
/* */
/* Harksheider Str. 102A */
/* 22399 Hamburg */
/* */
/* Tel. +49 (0)40 60 87 305 0 */
/* Fax +49 (0)40 60 87 305 20 */
/* */
/* http://www.struck.de */
/* */
/* © 2015 */
/* */
/***************************************************************************/
 
#ifdef SIS3153W_EXPORTS
#define SIS3153W_API __declspec(dllexport)
#else
#define SIS3153W_API __declspec(dllimport)
#endif
 
#include <windows.h>
 
#include "sis3153wStat.h"
#include "sis3153wType.h"
 
#ifdef __cplusplus
extern "C" {
#endif
 
// device handling
SIS3153W_API SIS3153W_STATUS __cdecl FindAll_SIS3153USB_Devices(struct SIS3153USB_Device_Struct* sis3153usb_Device, UINT *nof_usbdevices, UINT max_usb_device_Number);
SIS3153W_API SIS3153W_STATUS __cdecl Sis3153usb_OpenDriver(struct SIS3153USB_Device_Struct* sis3153usb_Device);
SIS3153W_API SIS3153W_STATUS __cdecl Sis3153usb_CloseDriver(struct SIS3153USB_Device_Struct* sis3153usb_Device);
 
// api information
SIS3153W_API SIS3153W_STATUS __cdecl sis3153Usb_version(PSIS3153W_VERSION version);
SIS3153W_API SIS3153W_STATUS __cdecl sis3153Usb_getLastError(int *err);
 
// local register access
SIS3153W_API SIS3153W_STATUS __cdecl sis3153Usb_Register_Single_Read(HANDLE usbDevice, UINT addr, UINT* data);
SIS3153W_API SIS3153W_STATUS __cdecl sis3153Usb_Register_Single_Write(HANDLE usbDevice, UINT addr, UINT data);
SIS3153W_API SIS3153W_STATUS __cdecl sis3153Usb_Register_Dma_Read(HANDLE usbDevice, UINT addr, UINT *dmabufs, UINT req_nof_data, UINT *got_nof_data);
SIS3153W_API SIS3153W_STATUS __cdecl sis3153Usb_Register_Dma_Write(HANDLE usbDevice, UINT addr, UINT *dmabufs, UINT req_nof_data, UINT *put_nof_data);
 
// remote vme access
SIS3153W_API SIS3153W_STATUS __cdecl sis3153Usb_Vme_Single_Read(HANDLE usbDevice, UINT addr, UINT am, UINT size, UINT *data);
SIS3153W_API SIS3153W_STATUS __cdecl sis3153Usb_Vme_Single_Write(HANDLE usbDevice, UINT addr, UINT am, UINT size, UINT data);
SIS3153W_API SIS3153W_STATUS __cdecl sis3153Usb_Vme_Dma_Read(HANDLE usbDevice, UINT addr, UINT am, UINT size, UINT fifo_mode, UINT *dmabufs, UINT req_nof_data, UINT *got_nof_data);
SIS3153W_API SIS3153W_STATUS __cdecl sis3153Usb_Vme_Dma_Write(HANDLE usbDevice, UINT addr, UINT am, UINT size, UINT fifo_mode, UINT *dmabufs, UINT req_nof_data, UINT *put_nof_data);
 
// remote vme handling
SIS3153W_API SIS3153W_STATUS __cdecl sis3153Usb_VmeSysreset(HANDLE usbDevice);
 
// fpga flash utils
SIS3153W_API SIS3153W_STATUS __cdecl sis3153Usb_flash_fpga_ctrl(HANDLE usbDevice, UCHAR val);
SIS3153W_API SIS3153W_STATUS __cdecl sis3153Usb_flash_cs_ctrl(HANDLE usbDevice, UCHAR val);
SIS3153W_API SIS3153W_STATUS __cdecl sis3153Usb_flash_byte_io(HANDLE usbDevice, UCHAR byteIn, PUCHAR byteOut);
SIS3153W_API SIS3153W_STATUS __cdecl sis3153Usb_flash_read_id(HANDLE usbDevice, PUCHAR id);
SIS3153W_API SIS3153W_STATUS __cdecl sis3153Usb_flash_read_sr(HANDLE usbDevice, PUCHAR sr);
SIS3153W_API SIS3153W_STATUS __cdecl sis3153Usb_flash_write_sr(HANDLE usbDevice, UCHAR sr);
SIS3153W_API SIS3153W_STATUS __cdecl sis3153Usb_flash_write_en(HANDLE usbDevice);
SIS3153W_API SIS3153W_STATUS __cdecl sis3153Usb_flash_write_en_volatile(HANDLE usbDevice);
SIS3153W_API SIS3153W_STATUS __cdecl sis3153Usb_flash_write_dis(HANDLE usbDevice);
SIS3153W_API SIS3153W_STATUS __cdecl sis3153Usb_flash_set_address(HANDLE usbDevice, UINT address);
SIS3153W_API SIS3153W_STATUS __cdecl sis3153Usb_flash_read(HANDLE usbDevice, USHORT len, PUCHAR data);
SIS3153W_API SIS3153W_STATUS __cdecl sis3153Usb_flash_prog_page(HANDLE usbDevice, USHORT len, PUCHAR data);
SIS3153W_API SIS3153W_STATUS __cdecl sis3153Usb_flash_erase_sector(HANDLE usbDevice);
SIS3153W_API SIS3153W_STATUS __cdecl sis3153Usb_flash_erase_block64(HANDLE usbDevice);
 
SIS3153W_API SIS3153W_STATUS __cdecl sis3153Usb_update_firmware(HANDLE usbDevice, PCHAR bin, void(__cdecl *cb)(int percent));
SIS3153W_API SIS3153W_STATUS __cdecl sis3153Usb_program_devinfo(HANDLE usbDevice, USHORT serno);
 
// read FX3 Firmware Version
SIS3153W_API SIS3153W_STATUS __cdecl sis3153Usb_read_fx3_firmware_version(HANDLE usbDevice, UINT *data);
SIS3153W_API SIS3153W_STATUS __cdecl sis3153Usb_cmd_fx3_vme_interface_reset(HANDLE usbDevice);
SIS3153W_API SIS3153W_STATUS __cdecl sis3153Usb_cmd_fx3_fpga_reset(HANDLE usbDevice);
 
SIS3153W_API SIS3153W_STATUS __cdecl sis3153Usb_read_fx3_phy_info_counters(HANDLE usbDevice, USHORT write_data, UINT *read_data);
 
#ifdef __cplusplus
}
#endif
 
#endif // SIS3153W_H_
/cvi/instr/SIS3153/sis3153wStat.h
0,0 → 1,37
#ifndef SIS3153WSTAT_H_
#define SIS3153WSTAT_H_
 
#define API_RETURNCODE_START 0x0
#define API_RETURNCODE_LOCAL 0x100
#define API_RETURNCODE_REMOTE 0x200
 
typedef enum _SIS3153W_STATUS{
// 0: general return codes
Stat3153Success = API_RETURNCODE_START,
Stat3153NullArgument,
Stat3153InvalidDeviceIndex,
Stat3153InvalidArgument,
Stat3153ErrorDeviceOpen,
Stat3153ErrorDeviceHold,
Stat3153ErrorDeviceDownload,
Stat3153ErrorDeviceRun,
Stat3153ErrorDeviceClose,
Stat3153ErrorSetInterface,
Stat3153ErrorDescriptorOpen,
Stat3153ErrorIo,
Stat3153ErrorFileOpen,
Stat3153ErrorFileAlloc,
Stat3153ErrorPromId,
Stat3153ErrorPromTimeout,
Stat3153ErrorVfyAlloc,
Stat3153ErrorVfyFailed,
// 0x100: local side errors
Stat3153InvalidParameter = API_RETURNCODE_LOCAL + 0x10, // starts at 0x110
Stat3153UsbWriteError,
Stat3153UsbReadError,
Stat3153UsbReadLengthError,
// 0x200: remote side errors
Stat3153VmeBerr = API_RETURNCODE_REMOTE + 0x11 // starts at 0x211
}SIS3153W_STATUS;
 
#endif
/cvi/instr/SIS3153/sis3153wType.h
0,0 → 1,24
#ifndef SIS3153WTYPE_H_
#define SIS3153WTYPE_H_
 
// device handle
struct SIS3153USB_Device_Struct{
PVOID hDev;
PVOID hUsb;
PCHAR cDName;
PCHAR readableName;
USHORT idVendor;
USHORT idProduct;
USHORT idSerNo;
USHORT idDriverVersion;
USHORT idFxFirmwareVersion;
USHORT idFpgaFirmwareVersion;
};
 
// version information
typedef struct _SIS3153W_VERSION{
UCHAR SisMajor;
UCHAR SisMinor;
}SIS3153W_VERSION, *PSIS3153W_VERSION;
 
#endif // SIS3153WTYPE_H_