unit AIOAIO;

interface

type
	TUInt8    = Byte      ; TPUInt8    = ^TUInt8   ;
	TUInt16   = Word      ; TPUInt16   = ^TUInt16  ;
	TUInt32   = LongWord  ; TPUInt32   = ^TUInt32  ;
	TUInt64   = type Int64; TPUInt64   = ^TUInt64  ;
	TUNative  = Cardinal  ; TPUNative  = ^TUNative ;
	TSingle   = Single    ; TPSingle   = ^TSingle  ;
	TDouble   = Double    ; TPDouble   = ^TDouble  ;
	TAnsiChar = AnsiChar  ; TPAnsiChar = ^TAnsiChar;
	TWideChar = WideChar  ; TPWideChar = ^TWideChar;

type
	TWinErrCode = TUInt32;
	TPWinErrCode = ^TWinErrCode;
	TSerialNumber = TUInt64;
	TPSerialNumber = ^TSerialNumber;

type	
	TBoardIndex = TUInt64;
const
	biAuto = TBoardIndex(0);
	biNone = TBoardIndex(-1);

type
	TChannelIndex = TUInt32;
const
	ciAll = TChannelIndex(-1);

type 
	TRangeCode = TUInt32;
	TPRangeCode = ^TRangeCode;
const
	rcNoChange   = TRangeCode(-1);
	rcUnipolar10   = TRangeCode($30313055); //FourCC('U010');
	rcUnipolar5    = TRangeCode($35303055); //FourCC('U005');
	rcBipolar24    = TRangeCode($3432E142); //FourCC('B±24');
	rcBipolar20    = TRangeCode($3032E142); //FourCC('B±20');
	rcBipolar12    = TRangeCode($3231E142); //FourCC('B±12');
	rcBipolar10    = TRangeCode($3031E142); //FourCC('B±10');
	rcBipolar5     = TRangeCode($3530E142); //FourCC('B±05');
	rcBipolar2_5   = TRangeCode($BD32E142); //FourCC('B±2½');
	rcBipolar1_25  = TRangeCode($BC31E142); //FourCC('B±1¼');
	rcBipolar_625  = TRangeCode($3835E142); //FourCC('B±58');
	rcBipolar_3125  = TRangeCode($3331E142); //FourCC('B±13');
    rcCurrent420   = TRangeCode($30323449);  // 'I420'
    rcCurrent020   = TRangeCode($30323049);  // 'I020'
    rcCurrent024   = TRangeCode($34323049);  // 'I024'
	rcRangeCode0   = TRangeCode(0);
	rcRangeCode1   = TRangeCode(1);
	rcRangeCode2   = TRangeCode(2);
	rcRangeCode3   = TRangeCode(3);
	rcRangeCode4   = TRangeCode(4);
	rcRangeCode5   = TRangeCode(5);
	rcRangeCode6   = TRangeCode(6);
	rcRangeCode7   = TRangeCode(7);
	rcRangeCode8   = TRangeCode(8);
	rcRangeCode9   = TRangeCode(9);
	rcRangeCode10  = TRangeCode(10);
    

type
	TSequencerIndex = TUInt32;
const
	siFirst = TSequencerIndex(0);
	siSecond = TSequencerIndex(1);

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

type
	TChunkingType = TUInt32;
const
	ctAuto = TChunkingType(0);
	ctSize = TChunkingType(1);
	ctRate = TChunkingType(2);

type
	TCallbackType = TUInt32;
const
	ctRaw = TCallbackType($776152); //FourCC('Raw'#0);
	ctCounts = TCallbackType($6E756F43); //FourCC('Coun');
	ctV = TCallbackType($746C6F56); //FourCC('Volt');
	ctNone = TCallbackType($FFFFFFFF);

function BRD_GetHighestBoardIndex: TBoardIndex; cdecl; external 'AIOAIO.dll';
function BRD_GetName(iBoard: TBoardIndex; BufLen: TUInt32; pNameBuf: TPAnsiChar = nil; pNameLen: TPUInt32 = nil): TWinErrCode; cdecl; overload; external 'AIOAIO.dll' name 'BRD_GetNameA';
function BRD_GetName(iBoard: TBoardIndex; BufLen: TUInt32; pNameBuf: TPWideChar = nil; pNameLen: TPUInt32 = nil): TWinErrCode; cdecl; overload; external 'AIOAIO.dll' name 'BRD_GetNameW';
function BRD_GetNameA(iBoard: TBoardIndex; BufLen: TUInt32; pNameBuf: TPAnsiChar = nil; pNameLen: TPUInt32 = nil): TWinErrCode; cdecl; external 'AIOAIO.dll';
function BRD_GetNameW(iBoard: TBoardIndex; BufLen: TUInt32; pNameBuf: TPWideChar = nil; pNameLen: TPUInt32 = nil): TWinErrCode; cdecl; external 'AIOAIO.dll';
function BRD_GetSerialNumber(iBoard: TBoardIndex; pSN: TPSerialNumber): TWinErrCode; cdecl; external 'AIOAIO.dll';
function BRD_GetDeviceID(iBoard: TBoardIndex; pDeviceID: TPUInt32): TWinErrCode; cdecl; external 'AIOAIO.dll';
function BRD_Reset(iBoard: TBoardIndex): TWinErrCode; cdecl; external 'AIOAIO.dll';

function DAC_SetRange(iBoard: TBoardIndex; Ch: TChannelIndex = ciAll; Range: TRangeCode = rcBipolar10): TWinErrCode; cdecl; overload; external 'AIOAIO.dll' name 'DAC_SetRange1';
function DAC_SetRange(iBoard: TBoardIndex; RangeCt: TUInt32; pRange: TPRangeCode): TWinErrCode; cdecl; overload; external 'AIOAIO.dll' name 'DAC_SetRangeAll';
function DAC_SetRange1(iBoard: TBoardIndex; Ch: TChannelIndex = ciAll; Range: TRangeCode = rcBipolar10): TWinErrCode; cdecl; external 'AIOAIO.dll';
function DAC_SetRangeAll(iBoard: TBoardIndex; RangeCt: TUInt32; pRange: TPRangeCode): TWinErrCode; cdecl; external 'AIOAIO.dll';
function DAC_Output(iBoard: TBoardIndex; Ch: TChannelIndex {= ciAll}; V: TDouble): TWinErrCode; cdecl; overload; external 'AIOAIO.dll' name 'DAC_OutputV';
function DAC_Output(iBoard: TBoardIndex; Ch: TChannelIndex {= ciAll}; Counts: TUInt64): TWinErrCode; cdecl; overload; external 'AIOAIO.dll' name 'DAC_OutputCounts';
function DAC_OutputV(iBoard: TBoardIndex; Ch: TChannelIndex {= ciAll}; V: TDouble): TWinErrCode; cdecl; external 'AIOAIO.dll';
function DAC_OutputCounts(iBoard: TBoardIndex; Ch: TChannelIndex {= ciAll}; Counts: TUInt64): TWinErrCode; cdecl; external 'AIOAIO.dll';

function ADC_SetRange(iBoard: TBoardIndex; iSequencer: TSequencerIndex; Ch: TChannelIndex = ciAll; RangeCode: TRangeCode = rcBipolar10): TWinErrCode; cdecl; overload; external 'AIOAIO.dll' name 'ADC_SetRange1';
function ADC_SetRange(iBoard: TBoardIndex; iSequencer: TSequencerIndex; RangeCt: TUInt32; pRangeCodes: TPRangeCode): TWinErrCode; cdecl; overload; external 'AIOAIO.dll' name 'ADC_SetRangeAll';
function ADC_SetRange1(iBoard: TBoardIndex; iSequencer: TSequencerIndex; Ch: TChannelIndex = ciAll; RangeCode: TRangeCode = rcBipolar10): TWinErrCode; cdecl; external 'AIOAIO.dll';
function ADC_SetRangeAll(iBoard: TBoardIndex; iSequencer: TSequencerIndex; RangeCt: TUInt32; pRangeCodes: TPRangeCode): TWinErrCode; cdecl; external 'AIOAIO.dll';
function ADC_SetRate(iBoard: TBoardIndex; iSequencer: TSequencerIndex; Hz: TDouble): TWinErrCode; cdecl; external 'AIOAIO.dll';
function ADC_GetRate(iBoard: TBoardIndex; iSequencer: TSequencerIndex; pHz: TPDouble): TWinErrCode; cdecl; external 'AIOAIO.dll';
function ADC_SetChannelCount(iBoard: TBoardIndex; iSequencer: TSequencerIndex; ChCt: TChannelIndex = ciAll): TWinErrCode; cdecl; external 'AIOAIO.dll';
function ADC_SetDifferential(iBoard: TBoardIndex; bDifferential: LongBool = True): TWinErrCode; cdecl; external 'AIOAIO.dll';
function ADC_GetImmediateScan(iBoard: TBoardIndex; pVData: TPDouble; Range: TRangeCode = rcNoChange): TWinErrCode; cdecl; overload; external 'AIOAIO.dll' name 'ADC_GetImmediateScanV';
function ADC_GetImmediateScan(iBoard: TBoardIndex; pRawData: TPUInt32; Range: TRangeCode = rcNoChange): TWinErrCode; cdecl; overload; external 'AIOAIO.dll' name 'ADC_GetImmediateScanRaw';
function ADC_GetImmediateScanV(iBoard: TBoardIndex; pVData: TPDouble; Range: TRangeCode = rcNoChange): TWinErrCode; cdecl; external 'AIOAIO.dll';
function ADC_GetImmediateScanRaw(iBoard: TBoardIndex; pRawData: TPUInt32; Range: TRangeCode = rcNoChange): TWinErrCode; cdecl; external 'AIOAIO.dll';
function ADC_GetImmediate(iBoard: TBoardIndex; iSequencer: TSequencerIndex; out V: TDouble; Ch: TChannelIndex; Range: TRangeCode = rcNoChange): TWinErrCode; cdecl; overload; external 'AIOAIO.dll' name 'ADC_GetImmediateV';
function ADC_GetImmediate(iBoard: TBoardIndex; iSequencer: TSequencerIndex; out Data: TUInt32; Ch: TChannelIndex; Range: TRangeCode = rcNoChange): TWinErrCode; cdecl; overload; external 'AIOAIO.dll' name 'ADC_GetImmediateRaw';
function ADC_GetImmediateV(iBoard: TBoardIndex; iSequencer: TSequencerIndex; out V: TDouble; Ch: TChannelIndex; Range: TRangeCode = rcNoChange): TWinErrCode; cdecl; external 'AIOAIO.dll';
function ADC_GetImmediateRaw(iBoard: TBoardIndex; iSequencer: TSequencerIndex; out Data: TUInt32; Ch: TChannelIndex; Range: TRangeCode = rcNoChange): TWinErrCode; cdecl; external 'AIOAIO.dll';

//function ADC_ConfigureAcquire(iBoard: TBoardIndex; iSequencer: TSequencerIndex; ChunkingType: TChunkingType; Chunk: TUInt32): TWinErrCode; cdecl; external 'AIOAIO.dll';
function ADC_AcquireBlock(iBoard: TBoardIndex; iSequencer: TSequencerIndex; SampleCt: TUNative): TWinErrCode; cdecl; external 'AIOAIO.dll';
function ADC_AcquireStream(iBoard: TBoardIndex; iSequencer: TSequencerIndex): TWinErrCode; cdecl; external 'AIOAIO.dll';
function ADC_AcquireEnd(iBoard: TBoardIndex; iSequencer: TSequencerIndex): TWinErrCode; cdecl; external 'AIOAIO.dll';
function ADC_SetCallback(iBoard: TBoardIndex; iSequencer: TSequencerIndex; CallbackType: TCallbackType; pCallback: Pointer = nil): TWinErrCode; cdecl; external 'AIOAIO.dll';
function ADC_GetData(iBoard: TBoardIndex; iSequencer: TSequencerIndex; DataCt: TUInt32; pGotDataCt: TPUInt32; pData: TPDouble = nil; pStatus: TPUInt16 = nil; pTimestamp: TPUInt16 = nil): TWinErrCode; cdecl; overload; external 'AIOAIO.dll' name 'ADC_GetDataV';
function ADC_GetData(iBoard: TBoardIndex; iSequencer: TSequencerIndex; DataCt: TUInt32; pGotDataCt: TPUInt32; pData: TPUInt16 = nil; pStatus: TPUInt16 = nil; pTimestamp: TPUInt16 = nil): TWinErrCode; cdecl; overload; external 'AIOAIO.dll' name 'ADC_GetDataCounts';
function ADC_GetData(iBoard: TBoardIndex; iSequencer: TSequencerIndex; DataCt: TUInt32; pGotDataCt: TPUInt32; pDataRaw: TPUInt32 = nil): TWinErrCode; cdecl; overload; external 'AIOAIO.dll' name 'ADC_GetDataRaw';
function ADC_GetDataV(iBoard: TBoardIndex; iSequencer: TSequencerIndex; DataCt: TUInt32; pGotDataCt: TPUInt32; pData: TPDouble = nil; pStatus: TPUInt16 = nil; pTimestamp: TPUInt16 = nil): TWinErrCode; cdecl; external 'AIOAIO.dll';
function ADC_GetDataCounts(iBoard: TBoardIndex; iSequencer: TSequencerIndex; DataCt: TUInt32; pGotDataCt: TPUInt32; pData: TPUInt16 = nil; pStatus: TPUInt16 = nil; pTimestamp: TPUInt16 = nil): TWinErrCode; cdecl; external 'AIOAIO.dll';
function ADC_GetDataRaw(iBoard: TBoardIndex; iSequencer: TSequencerIndex; DataCt: TUInt32; pGotDataCt: TPUInt32; pDataRaw: TPUInt32 = nil): TWinErrCode; cdecl; external 'AIOAIO.dll';
function ADC_PollData(iBoard: TBoardIndex; iSequencer: TSequencerIndex): TWinErrCode; cdecl; external 'AIOAIO.dll';
function ADC_ClearData(iBoard: TBoardIndex; iSequencer: TSequencerIndex): TWinErrCode; cdecl; external 'AIOAIO.dll';

function PIO_In8(iBoard: TBoardIndex; Offset: TUInt32): TUInt8; cdecl; external 'AIOAIO.dll';
function PIO_In16(iBoard: TBoardIndex; Offset: TUInt32): TUInt16; cdecl; external 'AIOAIO.dll';
function PIO_In32(iBoard: TBoardIndex; Offset: TUInt32): TUInt32; cdecl; external 'AIOAIO.dll';
function PIO_Out8(iBoard: TBoardIndex; Offset: TUInt32; Data: TUInt8): TWinErrCode; cdecl; external 'AIOAIO.dll';
function PIO_Out16(iBoard: TBoardIndex; Offset: TUInt32; Data: TUInt16): TWinErrCode; cdecl; external 'AIOAIO.dll';
function PIO_Out32(iBoard: TBoardIndex; Offset: TUInt32; Data: TUInt32): TWinErrCode; cdecl; external 'AIOAIO.dll';
function PIO_INS8(iBoard: TBoardIndex; Offset: TUInt32; DataCt: TUInt32; pData: TPUInt8): TWinErrCode; cdecl; external 'AIOAIO.dll';
function PIO_INS16(iBoard: TBoardIndex; Offset: TUInt32; DataCt: TUInt32; pData: TPUInt16): TWinErrCode; cdecl; external 'AIOAIO.dll';
function PIO_INS32(iBoard: TBoardIndex; Offset: TUInt32; DataCt: TUInt32; pData: TPUInt32): TWinErrCode; cdecl; external 'AIOAIO.dll';
function PIO_OUTS8(iBoard: TBoardIndex; Offset: TUInt32; DataCt: TUInt32; pData: TPUInt8): TWinErrCode; cdecl; external 'AIOAIO.dll';
function PIO_OUTS16(iBoard: TBoardIndex; Offset: TUInt32; DataCt: TUInt32; pData: TPUInt16): TWinErrCode; cdecl; external 'AIOAIO.dll';
function PIO_OUTS32(iBoard: TBoardIndex; Offset: TUInt32; DataCt: TUInt32; pData: TPUInt32): TWinErrCode; cdecl; external 'AIOAIO.dll';
function PIO_WaitForIRQ(iBoard: TBoardIndex; IRQIndex: TIRQIndex = iiOnly): TWinErrCode; cdecl; external 'AIOAIO.dll';
function PIO_PollForIRQ(iBoard: TBoardIndex; IRQIndex: TIRQIndex = iiOnly): TWinErrCode; cdecl; external 'AIOAIO.dll';
function PIO_AbortIRQWait(iBoard: TBoardIndex; IRQIndex: TIRQIndex = iiOnly): TWinErrCode; cdecl; external 'AIOAIO.dll';



// reserved for future implementation

//function BRD_SleepDevice(iBoard: TBoardIndex): TWinErrCode; cdecl; external 'AIOAIO.dll';

//function BRD_GetRev(iBoard: TBoardIndex; pRev: TPUInt32): TWinErrCode; cdecl; external 'AIOAIO.dll';

//function DAC_OutputVAll(iBoard: TBoardIndex; Ct: TUInt32; V: TPDouble): TWinErrCode; cdecl; external 'AIOAIO.dll';
//function DAC_OutputCountsAll(iBoard: TBoardIndex; Ct: TUInt32; Counts: TUInt64): TWinErrCode; cdecl; external 'AIOAIO.dll';
// header files overload DAC_OutputVAll with DAC_OutputCountsAll() as DAC_Output(), along with DAC_OutputV() and DAC_Output1()



implementation

end.
