C Service Interfaces
Since R2022b
When generating code from a component model that uses a C service code interface configuration, you map model data elements to service interfaces. A service interface specifies function prototype information and a data communication method (direct access, outside execution, or during execution) for the generated code as required by the target platform services. The code generator applies constraints when producing service interface code so that it is easier to integrate the code for use in a specific target environment. The list of service interfaces available for mapping is determined by interfaces defined in the shared Embedded Coder Dictionary that is attached to the model. If dictionary default service interfaces align with your target platform service requirements, you need not make mapping changes and can skip to generating and reviewing the component interface code.
Tools
Code Mappings Editor – Service Interface | Associate model elements with code interface definitions |
Objects
coder.mapping.api.CodeMapping | Model data and function interface configuration for C code generation |
Functions
Topics
Configuration Fundamentals
- Service Interface Configuration for Model Interface Elements
Control the representation of model data elements and functions in generated C code by using a service code interface configuration. - Code Definition and Mapping Limitations and Considerations
Restrictions, constraints, and considerations that apply to code definitions and code mappings. - Manage Multiple Code Mappings for a Model
Design models that are platform-neutral and ready to deploy to different run-time environments. - How Generated Code Exchanges Data with an Environment
The generated code exchanges signal, state, and parameter data with the calling environment through a data interface.
Callable Function Configuration
- Periodic and Aperiodic Function Interfaces
Generate callable entry-point functions for the algorithm represented by a top model. - Startup, Reset, and Shutdown Function Interfaces
Generate callable entry-point functions for startup, reset, and shutdown processing represented by a model.
Service Interface Configuration
- Service Interfaces
Generate C service interface code for components that interact with target environment resources. - Configure Sender and Receiver Service Interfaces for Model Inports and Outports
Configure sender and receiver service interfaces for model Inports and Outports. - Configure Data Transfer Service Interfaces for Data Transfer Signals
Configure data transfer service interfaces for signals representing data transfers between functions. - Configure Parameter and Parameter Argument Tuning Service Interfaces for Model Parameters and Model Parameter Arguments
Configure parameter and parameter argument tuning service interfaces for model parameters and model parameter arguments. - Configure Measurement Service Interfaces for Signals, States, and Data Stores
Configure measurement services for signals, states, and data stores. - Configure Timer Service Interfaces
Configure timer services for export functions.
Data Access and Initialization
- Reuse Parameter Data in Different Data Type Contexts
Reuse parameter data by creating aSimulink.Parameter
object or numeric MATLAB® variable that you can use in different data type contexts. - Limitations for Block Parameter Tunability in Generated Code
Limitations can prevent a block parameter from appearing in the generated code as tunable, which means you cannot interact with the parameter value after compiling the code. - Access Signal, State, and Parameter Data During Execution
As you iteratively develop a model, capture output signal and state data that model execution generates. Tune parameter values during execution to observe results on the outputs. - Switch Between Sets of Parameter Values During Simulation and Code Execution
Switch between independent sets of values for the same block parameters by storing the sets in an array of structures. - Configure Packaging of Parameter Arguments in Generated Code
Customize the implementation of parameter arguments in generated code. - Control Signal and State Initialization in the Generated Code
Generate code that enables you to store tunable initial conditions in memory, for example, for modeling a system that shuts down and restarts. - Initialization of Signal, State, and Parameter Data in the Generated Code
To match the numerics of a simulation in Simulink®, the generated code assigns initial values to global data, especially for block states and parameters. - Compile Code Conditionally for All Values of Variant Parameters with Same and Different Dimensions
This example shows how to generate a C code that contains all the active and inactive values of variant parameters.