您当前的位置: 首页 > 

Autism_Huang

暂无认证

  • 8浏览

    0关注

    27博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

Simulink自定义目标系统文件配置(5)——srmain.tlc文件

Autism_Huang 发布时间:2022-09-22 08:00:00 ,浏览量:8

前言

自定义目标系统文件由五大文件组成:

  • xx.tlc 系统目标文件
  • xx_callback_handler.m RTW工具箱回调函数
  • xx_make_rtw_hook.m tlc文件调用
  • xx_file_process.tlc 文件处理TLC文件
  • xx_srmain.tlc 控制主函数文件的生成
xx_srmain.tlc 控制主函数文件的生成

这个文件就是用来控制生成的main文件需要生成什么和怎么生成。

这个文件是被file_process调用的,所以如果要自定义srmain.tlc的话,一定要在file_process文件里面修改对应的tlc。 修改操作 bareboard_srmain.tlc模板:

%% ==============================================================================
%%
%% Abstract:
%%   Example main for bare board target (single rate model)
%%
%% Copyright 1994-2013 The MathWorks, Inc.
%%
%selectfile NULL_FILE

%function FcnSingleTaskingMain() void
  
  %
  
  %if GenerateSampleERTMain
    %assign ::CompiledModel.GenerateSampleERTMain = TLC_FALSE
    %warning Overriding example ert_main.c!
  %endif

  %openfile tmpBuf
  static boolean_T OverrunFlag = 0;\
  
  %\
%% 这个应该是全局变量  

  %\
%% 返回模型的数据(仅对ERT有效)
  %closefile tmpBuf
  
  %
  
  %openfile tmpBuf
  #include "%.h"
  %closefile tmpBuf
 
  %
  
  %openfile tmpBuf
  %assign fcnReturns = "void"
  %assign fcnName = "rt_OneStep"
  %assign fcnParams = ""
  %assign fcnCategory = "main"
  %createrecord fcnRec {Name fcnName; Returns fcnReturns; Params fcnParams; ...
    Abstract ""; Category fcnCategory; GeneratedBy "bareboard_srmain.tlc"; ...
    Type "Utility"}
  %
  %undef fcnRec
  % %(%)
  {
    /* Disable interrupts here */
    
    /* Check for overun */
    if (OverrunFlag++) {
      %;
      return;
    }
    
    /* Save FPU context here (if necessary) */
    /* Re-enable timer or interrupt here */
    %assign varsbuf = LibWriteModelInputs()
    %if varsbuf != ""
      /* Remove conditional, and set model inputs here */
      %\
    %endif
    
    %\
    
    %assign varsbuf = LibWriteModelOutputs()
    %if varsbuf != ""
      /* Remove conditional, and get model outputs here */
      %\
    %endif
    
    OverrunFlag--;
    
    /* Disable interrupts here */
    /* Restore FPU context here (if necessary) */
    /* Enable interrupts here */
  }
   
  %assign fcnReturns = "int_T"
  %assign fcnName = "main"
  %assign fcnParams = "int_T argc, const char *argv[]"
  %assign fcnCategory = "main"
  %createrecord fcnRec {Name fcnName; Returns fcnReturns; Params fcnParams; ...
    Abstract ""; Category fcnCategory; GeneratedBy "bareboard_srmain.tlc"; ...
    Type "Main"}
  %
  %undef fcnRec
  % %(%)
  {
    
    /* Unused arguments */
    (void)(argc);
    (void)(argv);
    
    /* Initialize model */
    %\
    
    /* Associate rt_OneStep() with a timer that executes at the base rate of the model */

    %\
    return 0;
  }
  %closefile tmpBuf
  
  %

  %
  
%endfunction

通过运行这个TLC文件,可以生成我们自定义的main函数以及中断函数,同时模型运行函数也可以放到自己想要运行的地方运行。

关注
打赏
1655915590
查看更多评论
立即登录/注册

微信扫码登录

0.0506s