#ifndef AIOAIO_H_Included
#define AIOAIO_H_Included

#ifdef __cplusplus
	#define AIOAIOImport extern "C" __declspec(dllimport)
#else
	#define AIOAIOImport __declspec(dllimport)
#endif





typedef unsigned char TUInt8, *TPUInt8;
typedef unsigned short TUInt16, *TPUInt16;
typedef unsigned long TUInt32, *TPUInt32;
typedef unsigned long long TUInt64, *TPUInt64;
typedef unsigned int TUNative, *TPUNative;
typedef float TSingle, *TPSingle;
typedef double TDouble, *TPDouble;
typedef char TAnsiChar, *TPAnsiChar;
typedef wchar_t TWideChar, *TPWideChar;
typedef void *TPointer;

typedef TUInt32 TWinErrCode, *TPWinErrCode;
typedef TUInt64 TSerialNumber, *TPSerialNumber;
typedef TUInt32 TLongBool;

typedef TUInt64 TBoardIndex;
const TBoardIndex biAuto = 0;
const TBoardIndex biNone = -1;

typedef TUInt32 TChannelIndex;
const TChannelIndex ciAll = -1;

typedef TUInt32 TRangeCode, *TPRangeCode;
const TRangeCode rcNoChange   = -1;
const TRangeCode rcUnipolar10   = 0x30313055; //FourCC('U010');
const TRangeCode rcUnipolar5    = 0x35303055; //FourCC('U005');
const TRangeCode rcBipolar24    = 0x3432E142; //FourCC('B±24');
const TRangeCode rcBipolar20    = 0x3032E142; //FourCC('B±20');
const TRangeCode rcBipolar12    = 0x3231E142; //FourCC('B±12');
const TRangeCode rcBipolar10    = 0x3031E142; //FourCC('B±10');
const TRangeCode rcBipolar5     = 0x3530E142; //FourCC('B±05');
const TRangeCode rcBipolar2_5   = 0xBD32E142; //FourCC('B±2½');
const TRangeCode rcBipolar1_25  = 0xBC31E142; //FourCC('B±1¼');
const TRangeCode rcBipolar_625  = 0x3835E142; //FourCC('B±58');
const TRangeCode rcBipolar_3125  = 0x3331E142; //FourCC('B±13');
const TRangeCode rcRangeCode0   = 0x0;
const TRangeCode rcRangeCode1   = 0x1;
const TRangeCode rcRangeCode2   = 0x2;
const TRangeCode rcRangeCode3   = 0x3;
const TRangeCode rcRangeCode4   = 0x4;
const TRangeCode rcRangeCode5   = 0x5;
const TRangeCode rcRangeCode6   = 0x6;
const TRangeCode rcRangeCode7   = 0x7;

typedef TUInt32 TSequencerIndex;
const TSequencerIndex siFirst = 0;
const TSequencerIndex siSecond = 1;

typedef TUInt32 TIRQIndex;
const TIRQIndex iiOnly = 0;
	//Someday cards will have more, and default param makes this trivial for now.

typedef TUInt32 TChunkingType;
const TChunkingType ctAuto = 0;
const TChunkingType ctSize = 1;
const TChunkingType ctRate = 2;

typedef TUInt32 TCallbackType;
const TCallbackType ctRaw = 0x776152; //FourCC('Raw'#0);
const TCallbackType ctCounts = 0x6E756F43; //FourCC('Coun');
const TCallbackType ctV = 0x746C6F56; //FourCC('Volt');
const TCallbackType ctNone = 0xFFFFFFFF;

AIOAIOImport TBoardIndex BRD_GetHighestBoardIndex(void);
AIOAIOImport TWinErrCode BRD_GetNameA(TBoardIndex iBoard, TUInt32 BufLen, TPAnsiChar pNameBuf = NULL, TPUInt32 pNameLen = NULL);
AIOAIOImport TWinErrCode BRD_GetNameW(TBoardIndex iBoard, TUInt32 BufLen, TPWideChar pNameBuf = NULL, TPUInt32 pNameLen = NULL);
TWinErrCode BRD_GetName(TBoardIndex iBoard, TUInt32 BufLen, TPAnsiChar pNameBuf = NULL, TPUInt32 pNameLen = NULL)
{
	return BRD_GetNameA(iBoard, BufLen, pNameBuf, pNameLen);
}
TWinErrCode BRD_GetName(TBoardIndex iBoard, TUInt32 BufLen, TPWideChar pNameBuf = NULL, TPUInt32 pNameLen = NULL)
{
	return BRD_GetNameW(iBoard, BufLen, pNameBuf, pNameLen);
}
AIOAIOImport TWinErrCode BRD_GetSerialNumber(TBoardIndex iBoard, TPSerialNumber pSN);
AIOAIOImport TWinErrCode BRD_GetDeviceID(TBoardIndex iBoard, TPUInt32 pDeviceID);
AIOAIOImport TWinErrCode BRD_Reset(TBoardIndex iBoard);

AIOAIOImport TWinErrCode DAC_SetRange1(TBoardIndex iBoard, TChannelIndex Ch = ciAll, TRangeCode Range = rcBipolar10);
AIOAIOImport TWinErrCode DAC_SetRangeAll(TBoardIndex iBoard, TUInt32 RangeCt, TPRangeCode pRange);
TWinErrCode DAC_SetRange(TBoardIndex iBoard, TChannelIndex Ch = ciAll, TRangeCode Range = rcBipolar10)
{
	return DAC_SetRange1(iBoard, Ch, Range);
}
TWinErrCode DAC_SetRange(TBoardIndex iBoard, TUInt32 RangeCt, TPRangeCode pRange)
{
	return DAC_SetRangeAll(iBoard, RangeCt, pRange);
}
AIOAIOImport TWinErrCode DAC_OutputV(TBoardIndex iBoard, TChannelIndex Ch /*= ciAll*/, TDouble V);
AIOAIOImport TWinErrCode DAC_OutputCounts(TBoardIndex iBoard, TChannelIndex Ch /*= ciAll*/, TUInt64 Counts);
TWinErrCode DAC_Output(TBoardIndex iBoard, TChannelIndex Ch /*= ciAll*/, TDouble V)
{
	return DAC_OutputV(iBoard, Ch, V);
}
TWinErrCode DAC_Output(TBoardIndex iBoard, TChannelIndex Ch /*= ciAll*/, TUInt64 Counts)
{
	return DAC_OutputCounts(iBoard, Ch, Counts);
}

AIOAIOImport TWinErrCode ADC_SetRange1(TBoardIndex iBoard, TSequencerIndex iSequencer, TChannelIndex Ch = ciAll, TRangeCode RangeCode = rcBipolar10);
AIOAIOImport TWinErrCode ADC_SetRangeAll(TBoardIndex iBoard, TSequencerIndex iSequencer, TUInt32 RangeCt, TPRangeCode pRangeCodes);
TWinErrCode ADC_SetRange(TBoardIndex iBoard, TSequencerIndex iSequencer, TChannelIndex Ch = ciAll, TRangeCode RangeCode = rcBipolar10)
{
	return ADC_SetRange1(iBoard, iSequencer, Ch, RangeCode);
}
TWinErrCode ADC_SetRange(TBoardIndex iBoard, TSequencerIndex iSequencer, TUInt32 RangeCt, TPRangeCode pRangeCodes)
{
	return ADC_SetRangeAll(iBoard, iSequencer, RangeCt, pRangeCodes);
}
AIOAIOImport TWinErrCode ADC_SetRate(TBoardIndex iBoard, TSequencerIndex iSequencer, TDouble Hz);
AIOAIOImport TWinErrCode ADC_GetRate(TBoardIndex iBoard, TSequencerIndex iSequencer, TPDouble pHz);
AIOAIOImport TWinErrCode ADC_SetChannelCount(TBoardIndex iBoard, TSequencerIndex iSequencer, TChannelIndex ChCt = ciAll);
AIOAIOImport TWinErrCode ADC_SetDifferential(TBoardIndex iBoard, TLongBool bDifferential = true);
AIOAIOImport TWinErrCode ADC_GetImmediateScanV(TBoardIndex iBoard, TPDouble pVData, TRangeCode Range = rcNoChange);
AIOAIOImport TWinErrCode ADC_GetImmediateScanRaw(TBoardIndex iBoard, TPUInt32 pRawData, TRangeCode Range = rcNoChange);
TWinErrCode ADC_GetImmediateScan(TBoardIndex iBoard, TPDouble pVData, TRangeCode Range = rcNoChange)
{
	return ADC_GetImmediateScanV(iBoard, pVData, Range);
}
TWinErrCode ADC_GetImmediateScan(TBoardIndex iBoard, TPUInt32 pRawData, TRangeCode Range = rcNoChange)
{
	return ADC_GetImmediateScanRaw(iBoard, pRawData, Range);
}
AIOAIOImport TWinErrCode ADC_GetImmediateV(TBoardIndex iBoard, TSequencerIndex iSequencer, TPDouble V, TChannelIndex Ch, TRangeCode Range = rcNoChange);
AIOAIOImport TWinErrCode ADC_GetImmediateRaw(TBoardIndex iBoard, TSequencerIndex iSequencer, TPUInt32 Data, TChannelIndex Ch, TRangeCode Range = rcNoChange);
TWinErrCode ADC_GetImmediate(TBoardIndex iBoard, TSequencerIndex iSequencer, TPDouble V, TChannelIndex Ch, TRangeCode Range = rcNoChange)
{
	return ADC_GetImmediateV(iBoard, iSequencer, V, Ch, Range);
}
TWinErrCode ADC_GetImmediate(TBoardIndex iBoard, TSequencerIndex iSequencer, TPUInt32 Data, TChannelIndex Ch, TRangeCode Range = rcNoChange)
{
	return ADC_GetImmediateRaw(iBoard, iSequencer, Data, Ch, Range);
}
//AIOAIOImport TWinErrCode ADC_ConfigureAcquire(TBoardIndex iBoard, TSequencerIndex iSequencer, TChunkingType ChunkingType, TUInt32 Chunk);
AIOAIOImport TWinErrCode ADC_AcquireBlock(TBoardIndex iBoard, TSequencerIndex iSequencer, TUNative SampleCt);
AIOAIOImport TWinErrCode ADC_AcquireStream(TBoardIndex iBoard, TSequencerIndex iSequencer);
AIOAIOImport TWinErrCode ADC_AcquireEnd(TBoardIndex iBoard, TSequencerIndex iSequencer);
AIOAIOImport TWinErrCode ADC_SetCallback(TBoardIndex iBoard, TSequencerIndex iSequencer, TCallbackType CallbackType, TPointer pCallback = NULL);
AIOAIOImport TWinErrCode ADC_GetDataV(TBoardIndex iBoard, TSequencerIndex iSequencer, TUInt32 DataCt, TPUInt32 pGotDataCt, TPDouble pData = NULL, TPUInt16 pStatus = NULL, TPUInt16 pTimestamp = NULL);
AIOAIOImport TWinErrCode ADC_GetDataCounts(TBoardIndex iBoard, TSequencerIndex iSequencer, TUInt32 DataCt, TPUInt32 pGotDataCt, TPUInt16 pData = NULL, TPUInt16 pStatus = NULL, TPUInt16 pTimestamp = NULL);
AIOAIOImport TWinErrCode ADC_GetDataRaw(TBoardIndex iBoard, TSequencerIndex iSequencer, TUInt32 DataCt, TPUInt32 pGotDataCt, TPUInt32 pDataRaw = NULL);
TWinErrCode ADC_GetData(TBoardIndex iBoard, TSequencerIndex iSequencer, TUInt32 DataCt, TPUInt32 pGotDataCt, TPDouble pData = NULL, TPUInt16 pStatus = NULL, TPUInt16 pTimestamp = NULL)
{
	return ADC_GetDataV(iBoard, iSequencer, DataCt, pGotDataCt, pData, pStatus, pTimestamp);
}
TWinErrCode ADC_GetData(TBoardIndex iBoard, TSequencerIndex iSequencer, TUInt32 DataCt, TPUInt32 pGotDataCt, TPUInt16 pData = NULL, TPUInt16 pStatus = NULL, TPUInt16 pTimestamp = NULL)
{
	return ADC_GetDataCounts(iBoard, iSequencer, DataCt, pGotDataCt, pData, pStatus, pTimestamp);
}
TWinErrCode ADC_GetData(TBoardIndex iBoard, TSequencerIndex iSequencer, TUInt32 DataCt, TPUInt32 pGotDataCt, TPUInt32 pDataRaw = NULL)
{
	return ADC_GetDataRaw(iBoard, iSequencer, DataCt, pGotDataCt, pDataRaw);
}
AIOAIOImport TWinErrCode ADC_PollData(TBoardIndex iBoard, TSequencerIndex iSequencer);
AIOAIOImport TWinErrCode ADC_ClearData(TBoardIndex iBoard, TSequencerIndex iSequencer);

AIOAIOImport TUInt8 PIO_In8(TBoardIndex iBoard, TUInt32 Offset);
AIOAIOImport TUInt16 PIO_In16(TBoardIndex iBoard, TUInt32 Offset);
AIOAIOImport TUInt32 PIO_In32(TBoardIndex iBoard, TUInt32 Offset);
AIOAIOImport TWinErrCode PIO_Out8(TBoardIndex iBoard, TUInt32 Offset, TUInt8 Data);
AIOAIOImport TWinErrCode PIO_Out16(TBoardIndex iBoard, TUInt32 Offset, TUInt16 Data);
AIOAIOImport TWinErrCode PIO_Out32(TBoardIndex iBoard, TUInt32 Offset, TUInt32 Data);
AIOAIOImport TWinErrCode PIO_INS8(TBoardIndex iBoard, TUInt32 Offset, TUInt32 DataCt, TPUInt8 pData);
AIOAIOImport TWinErrCode PIO_INS16(TBoardIndex iBoard, TUInt32 Offset, TUInt32 DataCt, TPUInt16 pData);
AIOAIOImport TWinErrCode PIO_INS32(TBoardIndex iBoard, TUInt32 Offset, TUInt32 DataCt, TPUInt32 pData);
AIOAIOImport TWinErrCode PIO_OUTS8(TBoardIndex iBoard, TUInt32 Offset, TUInt32 DataCt, TPUInt8 pData);
AIOAIOImport TWinErrCode PIO_OUTS16(TBoardIndex iBoard, TUInt32 Offset, TUInt32 DataCt, TPUInt16 pData);
AIOAIOImport TWinErrCode PIO_OUTS32(TBoardIndex iBoard, TUInt32 Offset, TUInt32 DataCt, TPUInt32 pData);
AIOAIOImport TWinErrCode PIO_WaitForIRQ(TBoardIndex iBoard, TIRQIndex IRQIndex = iiOnly);
AIOAIOImport TWinErrCode PIO_PollForIRQ(TBoardIndex iBoard, TIRQIndex IRQIndex = iiOnly);
AIOAIOImport TWinErrCode PIO_AbortIRQWait(TBoardIndex iBoard, TIRQIndex IRQIndex = iiOnly);



// reserved for future implementation
//__declspec(dllimport) TWinErrCode BRD_SleepDevice(TBoardIndex iBoard);

//__declspec(dllimport) TWinErrCode BRD_GetRev(TBoardIndex iBoard, TPUInt32 pRev);

//__declspec(dllimport) TWinErrCode DAC_OutputVAll(TBoardIndex iBoard, TUInt32 Ct, TPDouble V);
//__declspec(dllimport) TWinErrCode DAC_OutputCountsAll(TBoardIndex iBoard, TUInt32 Ct, TUInt64 Counts);
// header files overload DAC_OutputVAll with DAC_OutputCountsAll() as DAC_Output(), along with DAC_OutputV() and DAC_Output1()



#endif