Spectrum Brands MC.31XX 用户手册

下载
页码 102
36
MC.31xx Manual
Overview
Programming the Board
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 focussed 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 seperated 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 basically written using the Visual C++ compiler for Windows. If you use Linux there 
are some changes in the funtion’s parameter lists as mentioned in the relating software chapter.
To keep the examples as compatible as possible for users of both operational systems (Windows and Linux) all the functions that 
contain either a board number (Windows) or a handle (Linux) use the common parameter name ’hDrv’. Windows users simply have 
to set the parameter to the according board number (as the example below is showing), while Linux users can easily use the handle 
that is given back for the according board by the initialization function.
Error handling
If one action caused an error in the driver this error and the register and value where it occurs will be saved.
The driver is then locked until the error is read out using the SPC_LASTERRORCODE function. All other functions 
will lead to the same errorcode unless the error is cleared by reading SPC_LASTERRORCODE.
Register
Value
Direction
Description
SPC_COMMAND
0
r/w
Command register of the board.
SPC_START
10
Starts the board with the current register settings.
SPC_STOP
20
Stops the board manually.
// Windows users must set hDrv to the according board number before.
// Assuming that there is only one Spectrum board installed you’ll 
// have to set hDrv like this:
hDrv = 0;
SpcGetParam (hDrv, SPC_LASTERRORCODE,  &lErrorCode); // Any command just to show the hDrv usage
The name of the software regis-
ter as found in the regs.h file. 
Could directly be used by C and 
C++ 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-
tailled description is found 
above or below this register. 
Any constants that can be used to 
program the register directly are 
shown inserted beneath the register 
table.
The decimal value of the constant. Also 
found in the regs.h file. 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.