Delphi (Pascal) Programming Interface

Software

 

 

Function SpcGetData

int16 SpcGetData (int16 nr, int16 ch, int32 start, int32 len, dataptr data);

Under Linux the additional parameter nBytesPerSample must be used for this function. For all boards with 8 bit resolution the parameter is „1“, for all boards with 12, 14 or 16 bit resolution this parameter has to be „2“, when reading timestamps this parameter has to be „8“. Under Linux the value „hDrv“ must contain the handle that was given back by the open function of that specific board. Under Linux the return value is not an error code but is the number of bytes that has been read.

Function SpcGetData (Linux)

int32 SpcGetData (int hDrv, int32 lCh, int32 lStart, int32 lLen, int16 nBytesPerSample, dataptr pvData)

Delphi (Pascal) Programming Interface

Type definition

All Spectrum driver functions are using pre-defined variable types to cover different operating systems and to use the same driver interface for all programming languages. Under Delphi it is necessary to define these types once. This is also shown in the examples delivered on CD.

Delphi type definition:

type

=

shortint;

int8

pint8

= ^shortint;

int16

=

smallint;

pint16

= ^smallint;

int32

=

longint;

pint32

= ^longint;

data

=

array[1..MEMSIZE] of smallint;

dataptr = ^data;

In the example shown above the size of data is defined to „smallint“. This definition is only valid for boards that have a sample resolution of 12, 14 or 16 bit. On 8 bit boards this has to be a „shortint“ type.

Include Driver

To include the driver functions into delphi it is necessary to first add them to the implementation section of the program file. There the name of the function and the location in the dll is defined:

Driver implementation:

function SpcSetData

(nr,ch:int16;

start,len:int32;

data:dataptr): int16; cdecl; external 'SPECTRUM.DLL';

function SpcGetData

(nr,ch:int16;

start,len:int32;

data:dataptr): int16; cdecl; external 'SPECTRUM.DLL';

function SpcSetParam

(nr:int16; reg,value: int32): int16;

cdecl; external 'SPECTRUM.DLL';

function

SpcGetParam

(nr:int16; reg:int32; value:pint32): int16;

cdecl;

external

'SPECTRUM.DLL';

function

SpcInitPCIBoards (count,PCIVersion: pint16): int16;

cdecl;

external

'SPECTRUM.DLL';

Examples

Examples for Delphi can be found on CD in the directory /Examples/delphi. There is one subdirectory for each board family. You’ll find board specific examples for that family there. The examples are bus type independent. As a result that means that the MI30xx directory con- tains examples for the MI.30xx, the MC.30xx and the MX.30xx families. The example directories contain a running project file for Borland Delphi that can be directly loaded and compiled.

Driver functions

The driver contains five functions to access the hardware.

Function SpcInitPCIBoard

This function initializes all installed PCI, PXI and CompactPCI boards. The boards are recognized automatically. All installation parameters are read out from the hardware and stored in the driver. The number of PCI boards will be given back in the value Count and the version of the PCI bus itself will be given back in the value PCIVersion.

Function SpcSetParam

All hardware settings are based on software registers that can be set by the function SpcSetParam. This function sets a register to a defined value or executes a command. The board must first be initialized. The available software registers for the driver are listed in the board specific part of the documentation below.

32

MC.31xx Manual

Page 32
Image 32
Spectrum Brands MC.31XX manual Delphi Pascal Programming Interface, Type definition, Include Driver, Examples