MC9S12XEP底层驱动封装库 (一)

注意:

tlc文件通常分为两个等价,系统级和模块级。系统目标文件(system target file),例如ert.tlc就是常用的系统目标文件

系统目标文件非常特殊,%%也不都是注释,像这里告诉了Simulink环境,目标文件支持哪些功能,例如生成

一、MC9S12XEP底层驱动封装库

MC9S12XEP100.tlc(系统目标文件)

系统目标文件是控制主体代码生成,对代码生成进行全局的控制

%% SYSTLC: my_MC9S12XEP100 TMF: none  MAKE: make_rtw  EXTMODE: ext_comm 
  • SYSTLC :对于系统目标文件(.tlc)的描述

  • TMF :不生成tmf文件的模板

  • MAKE :支持MAKE命令

  • EXTMOD : ext_comm 支持外部模式

%selectfile NULL_FILE
%assign CodeFormat = "Embedded-C"
%assign TargetType = "RT"
%assign Language   = "C"
%assign AutoBuildProcedure = !GenerateSampleERTMain
%include "codegenentry.tlc"
  • %assign CodeFormat :函数级或者非脚本类型的tlc,需要包含NULL_FILE

  • %assign TargetType :“Embedded-C”嵌入式代码支持的生成代码类型

  • assign Language :“RT” 单片机都是实时的硬件,所以用RT(real time)

  • assign AutoBuildProcedure : 这里指的是不生成Main文件,在此处也可以不写,自己去configuration里面选,相当于下图的蓝线没有勾选。

  • %include "codegenentry.tlc" :" codegenentry.tlc" 继承codegenentry内容

tlc里面的include和c语言不同,C语言是告诉程序包含了哪些头文件,可以去头文件里面寻找函数等,tlc的include相当于inline, 内联的功能,相当于直接展开到文件中。

/%
  BEGIN_RTW_OPTIONS
  END_RTW_OPTIONS 
%/

BEGIN_RTW_OPTIONS和END_RTW_OPTIONS中间这部分也是有用的,是对关于GUI的一些配置。

  rtwoption_index = 1;
  rtwoptions(rtwoption_index).prompt         = 'MC9S12XEP100 Target Options';
  rtwoptions(rtwoption_index).type           = 'Category';
  rtwoptions(rtwoption_index).enable         = 'on';  
  rtwoptions(rtwoption_index).default        = 1;  //有几个子模块
  rtwoptions(rtwoption_index).popupstrings  = '';
  rtwoptions(rtwoption_index).tlcvariable   = '';
  rtwoptions(rtwoption_index).tooltip       = '';
  rtwoptions(rtwoption_index).callback      = '';
  rtwoptions(rtwoption_index).makevariable  = '';
  
  
  rtwoption_index = rtwoption_index + 1;
  rtwoptions(rtwoption_index).prompt         = 'Actions';   
  rtwoptions(rtwoption_index).type           = 'Popup';         //下拉框
  rtwoptions(rtwoption_index).popupstrings   = 'Build|Run'; //这里设置的是Action的下拉框里面有两个值可以选择Build或者Run
  rtwoptions(rtwoption_index).enable         = 'on';  
  rtwoptions(rtwoption_index).default        = 'Build';   //Action选项的默认是Build
  rtwoptions(rtwoption_index).tlcvariable    = 'BuildAction';
  rtwoptions(rtwoption_index).tooltip        = 'Select CodeWarrior BuildAction.';
  rtwoptions(rtwoption_index).callback       = '';
  rtwoptions(rtwoption_index).makevariable   = '';

显示如下

rtwgensettings.BuildDirSuffix = ‘_MC9S12XEP100_rtw’;

//这个是设置代码的生成文件名,比如说你起了个simulink模型的名字是test,那么他便一直后生成的代码的文件的名字就是test_MC9S12XEP100_rtw;

rtwgensettings.SelectCallback = [‘MC9S12XEP100_callback_handler(hDlg, hSrc)’];

//这个是选择回调函数 就是你点击下图中的APPLY或者OK的时候执行的脚本函数

完整代码如下:

%% SYSTLC: my_MC9S12XEP100 TMF: none  MAKE: make_rtw  EXTMODE: ext_comm 
​
%selectfile NULL_FILE
%assign CodeFormat = "Embedded-C"
%assign TargetType = "RT"
%assign Language   = "C"
​
%assign AutoBuildProcedure = !GenerateSampleERTMain
%include "codegenentry.tlc"
​
/%
  BEGIN_RTW_OPTIONS
​
  rtwoption_index = 1;
  rtwoptions(rtwoption_index).prompt         = 'MC9S12XEP100 Target Options';
  rtwoptions(rtwoption_index).type           = 'Category';
  rtwoptions(rtwoption_index).enable         = 'on';  
  rtwoptions(rtwoption_index).default        = 1;  
  rtwoptions(rtwoption_index).popupstrings  = '';
  rtwoptions(rtwoption_index).tlcvariable   = '';
  rtwoptions(rtwoption_index).tooltip       = '';
  rtwoptions(rtwoption_index).callback      = '';
  rtwoptions(rtwoption_index).makevariable  = '';
​
  rtwoption_index = rtwoption_index + 1;
  rtwoptions(rtwoption_index).prompt         = 'Actions';
  rtwoptions(rtwoption_index).type           = 'Popup';
  rtwoptions(rtwoption_index).popupstrings   = 'Build|Run';
  rtwoptions(rtwoption_index).enable         = 'on';  
  rtwoptions(rtwoption_index).default        = 'Build';   
  rtwoptions(rtwoption_index).tlcvariable    = 'BuildAction';
  rtwoptions(rtwoption_index).tooltip        = 'Select CodeWarrior BuildAction.';
  rtwoptions(rtwoption_index).callback       = '';
  rtwoptions(rtwoption_index).makevariable   = '';
​
  %----------------------------------------%
  % Configure RTW code generation settings %
  %----------------------------------------%
  rtwgensettings.BuildDirSuffix = '_MC9S12XEP100_rtw';
  rtwgensettings.DerivedFrom = 'ert.tlc';
  rtwgensettings.Version = '1';
  rtwgensettings.SelectCallback = ['MC9S12XEP100_callback_handler(hDlg, hSrc)'];
​
  END_RTW_OPTIONS 
%/
  • 35
    点赞
  • 27
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值