Programming the Board
Overview
(c) Spectrum GmbH
55
Programming the Board
Overview
The following chapters show you in detail how to program the different aspects of the board. For every topic there’s a small example. For
the examples we focused on Visual C++. However as shown in the last chapter the differences in programming the board under different
programming languages are marginal. This manual describes the programming of the whole hardware family. Some of the topics are similar
for all board versions. But some differ a little bit from type to type. Please check the given tables for these topics and examine carefully which
settings are valid for your special kind of board.
Register tables
The programming of the boards is totally software register based. All software registers are described in the following form:
If no constants are given below the register table, the dedicated register is used as a switch. All such registers
are activated if written with a “1“ and deactivated if written with a “0“.
Programming examples
In this manual a lot of programming examples are used to give you an impression on how the actual mentioned registers can be set within
your own program. All of the examples are located in a separated colored box to indicate the example and to make it easier to differ it from
the describing text.
All of the examples mentioned throughout the manual are written in C/C++ and can be used with any C/C++ compiler for Windows or Linux.
Complete C/C++ Example
Register
Value
Direction
Description
SPC_M2CMD
100
w
Command register of the board.
M2CMD_CARD_START
4h
Starts the board with the current register settings.
M2CMD_CARD_STOP
40h
Stops the board manually.
#include “../c_header/dlltyp.h”
#include “../c_header/regs.h”
#include “../c_header/spcm_drv.h”
#include <stdio.h>
int main()
{
drv_handle hDrv; // the handle of the device
int32 lCardType; // a place to store card information
hDrv = spcm_hOpen ("/dev/spcm0"); // Opens the board and gets a handle
if (!hDrv) // check whether we can access the card
return -1;
spcm_dwGetParam_i32 (hDrv, SPC_PCITYP, &lCardType); // simple command, read out of card type
printf (“Found card M2i/M3i/M4i.%04x in the system\n”, lCardType & TYP_VERSIONMASK);
spcm_vClose (hDrv);
return 0;
}
The name of the software regis-
ter as found in the regs.h file.
Could directly be used by C/
C++, Delphi and Basic compiler
The decimal value of the software register.
Also found in the regs.h file. This value must
be used with all programs or compilers that
cannot use the header file directly.
Describes whether
the register can be
read (r) and/or writ-
ten (w).
Short description of the function-
ality of the register. A more de-
tailed description is found
above or below the register ta-
bles.
Any constants that can be used to
program the register directly are
shown inserted beneath the register
table.
The decimal or hexadecimal value of the
constant, also found in the regs.h file. Hexa-
decimal values are indicated with an „h“ at
the end. This value must be used with all
programs or compilers that cannot use the
header file directly.
Short description of
the use of this con-
stant.