User`s guide
10 Targeting Custom Hardware
10-4
Run-Time Interface
There are two ways to target custom hardware:
• Rapid prototyping
• Embedded real-time
Rapid prototyping targets have an environment similar to the generic
real-time or Tornado target. This section describes how to create a Run-time
interface for a rapid prototyping target.
To create a run-time interface (i.e., a main program), you can begin with the
generic real-time target (
grt). The run-time interface for grt consists of:
•
grt_main.c —locatedinmatlabroot/rtw/c/grt
• rt_sim.c — located in matlabroot/rtw/c/src
• ode1.c - ode5.c — you must use one of these solvers if your model has
continuous states. These are located in
matlabroot/rtw/c/src.
• library routines for the model code — located in
matlabroot/rtw/c/libsrc
For your run-time interface, you will need to copy and modify grt_main.c.The
other modules do not require modification.
To create a new target called
mytarget, start by creating a directory. For
example, create
/applications/mytarget
and add it to your MATLAB path.
Copy
grt_main.c to this directory and rename it rt_main.c. You will then need
to modify
rt_main.c to execute your model code. By default, grt_main.c is set
up to execute your code in pseudomultitasking mode. If your target has a
real-time operating system, you will need to modify
rt_main.c to include calls
for task creation and management. See Chapter 6, “Program Architecture,”
and Chapter 7, “Models with Multiple Sample Rates,” for more details on the
model code and how it is executed. The Tornado target is an example of a
system that has a real-time operating system (see
matlabroot/rtw/c/
tornado/rt_main.c
for the Tornado main module). Refer to Chapter 8,
“Targeting Tornado for Real-Time Applications,” for detailed information
about targeting Tornado.