The code generator includes a variety of approaches for integrating legacy or custom code with generated code. Legacy code is existing handwritten code or code for environments that you integrate with code that the code generator produces. Custom code is legacy code or other user-specified lines of code that you include in the code generator build process. Collectively, legacy and custom code are called external code.
You integrate external code by importing existing external code into code produced by the code generator, exporting generated code into an existing external code base, or you can do both. For example, you can import code by calling an external function, by using the Legacy Code Tool, or place external code at specific locations in generated code by including Custom Code blocks in a model. When you import external code, the resulting generated code interfaces with generated scheduling code.
You can export generated code as a plug-in function for use in an external development environment. When you export generated code, you intend to interface that code manually with a scheduling mechanism in your application run-time environment.
For guidance on choosing an approach based on your application requirements, see Choose an External Code Integration Workflow .
|System Derivatives||Specify external system derivative code|
|System Disable||Specify external system disable code|
|System Enable||Specify external system enable code|
|System Initialize||Specify external system initialization code|
|System Outputs||Specify external system outputs code|
|System Start||Specify external system startup code|
|System Terminate||Specify external system termination code|
|System Update||Specify external system update code|
What external code integration is.
For application integration points, characterize external code, identify code generation integration requirements, and choose a workflow.
Use of untrusted custom code entails risk.
Call external algorithmic code, which is hardware-independent and reusable, from generated code.
Place C/C++ code into code generated for a model.
Integrate legacy C++ object methods by using the Legacy Code Tool.
Call external device drivers from generated code.
Configure the code generator to replace functions and operators for alignment with external code or run-time environment requirements.
Add support files and control model code generation and builds within the Simulink Environment.
Configure the signals, states, and parameters in a Simulink® model to match the data interface of your existing C code.
When you export the generated code into your external code, exchange signal, state, and parameter data.
The generated code exchanges signal, state, and parameter data with the calling environment through a data interface.
Control how generated code exchanges data with a calling environment.
Customize the data interface of a model to enable integration of the generated code with your own code and to improve code traceability and readability.
Configure how the code generator applies identifiers (symbols), comments, code styles, code format, and organization.