Main Content

C 数据接口和函数接口

将模型数据元素和函数映射到独立于模型的代码定义

为了遵守代码标准和规范,将生成的代码与外部代码集成,并满足内存要求,需要针对代码生成配置模型数据元素和入口函数的表示。您可以将模型数据元素和函数映射到由产品预定义或使用 Embedded Coder 字典创建的代码定义。对于数据元素,您还可以选择将它们映射到使用自定义存储类设计器在包中创建的代码定义。

有关介绍,请参阅C Data Code Interface Configuration for Model Interface Elements

工具

代码映射编辑器 - CAssociate model elements with code interface definitions

对象

coder.mapping.api.CodeMapping用于 C 代码生成的模型数据和函数接口配置 (自 R2020b 起)
coder.mapping.api.CoderDictionaryQuery and set the code settings of dictionary defaults in an Embedded Coder dictionary within a Simulink data dictionary (自 R2021a 起)

函数

全部展开

model_initializeGenerated C/C++ entry-point function that contains initialization code for a Simulink model
model_resetGenerated C/C++ entry-point function that contains reset code for a Simulink model
model_stepGenerated C/C++ entry-point function that contains execution code for each step in a Simulink model
model_terminateGenerated C/C++ entry-point function that contains termination code for a Simulink model

创建和查找代码映射

coder.mapping.api.getGet code mappings for model (自 R2020b 起)
coder.mapping.utils.createCreate code mappings object for configuring data and function interface for C and C++ code generation (自 R2020b 起)
findGet model elements for the category of model code mappings (自 R2020b 起)

默认配置

getDataDefaultGet default storage class or storage class property setting for model data category (自 R2020b 起)
getFunctionDefaultGet default function customization template or memory section for model functions category (自 R2020b 起)
setDataDefaultSet default storage class and storage class property values for model data category (自 R2020b 起)
setFunctionDefaultSet default function customization template and memory section for model functions category (自 R2020b 起)

函数配置

getFunctionGet code configuration from code mappings for model function (自 R2020b 起)
setFunctionSet coder mapping information for model function (自 R2020b 起)

根级输入端口和输出端口配置

getInportGet code and calibration configuration from code mappings for root-level inport (自 R2020b 起)
getOutportGet code and calibration configuration from code mappings for root-level outport (自 R2020b 起)
getDeploymentTypeGet deployment type of model (自 R2022a 起)
setInportConfigure root-level inports for code and calibration file (a2l) generation (自 R2020b 起)
setOutportConfigure root-level outport for code and calibration file (a2l) generation (自 R2020b 起)
setDeploymentTypeSet deployment type of model (自 R2022a 起)

参数配置

getModelParameterGet code and calibration configuration from code mappings for model parameters (自 R2020b 起)
setModelParameterConfigure model parameter for code and calibration file (a2l) generation (自 R2020b 起)

信号、状态和数据存储配置

addSignalAdd block output signal to model code mappings (自 R2020b 起)
getDataStoreGet code and calibration configuration from code mappings for local or shared local data store (自 R2020b 起)
getSignalGet code and calibration configuration from code mappings for block output signal (自 R2020b 起)
getStateGet code and calibration configuration from code mappings for block state (自 R2020b 起)
removeSignalRemove block output signal from model code mappings (自 R2020b 起)
setDataStoreConfigure local or shared local data store for code and calibration file (a2l) generation (自 R2020b 起)
setSignalConfigure block signal data for code and calibration file (a2l) generation (自 R2020b 起)
setStateConfigure block states for code and calibration file (a2l) generation (自 R2020b 起)

代码生成器字典配置

setDataDefaultSet default code settings for data category (自 R2021a 起)
getDataDefaultGet default code settings for data category (自 R2021a 起)
setFunctionDefaultSet default function customization template and memory section for model functions category (自 R2021a 起)
getFunctionDefaultGet default function customization template or memory section for model functions category (自 R2021a 起)

主题

配置基础

C 数据配置

C 函数配置

数据访问和初始化

相关信息