C Service Interfaces
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 linked 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.
|Code Mappings Editor – Service Interface||Associate model elements with code interface definitions|
|Model data and function interface configuration for C code generation|
Generated Entry Points
|Generated C/C++ entry-point function that contains initialization code for a Simulink model|
|Generated C/C++ entry-point function that contains reset code for a Simulink model|
|Generated C/C++ entry-point function that contains execution code for each step in a Simulink model|
|Generated C/C++ entry-point function that contains termination code for a Simulink model|
Service Interface Configuration for C Code Generation
Create and Find Code Mappings
|Get code mappings for model|
|Create code mappings object for configuring data and function interface for C and C++ code generation|
|Get model elements for the category of model code mappings|
|Get code configuration from code mappings for model function|
|Set code mapping information for model function|
Root-Level Inport and Outport Configuration
|Get code and calibration configuration from code mappings for root-level inport|
|Get code and calibration configuration from code mappings for root-level outport|
|Get deployment type of model|
|Configure root-level inports for code and calibration file (a2l) generation|
|Configure root-level outport for code and calibration file (a2l) generation|
|Set deployment type of model|
|Get code and calibration configuration from code mappings for model parameters|
|Configure model parameter for code and calibration file (a2l) generation|
Signal, State, and Data Store Configuration
|Add block output signal to model code mappings|
|Get code and calibration configuration from code mappings for local or shared local data store|
|Get code and calibration configuration from code mappings for block output signal|
|Get code and calibration configuration from code mappings for block state|
|Remove block output signal from model code mappings|
|Configure local or shared local data store for code and calibration file (a2l) generation|
|Configure block signal data for code and calibration file (a2l) generation|
|Configure block states for code and calibration file (a2l) generation|
Data Transfer 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
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 for Aperiodic Export Functions
Configure timer services for export functions.
Data Access and Initialization
- Reuse Parameter Data in Different Data Type Contexts
Reuse parameter data by creating a
Simulink.Parameterobject 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.