unit AIOWDM;

interface

uses
  Windows;

const //Watchdog function constants
  WDG_ACTION_IGNORE = 0;
  WDG_ACTION_DISABLE = 1;
  WDG_ACTION_SOFT_RESTART = 2;
  WDG_ACTION_MOSTLY_SOFT_RESTART = 4;
  PCI_WDG_CSM_RATE = 2.08333;
  P104_WDG_CSM_RATE = 2.08333;
  ISA_WDG_CSM_RATE = 0.894886;
  
  BAR0 = $80;
  BAR1 = $81;
  BAR2 = $82;
  BAR3 = $83;
  BAR4 = $84;
  BAR5 = $85;

  rcNoChange = $FFFFFFFF;
  rcUnipolar10 = $30313055;  // "U010"
  rcUnipolar5 = $35303055;   // "U005"
  rcBipolar10 = $3031E142;   // "B±10"
  rcBipolar5 = $3530E142;    // "B±05"
  rcBipolar2_5 = $BD32E142;  // "B±2½"
  rcCurrent420 = $30323449;  // "I420"
  rcCurrent020 = $30323049;  // "I020"
  rcCurrent024 = $34323049;  // "I024"

  rcCode0 = 0;
  rcCode1 = 1;
  rcCode2 = 2;
  rcCode3 = 3;
  rcCode4 = 4;
  rcCode5 = 5;
  rcCode6 = 6;
  rcCode7 = 7;
  rcCode8 = 8;
  rcCode9 = 9;
  rcCode10 = 10;
    
  bSimultaneous = true;
  bUpdate = true;
  bRestricted = true;

function GetNumCards: Integer; cdecl; external 'AIOWDM.dll';
function QueryCardInfo(CardNum: Integer; pDeviceID: PLongWord; pBase: PLongWord; pNameSize: pLongWord; pName: PAnsiChar): LongWord; cdecl; external 'AIOWDM.dll';
function QueryBARBase(CardNum: Integer; BARIndex: LongWord; pBase: PLongWord): LongWord; cdecl; external 'AIOWDM.dll';
function WaitForIRQ(CardNum: Integer): LongWord; cdecl; external 'AIOWDM.dll';
function COSWaitForIRQ(CardNum: Integer; PPIs: LongWord; pData: Pointer): LongWord; cdecl; external 'AIOWDM.dll';
function SetCOSScheme(CardNum: LongInt; COSScheme: LongWord): LongWord; cdecl; external 'AIOWDM.dll';
function PollForIRQ(CardNum: Integer): LongWord; cdecl; external 'AIOWDM.dll';
function WDGHandleIRQ(CardNum: Integer; Action: LongWord): LongWord; cdecl; external 'AIOWDM.dll';
function AbortRequest(CardNum: Integer): LongWord; cdecl; external 'AIOWDM.dll';
function CloseCard(CardNum: Integer): LongWord; cdecl; external 'AIOWDM.dll';
function WDGInit(CardNum: Integer): LongWord; cdecl; external 'AIOWDM.dll';
function WDGSetTimeout(CardNum: Integer; Milliseconds, MHzClockRate: Double): Double; cdecl; external 'AIOWDM.dll';
function WDGSetResetDuration(CardNum: Integer; Milliseconds, MHzClockRate: Double): Double; cdecl; external 'AIOWDM.dll';
function WDGPet(CardNum: Integer): LongWord; cdecl; external 'AIOWDM.dll';
function WDGReadTemp(CardNum: Integer): Double; cdecl; external 'AIOWDM.dll';
function WDGReadStatus(CardNum: Integer): LongWord; cdecl; external 'AIOWDM.dll';
function WDGStart(CardNum: Integer): LongWord; cdecl; external 'AIOWDM.dll';
function WDGStop(CardNum: Integer): LongWord; cdecl; external 'AIOWDM.dll';
function EmergencyReboot(): LongWord; cdecl; external 'AIOWDM.dll';

//8-bit Relative
function RelInPortB(Cardnum:DWord; Port: DWord): Word; cdecl; external 'AIOWDM.dll';
function RelOutPortB(Cardnum:DWord; Port: DWord; Value: Byte): Word; cdecl; external 'AIOWDM.dll';
function InBAR8(CardNum: LongWord; BAR: Byte; Offset: LongWord): Byte; cdecl; external 'AIOWDM.dll';
function OutBAR8(CardNum: LongWord; BAR: Byte; Offset: LongWord; Value: Byte): Byte; cdecl; external 'AIOWDM.dll';
function RelINSB(CardNum, Offset, Count: LongWord; pBuf: PByte): LongWord; cdecl; external 'AIOWDM.dll';

//16-bit Relative
function RelInPort(Cardnum:DWord; Port: DWord): Word; cdecl; external 'AIOWDM.dll';
function RelOutPort(Cardnum:DWord; Port: DWord; Value: Word): Word; cdecl; external 'AIOWDM.dll';
function InBAR16(CardNum: LongWord; BAR: Byte; Offset: LongWord): Word; cdecl; external 'AIOWDM.dll';
function OutBAR16(CardNum: LongWord; BAR: Byte; Offset: LongWord; Value: Word): Word; cdecl; external 'AIOWDM.dll';
function RelINSW(CardNum, Offset, Count: LongWord; pBuf: PWord): LongWord; cdecl; external 'AIOWDM.dll';

//32-bit Relative
function RelInPortL(Cardnum:DWord; Port: DWord): DWord; cdecl; external 'AIOWDM.dll';
function RelOutPortL(Cardnum:DWord; Port: DWord; Value: DWord): Word; cdecl; external 'AIOWDM.dll';
function InBAR32(CardNum: LongWord; BAR: Byte; Offset: LongWord): LongWord; cdecl; external 'AIOWDM.dll';
function OutBAR32(CardNum: LongWord; BAR: Byte; Offset: LongWord; Value: LongWord): LongWord; cdecl; external 'AIOWDM.dll';
function RelINSL(CardNum, Offset, Count: LongWord; pBuf: PLongWord): LongWord; cdecl; external 'AIOWDM.dll';
function RelInPortDWord(Cardnum:DWord; Port: DWord): DWord; cdecl; external 'AIOWDM.dll';
function RelOutPortDWord(Cardnum:DWord; Port: DWord; Value: DWord): Word; cdecl; external 'AIOWDM.dll';

//8-bit Absolute
function InPortB(Port: DWord): Word; cdecl; external 'AIOWDM.dll';
function OutPortB(Port: DWord; Value: Byte): Word; cdecl; external 'AIOWDM.dll';
function INSB(Addr, Count: LongWord; pBuf: PByte): LongWord; cdecl; external 'AIOWDM.dll';

//16-bit Absolute
function InPort(Port: DWord): Word; cdecl; external 'AIOWDM.dll';
function OutPort(Port: DWord; Value: Word): Word; cdecl; external 'AIOWDM.dll';
function INSW(Addr, Count: LongWord; pBuf: PWord): LongWord; cdecl; external 'AIOWDM.dll';

//32-bit Absolute
function InPortL(Port: DWord): DWord; cdecl; external 'AIOWDM.dll';
function OutPortL(Port: DWord; Value: DWord): Word; cdecl; external 'AIOWDM.dll';
function INSL(Addr, Count: LongWord; pBuf: PLongWord): LongWord; cdecl; external 'AIOWDM.dll';
function InPortDWord(Port: DWord): DWord; cdecl; external 'AIOWDM.dll';
function OutPortDWord(Port: DWord; Value: DWord): Word; cdecl; external 'AIOWDM.dll';

// DAC Functions — Note: most only support PCI-/PCIe-DA1x-xx devices at this time!
function DAC_GetNumDacs(CardNum: LongWord; numDacs: PWord): LongWord; cdecl; external 'AIOWDM.dll';
function DAC_GetMaxCounts(CardNum: LongWord; maxCounts: PLongWord): LongWord; cdecl; external 'AIOWDM.dll';
function DAC_Output(CardNum: LongWord; iDac: Word; Value: double): LongWord; cdecl; external 'AIOWDM.dll';
function DAC_Outputs(CardNum: LongWord; numValues: Word; Values: pdouble): LongWord; cdecl; external 'AIOWDM.dll';
function DAC_SetRange(CardNum: LongWord; iDac: Word; RangeCode: LongWord ): LongWord; cdecl; external 'AIOWDM.dll';
function DAC_SetRanges(CardNum, numRangeCodes: LongWord; RangeCodes: PLongWord ): LongWord; cdecl; external 'AIOWDM.dll';
function DAC_GetRange(CardNum: LongWord; iDac: Word; RangeCode: PLongWord ): LongWord; cdecl; external 'AIOWDM.dll';
function DAC_GetRanges(CardNum: LongWord; numRangeCodes: PWord; RangeCodes: PLongWord ): LongWord; cdecl; external 'AIOWDM.dll';
function DAC_ValueFromCounts(CardNum: LongWord; iDac: Word; Counts: LongWord; Value: PDouble): LongWord; cdecl; external 'AIOWDM.dll';
function DAC_OutputCount(CardNum: LongWord; iDac: Word; Counts: LongWord ): LongWord; cdecl; external 'AIOWDM.dll';
function DAC_OutputCounts(CardNum: LongWord; numCounts: Word; Counts: PLongWord ): LongWord; cdecl; external 'AIOWDM.dll';
function DAC_ReloadCalibrationData(CardNum: LongWord): LongWord; cdecl; external 'AIOWDM.dll';
function DAC_EnableCalibration(CardNum: LongWord; Enable: Word): LongWord; cdecl; external 'AIOWDM.dll';
function DAC_GetCalibrationData(CardNum: LongWord; pBufLength:PWord; pBuf: Pointer): LongWord; cdecl; external 'AIOWDM.dll';
function DAC_ConfigureSimultaneousMode(CardNum: LongWord; bSimultaneous, bUpdate: LongBool): LongWord; cdecl; external 'AIOWDM.dll';
function DAC_ConfigureVoltageRestrictMode(CardNum: LongWord; bRestricted: LongBool): LongWord; cdecl; external 'AIOWDM.dll';

Function DIF_ConfigurePulseClock(CardNum: LongWord; clockHz: PDouble): LongWord; cdecl; external 'AIOWDM.dll';
Function DIF_Measure(CardNum: LongWord; iBit: LongWord; LoSide, HiSide, DutyCycle, Frequency: PDouble): LongWord; cdecl; external 'AIOWDM.dll';
Function DIF_Generate(CardNum: LongWord; iBit: LongWord; ActiveSide, InactiveSide: double; PulseCount: Word): LongWord; cdecl; external 'AIOWDM.dll';
Function DIF_ConfigureGeneration(CardNum: LongWord; iBit: LongWord; ActiveSide, InactiveSide: double; PulseCount: Word): LongWord; cdecl; external 'AIOWDM.dll';
Function DIF_ConfigureCounting(CardNum: LongWord; iBit: LongWord; bCountFalling, bCountRising: Longbool): LongWord; cdecl; external 'AIOWDM.dll';
Function DIF_Count(CardNum: LongWord; iBit: LongWord; Count: PLongWord): LongWord; cdecl; external 'AIOWDM.dll';
Function DIF_CountOverflowIRQEnable(CardNum: LongWord; iBit: LongWord; bEnabled: LongBool): LongWord; cdecl; external 'AIOWDM.dll';
Function DIF_IRQEdgeEnable(CardNum: LongWord; iBit: LongWord; bFallingIRQ, bRisingIRQ: Longbool): LongWord; cdecl; external 'AIOWDM.dll';

implementation

end.
