// SPdbUSBmDLL.h
/////////////////////
#ifndef __SPDBUSBMDLL_H__
#define __SPDBUSBMDLL_H__

#define DLLIMPORT extern "C" __declspec(dllimport)
#define	CALLTYPE	__stdcall

#define MAX_USB_PORT_NUM	8
#define SP_EXT_TRG_WAITING	-99

enum{
	SP_ORDER_BY_USBPORTNUM	= 0,
	SP_ORDER_BY_CHANNELID	= 1
};

enum{
	SP_TRIGGER_OFF		= 10,
	SP_TRIGGER_INTERNAL = 11,
	SP_TRIGGER_EXTERNAL = 12
};

enum{
	SP_EXTEDGE_FALLING		= 0,
	SP_EXTEDGE_RISING		= 1,
};

enum{
	SP_INTMODE_SWTRIGGER	= 0,
	SP_INTMODE_FREERUN_PREV	= 1,
	SP_INTMODE_FREERUN_NEXT	= 2
};

enum{
	SP_NO_ERROR					=  1,
	SP_ERROR_DEVICE_IO_CTRL		= -1,
	SP_ERROR_OPEN_DRIVER		= -2,
	SP_ERROR_OPEN_FILE			= -3,
	SP_ERROR_EEPROM_READ		= -4,
	SP_ERROR_MEMORY_ALLOC		= -5,
	SP_ERRPR_NOTSUPORT_DEV		= -7
};

enum{
	SP_CCD_SONY					= 0,
	SP_CCD_TOSHIBA				= 1,
	SP_CCD_PDA					= 2,
	SP_CCD_G9212				= 3,		// InGaAs
	SP_CCD_S10420				= 4,		//Non Cooled BT Back thinned CCD
	SP_CCD_G92XX_256			= 5,
	SP_CCD_S10141				= 6,		//SM303 S10141 CCD
	SP_CCD_TCD1304AP			= 7			//SM445
};

enum{
	SP_CCD_PIXEL_G9212			= 512,	// InGaAs
	SP_CCD_PIXEL_G9212_REAL		= 512,
	SP_CCD_PIXEL_PDA			= 1056,	// Back thinned CCD, it has to be a multiple of "32"
	SP_CCD_PIXEL_PDA_REAL		= 1024,
	SP_CCD_PIXEL_SONY			= 2080,
	SP_CCD_PIXEL_SONY_REAL		= 2048,
	SP_CCD_PIXEL_TOSHIBA		= 3680,
	SP_CCD_PIXEL_TOSHIBA_REAL	= 3648,
	SP_CCD_PIXEL_S10420			= 2080,	// Non Cooled Back thined
	SP_CCD_PIXEL_S10420_REAL	= 2048,
	SP_CCD_PIXEL_S10141			= 2080, 
	SP_CCD_PIXEL_S10141_REAL	= 2048,
	SP_CCD_PIXEL_TCD1304AP		= 3680,
	SP_CCD_PIXEL_TCD1304AP_REAL = 3648
};

DLLIMPORT short CALLTYPE spTestAllChannels(short sOrderType = SP_ORDER_BY_CHANNELID);
DLLIMPORT short CALLTYPE spSetupAllChannels();
DLLIMPORT short CALLTYPE spSetupGivenChannel(short sChannel=0);
DLLIMPORT short CALLTYPE spInitAllChannels(short sCCDType = SP_CCD_SONY);
DLLIMPORT short CALLTYPE spInitGivenChannel(short sCCDType = SP_CCD_SONY, short sChannel = 0);
DLLIMPORT short CALLTYPE spSetIntEx(long const lIntTime, short sChannel=0);
DLLIMPORT short CALLTYPE spSetDblIntEx(long const lIntTime, short sChannel=0);
DLLIMPORT short CALLTYPE spSetTrgEx(short const sTrgType, short sChannel=0);
DLLIMPORT short CALLTYPE spReadDataEx(long *lpArray, short sChannel=0);
DLLIMPORT short CALLTYPE spCloseAllChannels();
DLLIMPORT short CALLTYPE spCloseGivenChannel(short sChannel=0);
DLLIMPORT short CALLTYPE spWriteChannelID(short sNum, short sChannel=0);
DLLIMPORT short CALLTYPE spReadChannelID(short *spNum, short sChannel=0);
DLLIMPORT void CALLTYPE spGetAssignedChannelID(short *spChannelID);
DLLIMPORT void CALLTYPE spPolyCalc(double *coefs, short order, double x, double *y);
DLLIMPORT short CALLTYPE spPolyFit(double *x, double *y, short numPts, double *coefs, short order);
DLLIMPORT short CALLTYPE spSetIntMode(short IntMode, double dIntTime, short sChannel =0);
DLLIMPORT short CALLTYPE spSetExtEdgeMode(short EdgeMode, short sChannel =0);
DLLIMPORT short CALLTYPE spCheckSpeedMode(int *nCheckSpeed, short sChannel =0);
DLLIMPORT short CALLTYPE spGetDevIsNew(short sChannel =0);

DLLIMPORT short CALLTYPE spDevInfo(char *strModel, char *strSerial, short sChannel=0);
DLLIMPORT short CALLTYPE spGetWLTable(double *WLTable, short sChannel=0);
DLLIMPORT short CALLTYPE spDupdate(int ScanAvg, int smooth, short sChannel);
DLLIMPORT short CALLTYPE spReadDataExT(long *lpArray, short sChannel=0);

#endif
