我是靠谱客的博主 洁净舞蹈,这篇文章主要介绍Simulink自定义目标系统文件配置(5)——srmain.tlc文件前言xx_srmain.tlc 控制主函数文件的生成,现在分享给大家,希望可以做个参考。

前言

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

  • 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模板:

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
%% ============================================================================== %% %% Abstract: %% Example main for bare board target (single rate model) %% %% Copyright 1994-2013 The MathWorks, Inc. %% %selectfile NULL_FILE %function FcnSingleTaskingMain() void %<SetCurrentUtilsIncludesIdx("main_util_incl")> %if GenerateSampleERTMain %assign ::CompiledModel.GenerateSampleERTMain = TLC_FALSE %warning Overriding example ert_main.c! %endif %openfile tmpBuf static boolean_T OverrunFlag = 0; %<SLibDeclareFcnProtoCtlVariables()> %% 这个应该是全局变量 %<LibWriteModelData()> %% 返回模型的数据(仅对ERT有效) %closefile tmpBuf %<SLibCacheCodeToFile("mainSrc_data_defn", tmpBuf)> %openfile tmpBuf #include "%<LibGetMdlPubHdrBaseName()>.h" %closefile tmpBuf %<SLibCacheCodeToFile("mainSrc_incl", 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"} %<SLibDumpFunctionBanner(fcnRec)> %undef fcnRec %<fcnReturns> %<fcnName>(%<fcnParams>) { /* Disable interrupts here */ /* Check for overun */ if (OverrunFlag++) { %<LibSetRTModelErrorStatus(""Overrun"")>; 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 */ %<varsbuf> %endif %<LibCallModelStep(0)> %assign varsbuf = LibWriteModelOutputs() %if varsbuf != "" /* Remove conditional, and get model outputs here */ %<varsbuf> %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"} %<SLibDumpFunctionBanner(fcnRec)> %undef fcnRec %<fcnReturns> %<fcnName>(%<fcnParams>) { /* Unused arguments */ (void)(argc); (void)(argv); /* Initialize model */ %<LibCallModelInitialize()> /* Associate rt_OneStep() with a timer that executes at the base rate of the model */ %<LibCallModelTerminate()> return 0; } %closefile tmpBuf %<SLibCacheCodeToFile("mainSrc_fcn_defn", tmpBuf)> %<SetCurrentUtilsIncludesIdx("")> %endfunction

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

最后

以上就是洁净舞蹈最近收集整理的关于Simulink自定义目标系统文件配置(5)——srmain.tlc文件前言xx_srmain.tlc 控制主函数文件的生成的全部内容,更多相关Simulink自定义目标系统文件配置(5)——srmain.tlc文件前言xx_srmain.tlc内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(79)

评论列表共有 0 条评论

立即
投稿
返回
顶部