文档

自定义生成的C函数接口

Choose an Approach for Customizing Generated C Function Interfaces

为了促进外部和生成的代码的集成并实现符合代码标准和准则,您可以配置代码生成器如何从模型或子系统产生函数接口。对于此级别的自定义,您必须使用基于ERT的系统目标文件配置模型。

配置 更多信息
在模型上默认函数类别(初始化/终止,执行和共享实用程序)的命名规则 为函数配置默认代码生成
单个入口点功能的名称(覆盖默认命名规则) 覆盖单个C入口点功能的默认命名
基本速率步长入口点函数的步骤函数接口(函数名称,返回值和参数C类型限定符,名称和订单) 覆盖默认C步骤函数接口
函数接口(函数名称,返回值和参数C类型限定符,名称和订单)simulink函数和功能呼叫者块金宝app Customize Entry-Point Function Interfaces for Simulink Function and Function Caller Blocks

You can use software-in-the-loop (SIL) testing to verify code generated for customized entry-point functions. Create a SIL block by using your generated code. Then, integrate the SIL block into a model to verify that the generated code provides the same result as the original model or nonvirtual subsystem. For more information, see选择SIL或PIL方法

功能接口自定义限制

这些限制适用于生成功能接口的自定义:

  • 您必须选择模型配置参数单输出/更新功能

  • Multirate models are supported, but you must configure the models for single tasking.

  • 您必须配置根级内部和出口才能使用默认存储类。

  • If you choose to customize a function interface, you must provide your own custom主要的程序。您无法与静态配置函数接口rt_main.c那个笨拙的工作®提供。指定函数接口配置,而不是默认值在生成的代码和默认静态之间创建不匹配rt_main.c

  • 代码生成器删除了模型根源的数据结构,除非由不可撤销功能实现的子系统使用一个或多个室内的值。

  • 代码生成器删除模型根外口的数据结构,除非您启用MAT-FILE记录,或者如果一个或多个出口的样本时间不是基本的基本速率(包括恒定速率)。

  • If you copy a subsystem block to create a block in a new model or the same model, the function interface information from the original subsystem block is not copied to the new subsystem block.

  • 如果您有状态流®,对于使用模型root Inport值或调用使用模型root Inport值的子系统的状态流图表,请执行以下操作以生成代码:

    • 清除Execute (enter) Chart At Initialization状态流图中的复选框。

    • 使Stateflow那种一次性的功能函数。

    • 插入模拟金宝app®信号转换根部插入根后立即阻止。在里面信号转换块参数对话框,选择从“减少块”优化中排除此块

  • If a model root inport value connects to a Simscape™ conversion block, insert a Simulink信号转换在根机构和SIMSCAPE转换块之间块。在里面信号转换块参数对话框,选择从“减少块”优化中排除此块

  • When building a referenced model that is configured with a function interface, do not use virtual buses as inputs or outputs to the referenced model. Use nonvirtual buses instead.

  • 如果C函数接口不是默认值,则忽略了模型配置参数的值通过固定尺寸的标量root输入按代码生成值。有关更多信息,请参阅通过固定尺寸的标量root输入按代码生成值(金宝appSimulink)。

Related Topics