User`s guide
Implementing Device Drivers
10-11
S_FUNCTION_NAME Definition
The statement
#define S_FUNCTION_NAME name
defines the name of the function that is the entry point for the S-function code.
This function is defined in
cg_sfun.h, which is included at the end of the
S-function. Note that
name must be the name of the S-function file without the
.c extension (e.g., dt2811ad for the Data Translation DT2811 A/D block). Also,
you must specify the
S_FUNCTION_NAME before you include simstruc.h.
Level 2 S-Function Definition
The statement
#define S_FUNCTION_LEVEL 2
defines the S-function as level 2. This allows you to take advantage of the full
feature set included with S-functions, while maintaining backwards
compatibility with older S-functions.
Defining the SimStruct
You must include the file simstruc.h to define the SimStruct (the Simulink
data structure) and the
SimStruct access macros:
#include "simstruc.h"
simstruc.h
itself includes rt_matrx.h, which contains definitions for mxGetPr
(and other matrix access macros). These mx macros are equivalent to those with
the same name defined in M
ATLAB’s Application Program Interface Library.
They are used to obtain the parameters specified in the device driver’s dialog
box. See the Application Program Interface Guide for more information on
matrix access macros.
This parallel definition of matrix access macros allows the same source code to
be used as a MEX-file or as a source module that is compiled and linked with
the generated code.