MATLAB REAL-TIME WORKSHOP 7 - TARGET LANGUAGE COMPILER Betriebsanweisung Seite 265

  • Herunterladen
  • Zu meinen Handbüchern hinzufügen
  • Drucken
  • Seite
    / 386
  • Inhaltsverzeichnis
  • LESEZEICHEN
  • Bewertet. / 5. Basierend auf Kundenbewertungen
Seitenansicht 264
Implementing Device Drivers
10-7
Implementing Device Drivers
S-functions can be built into MEX-files or compiled and linked with other code
to become part of a stand-alone program. This dual nature is exploited by the
device driver blocks. These blocks are implemented as C code S-functions. They
are compiled as MEX-files so you can place them in your Simulink block
diagram. When you use the same model to build a real-time program, the
source code for the device driver blocks is automatically compiled and linked
with your program.
Additionally, the Real-Time Workshop uses Target Language Compiler
technology that allows you to inline your S-function. By providing a customized
TLC file containing the definition of your block, you can directly generate the
code for your device driver. The advantage of inlining your S-function in this
fashion is the elimination of function call overhead associated with the
S-function interface.
It is helpful to examine existing device driver code in conjunction with this
chapter. The source code for the blocks resides in the following directories:
matlabroot/rtw/c/dos/devices directory for the source code to blocks in
doslib.
matlabroot/rtw/c/tornado/devices directory for the source code to blocks
in
vxlib.
There is also an S-function template that provides a useful starting point for
the creation of any S-function. The file is
matlabroot/simulink/src/sfuntmpl.c
or
matlabroot/simulink/src/sfuntmpl.doc
Note This chapter does not discuss inlining of S-functions. Refer to “Inlining
an S-function” in the Target Language Compiler Reference Guide.
Device drivers are implemented as C MEX S-functions. When you insert these
blocks into your Simulink model, the code generator compiles and links the
block’s source along with the source files used to build your program.
Seitenansicht 264
1 2 ... 260 261 262 263 264 265 266 267 268 269 270 ... 385 386

Kommentare zu diesen Handbüchern

Keine Kommentare