Sensoray 526 User Manual

Page 6

Advertising
background image

6

Developing a Windows application

Sensoray does not provide a .lib file for the DLL, because thouse are not compatible across
various development platforms. Instead, dynamic linking is used. An application has to explicitly
open s526.dll and get the pointers to DLL fuctions before those functions could be called. To
simplify those actions 2 files are provided: s526f.h and s526app.c. The following steps have to be
completed when developing an application with s526.dll:

1. File s526app.c has to be included in the project. Please, do not try the following:

#include “s526app.c”,

it’s not going to work! Instead use “Add files to project”.

2. Each file of the project that contains calls to DLL functions has to include s526f.h (this time

with the help of #include directive).

3. The first action of the application related to Model 526 board has to be a call to

S526_DLLOpen function (declared in s526f.h). That is followed by a call (or calls) to
S526_Open for each Model 526 board used by the application. When terminating the
application first call S526_Close (for all open boards), and then S526_DLLClose (once per
application). Errors returned by S526_DLLOpen function are usually related to either DLL not
being installed in one of Windows default folders (or an application folder), or a wrong
version of the DLL being installed.


Please see sample applications for programming examples.

Interrupts under Windows

The following approach is implemented in the DLL: when a board is initialized (with S526_Open)
the driver creates an event that becomes signaled when an interrupt occurs. A handle to this
event is passed to the application as part of the BOARD526 structure. The application uses
Windows API function WaitForSingleObject to wait until interrupt occurs. If a call to this function
is put in a separate thread, other actions could be performed by the application while this thread
is waiting for the interrupt (WaitForSingleObject does not consume CPU time). Note that the
Interrupt Enable Register (IER) is being reset to 0 by the driver as soon as the interrupt occurs.
The application has to restore the value of IER (enable interrupts) after the interrupt processing
is complete.

Installation

The following procedure has to be carried out for installation under Windows98/2000/XP. The
system response during the installation may vary slightly depending on the specific version of
Windows. Under WindowsNT only step 1 is necessary.

1. Run setup.exe from the installation disk. The software is installed under \Program

Files\Sensoray\S526.

2. Find the necessary spare resources (I/O space and interrupt). This can be done by going to

Device Manager, selecting “View resources by type”, and expanding “Input/output (IO)” and
“Interrupt request (IRQ)” items. Configure the jumpers on the board to match the selected
I/O base address and IRQ.

Advertising