5 board configuration functions – Sensoray Smart A/D User Manual

Page 7

Advertising
background image

S

ENSORAY

I

NSTRUCTION

M

ANUAL

S

MART

A/D D

RIVER

FOR

W

INDOWS

Page 5

3.5 Board Configuration Functions

3.5.1 SetBoardAttr()

Function:

Registers/unregisters (synonomous with “connects/disconnects”) a Smart A/D™ board to/from the driver.

A board is registered by declaring to the driver the board’s model number, and, in the case of non-PCI models, the
board’s physical address. Each Smart A/D™ board must be registered by this function before calling any
other driver functions that reference that board.

Unregister a board by calling this function with the modelnum parameter set to zero. This releases the board
handle and frees all resources that were used by the associated board. All connected boards must be
unregistered when the application terminates.
This can be accomplished as follows:

1. If the application is dynamically linked to the driver, call FreeLibrary() when the application terminates.

2. If the application is statically linked to the driver, Windows will automatically unregister all boards.

Prototype:

long SetBoardAttr( long hBD, long modelnum, long address );

Example:

///////////////////////////////////////////////////////////////////////////////////

// Declare board number 0 to be a Model 619 PCI Smart A/D board, address unknown.

///////////////////////////////////////////////////////////////////////////////////

long successful = SetBoardAttr( 0, 619, 0 );

long board0adrs = GetBoardAdrs( 0 ); // Get board’s bus/slot number.

Example:

//////////////////////////////////////////////////////////////////////////////////

// Declare board number 2 to be a Model 618 PCI Smart A/D board which resides at

// bus number 0, slot number 11.

//////////////////////////////////////////////////////////////////////////////////

long board2adrs = 0x0000000B;

long successful = SetBoardAttr( 0, 618, board2adrs );

Example:

////////////////////////////////////////////////////////////////////////////

// Declare board number 3 to be a Sensoray Model 7419 STDbus Smart A/D board

// which resides at base I/O address F2B2 hex.

////////////////////////////////////////////////////////////////////////////

long baseport = 0xF2B2L;

long successful = SetBoardAttr( 3, 7419, baseport );

Parameter

Type

Description

hBD

long

Board handle. Use any value between 0 and 15, inclusive, but do not use a value that
has already been used for another Smart A/D™ board.

modelnum

long

To register a Smart A/D™ board with the driver, specify the board’s model number.
A previously registered board may be unregistered by setting this to zero.

address

long

Physical address of the Smart A/D™ board. See “Physical Addressing” on page 3 for
details of physical address formats.
PCI/CPCI models only: If you know a board’s address, you may register the board
by specifying its address, just as you would with any other board type. Altermately,
you may set the address to zero; this causes the driver to seek the next available
unregistered PCI/CPCI Smart A/D™ board in your system and connect it to the
specified board handle. You may then determine the physical address of the
connected PCI/CPCI board by calling the GetBoardAdrs() function.

return value

long

A non-zero value is returned upon successful registration.

Advertising