Software | C/C++ Driver Interface |
|
|
C/C++ Driver Interface
C/C++ is the main programming language for which the drivers have been build up. Therefore the interface to C/C++ is the best match. All the small examples of the manual showing different parts of the hardware programming are done with C.
Header files
The basic task before using the driver is to include the header files that are delivered on CD together with the board. The header files are found in the directory /Driver/header_c. Please don’t change them in any way because they are updated with each new driver version to include the new registers and new functionality.
dlltyp.h | Includes the platform specific definitions for data types and function declarations. All data types are based on this definitions. The use of this typ definition file |
| allows the use of examples and programs on different platforms without changes to the program source. |
regs.h | Defines all registers and commands which are used in the Spectrum driver for the different boards. The registers a board uses are described in the board spe- |
| cific part of the documentation. |
spectrum.h | Defines the functions of the driver. All definitions are taken from the file dlltyp.h. The functions itself are described below. |
spcerr.h | Lists all and describes all error codes that can be given back by any of the driver functions. The error codes and their meaning are described in detail in the |
| appendix of this manul. |
errors.h | Only there for backward compatibility with older program versions. Please use spcerr.h instead. |
Example for including the header files:
//
#include "dlltyp.h" #include "spectrum.h" #include "spcerr.h" #include "regs.h"
Microsoft Visual C++
Include Driver
The driver files can be easily included in Microsoft C++ by simply using the library file that is delivered together with the drivers. The library file can be found on the CD in the path /Examples/vc/c_header. Please include the library file Spectrum.lib in your Visual C++ project. All functions described below are now available in your program.
Examples
Examples can be found on CD in the path /Examples/vc. 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 contains examples for the MI.30xx, the MC.30xx and the MX.30xx families. The example directories contain a running project file for Microsoft Visual C++ that can be directly loaded and compiled.
There are also some more board independent examples in the directory MIxxxx. These examples show different aspects of the boards like programming options or synchronization and have to be combined with one of the board specific example.
Borland C++ Builder
Include Driver
The driver files can be easily included in Borland C++ Builder by simply using the library file that is delivered together with the drivers. The library file can be found on the CD in the path /Examples/vc/c_header. Please include the library file spclib_bcc.lib in your Borland C++ Builder project. All functions described below are now available in your program.
Examples
The Borland C++ Builder examples share the sources with the Visual C++ examples. Please see above chapter for a more detailed documen- tation of the examples. In each example directory are project files for Visual C++ as well as Borland C++ Builder.
Linux Gnu C
Include Driver
The interface of the linux drivers is a little bit different from the windows interface. To make the access easier and to have more similar exam- ples we added an include file that re maps the standard driver functions to the linux specific functions. This include file is found in the path / Examples/linux/spcioctl.inc. All examples are based on this file.
Example for including Linux driver:
//
#include "dlltyp.h" #include "regs.h" #include "spcerr.h"
//
#include "../spcioctl.inc"
(c) Spectrum GmbH | 29 |