Support C Function Prototype Control
This section describes how to configure a custom embedded target to support function prototype control. Without the described modifications, you will not be able to use available interfaces for customizing entry-point function interfaces.
Function prototype control is not supported for component models configured with a service interface. For more information, see Model Code Interfaces and Configure Code Interfaces for Code Generation.
For more information, see Configure Generated C Function Interface for Model Entry-Point Functions.
About C Function Prototype Control and Custom Targets
The requirements for supporting C function prototype control are as follows:
The system target file must be derived from the ERT system target file.
The system target file must declare C function prototype control compliance, as described in Declaring C Function Prototype Control Compliance.
If your system target file uses a custom static main program, and if a nondefault function prototype control configuration is associated with a model, the static main program must call the function prototype controlled initialize and step functions, as described in Providing C Function Prototype Control Support in the Custom Static Main Program.
For an example that shows how to configure custom target optional features, see Customize System Target Files.
Declaring C Function Prototype Control Compliance
To declare C function prototype control compliance for your target, you must implement a
callback function that sets the
ModelStepFunctionPrototypeControlCompliant flag, and then install the
callback function in the
SelectCallback field of the
rtwgensettings structure in your system target file. The callback
function is triggered whenever the user selects the target in the System Target File
Browser. For example, the following system target file code installs a
SelectCallback function named
rtwgensettings.SelectCallback = 'custom_select_callback_handler(hDlg,hSrc)';
The arguments to the
hSrc) are handles to private data used by the
callback API functions. These handles are restricted to use in system target file callback
functions. They should be passed in without alteration.
Your callback function should set the
ModelStepFunctionPrototypeControlCompliant flag as follows:
slConfigUISetVal(hDlg,hSrc,'ModelStepFunctionPrototypeControlCompliant','on'); slConfigUISetEnabled(hDlg,hSrc,'ModelStepFunctionPrototypeControlCompliant',false); hSrc.refreshDialog;
configuration parameter is set to
on, you can use the Configure C Step
Function Interface dialog box to control the function prototype of the base-rate step
function generated for a rate-based model.
Providing C Function Prototype Control Support in the Custom Static Main Program
If your target uses a custom static main program, and if a nondefault function prototype control configuration is associated with a model, you must update the static main program to call the function prototype controlled initialize and step functions. You can do this in either of the following ways:
Manually adapt your static main program to declare model data and call the function prototype controlled initialize and step functions.
Generate your main program by selecting model configuration parameter Generate an example main program. The generated main program declares model data and calls the function prototype controlled initialize and step function.