Code Interfaces and Code Interface Specification - MATLAB & Simulink (original) (raw)

Generated application and component code interacts with target environment services through these generated code interfaces:

This figure shows an example of interaction between a component and platform services in a target execution environment.

Component code interfaces

The arrows indicate the direction of function interface calls. The target function scheduler calls component entry-point functions: Initialize,F1, F2, and Terminate. The component calls target platform services to read input, write output, transfer data between callable functions, and get time values.

For the code generator to produce code that can interact with target environment services, you must make the code generator aware of service interface requirements by using a combination of:

The following figure shows the relationship among:

Relationship between target environment interface requirements, interface specification, and target environment code integration and execution

You inform the code generator about how to generate C or C++ interface code by mapping model elements that represent interfaces, such as functions and root-level inport and outports, to code interfaces that are defined in a code interface configuration file. For example, in the Simulink Editor, you can model an interface for reading data from a target platform receiver service by using a root-level Inport or In Bus Element block. For application deployment, you might also need to include custom blocks that handle data communication requirements. When designing a top model for component deployment, follow the recommended modeling guidelines in Modeling Guidelines for Generated Code.

The code generator supports two types of code interfaces: data and service. You set up the mappings in the Embedded Coder app by using the Code Mappings editor or by using the code mappings programming interface.

For C code interfaces:

This table compares the two types of C code interfaces that you can define in an Embedded Coder Dictionary.

Data Interface In R2022b: Service Interface
For application deployment. For component deployment.
You configure each interface as a storage class, which specifies the appearance and placement of data elements in the generated code. Storage classes apply direct-access data communication. For each interface, you specify function prototype information and data communication method requirements for the generated code. You can configure an interface for direct-access, outside-execution, or during-execution data communication, as required by the target platform.
The code generator applies constraints when producing code so that it is easier to integrate the code for use in a specific target environment. For more information about the constraints, see Service Interface Constraints and Limitations.

If you need to use a data interface to configure a component for deployment, see the Component Deployment Guidelines for Embedded Coder Support Package. If you design and configure a component model according to the guidelines, the code generator produces code that aligns with interface requirements of a specific target platform.

For C++ code generation, you configure a model to use a data code interface. You do not create a code interface configuration. In the Embedded Coder app, you map functions that are represented in a top model to method prototypes. You map data elements that are represented in the top model to data visibility and member access function settings.

See Also

Topics