MATLAB REAL-TIME WORKSHOP 7 - TARGET LANGUAGE COMPILER Guide de l'utilisateur Page 266

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 386
  • Table des matières
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs
Vue de la page 265
10 Targeting Custom Hardware
10-8
You can add your own blocks to a device driver library by writing S-functions
that implement device drivers for your particular I/O board. However, in order
for the code generator to generate code that can call your blocks, they must be
implemented using the API defined by Simulink.
Before beginning the task of creating your own device driver block, you should
consult the Simulink documentation for a description of how to write
S-functions using the API.
Device Driver Blocks
A device driver block is:
A device driver software that handles communication between a real-time
program and an I/O device. See your particular hardware documentation for
information on its requirements.
An S-function — a system function that interacts with Simulink during the
simulation and is linked with the generated code. See the Simulink
documentation for more information.
A C MEX-file — a C subroutine that is dynamically linked to M
ATLAB.See
the MATLAB Application Program Interface Guide for more information on
MEX-files.
A masked Simulink block — masked blocks allow you to define your own
dialog box, icon, and initialization commands for the block. See the Using
Simulink manual for more information on masking blocks.
The S-Function Format
The S-function API requires you to define specific functions and a SimStruct
(a Simulink data structure). Like the generated code, the functions that
implement the S-function are private to the source file. This means you can
generate code for models having multiple instances of the same S-function.
Device driver S-functions are relatively simple to implement because they
perform only a few operations. These operations include:
Initializing the
SimStruct
Initializing the I/O device
Calculating the block outputs according to the type of driver being
implemented:
Vue de la page 265
1 2 ... 261 262 263 264 265 266 267 268 269 270 271 ... 385 386

Commentaires sur ces manuels

Pas de commentaire