Motorola DSP Developer's Kit | ![]() ![]() |
Input Objects
Pointers to MOTDSP_Input
objects only are declared outside the try
block of the mdlOutputs
function.
MOTDSP_Input* a = PTR_NIL; MOTDSP_Input* b = PTR_NIL;
Before creating MOTDSP_Input
objects declare InputPtrsType
pointers to all possible input ports using the specific Simulink 'ss' macros.
For example, for input Port 1 use
InputPtrsType uPtrs1 = ssGetInputPortSignalPtrs(S,0);
InputPtrsType uPtrs2 = ssGetInputPortSignalPtrs(S,1);
Also, you must declare a pointer to an mxArray
for each possible input port.
mxArray *array_ptr1; mxArray *array_ptr2;
Then use the support functions MOTDSP_CreateComplexMatrix
or MOTDSP_CreateRealMatrix
to create a valid matrix after checking its type:
//Determine whether the port is complex. const boolean_T c0 = (boolean_T)(ssGetInputPortComplexSignal(S,0) == COMPLEX_YES); //Then create the correct matrix: if (!c0) { /* If the matrix is Real... Use the MOTDSP_ function to create the appropriate matrix..*/ MOTDSP_CreateRealMatrix(&array_ptr1, (double *)*uPtrs1, width); }
Remember to clear the memory created for each mxArray
by calling the mxDestroyArray
function.
Finally, create a pointer to right hand side (prhs) MEX equivalent variable before mapping the input ports to variables. For example,
const mxArray *prhs [] = {array_ptr1, array_ptr2}; CREATE_INPUT_ARG(a,0); CREATE_INPUT_ARG(b,1);
Information about the variables is accessed by the supplied methods as described previously in MATLAB MEX-Files.
![]() | Simulink S-Function MEX-Files | Output Objects | ![]() |