Delphi (Pascal) Programming Interface | Software |
|
|
Delphi (Pascal) Programming Interface
Type definition
All Spectrum driver functions are using
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.
The value „nr“ contains the index of the board that you want to access, the value „reg“ is the register that has to be changed and the value „value“ is the new value that should be set to this software register. The function will return an error value in case of malfunction.
Function SpcGetParam
The function SpcGetParam reads out software registers or status information. The board must first be initialized. The available software re- gisters for the driver are listed in the board specific part of the documentation below.
The value „nr“ contains the index of the board that you want to access, the value „reg“ is the register that has to be read out and the value „value“ is a pointer to a value that should contain the read parameter after function call. The function will return an error value in case of malfunction.
Function SpcSetData
Writes data to the board for a specific memory channel. The board must first be initialized. The value „nr“ contains the index of the board that you want to access, the „ch“ parameter contains the memory channel. „start“ and „len“ define the position of data to be written. „data“ is a pointer to the array holding the data. The function will return an error value in case of malfunction.
32 | MI.61xx Manual |