Target Language Compiler |
 |
Solution
%% File : dp_read.tlc
%% Abstract:
%% Dual-Port Read block target file for S-function dp_read.
%%
%% Copyright (c) 1994-1999 by The MathWorks, Inc. All Rights Reserved.
%%
%implements "dp_read" "C"
%% Function: Outputs ==========================================================
%% Abstract:
%% Dual port read for the dp_read.mex S-function, (e.g. dp_read.dll).
%% Read the value from the specified address entered in the S-function
%% parameters and write to the output location:
%% Y = *dpAddress
%%
%% In the dp_read, the Parameters are defined to be:
%% offset,gain,variableType,hardwareAddress
%%
%function Outputs(block, system) Output
/* %<Type> Block: %<Identifier> */
{
%assign offset = CAST("Real",P1.Value[0])
%assign gain = CAST("Real",P2.Value[0])
%assign varType = LibBlockParameterString(P3)
%assign hwAddress = LibBlockParameterString(P4)
%assign y = LibBlockOutputSignal(0, "", "", 0)
volatile %<varType> *dpAddress = (%<varType> *) %<hwAddress>;
%<y> = ((real_T) *dpAddress) * %<gain> + %<offset>;
}
%endfunction %% Outputs
| Further Hints | | "Hello World" Example with model.rtw File |  |