1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2 %% $RCSfile: example_file_process.tlc,v $
3 %% $Revision: 1.1.6.5 $
4 %% $Date: 2010/09/13 16:20:21 $
7 %% Example Embedded Coder custom file processing template.
9 %% Note: This file can contain any valid TLC code, which Embedded Coder
10 %% executes just prior to writing the generated source files to disk.
11 %% Using this template "hook" file, you are able to augment the generated
12 %% source code and create additional files.
14 %% Copyright 1994-2010 The MathWorks, Inc.
16 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
19 %% Uncomment this TLC line to execute the example
23 %% %assign ERTCustomFileTest = TLC_TRUE
25 %if EXISTS("ERTCustomFileTest") && ERTCustomFileTest == TLC_TRUE
27 %% Need to set the template compliance flag before you can use the API
28 %<LibSetCodeTemplateComplianceLevel(1)>
30 %% Add a new C file timestwo.c and put a simple function in it
32 %assign cFile = LibCreateSourceFile("Source", "Custom", "timestwo")
38 %closefile tmwtypesBuf
40 %<LibSetSourceFileSection(cFile,"Includes",tmwtypesBuf)>
44 /* Times two function */
45 real_T timestwofcn(real_T input) {
51 %<LibSetSourceFileSection(cFile,"Functions",tmpBuf)>
53 %% Add a corresponding H file timestwo.h
55 %assign hFile = LibCreateSourceFile("Header", "Custom", "timestwo")
59 /* Times two function */
60 extern real_T timestwofcn(real_T input);
64 %<LibSetSourceFileSection(hFile,"Includes",tmwtypesBuf)>
65 %<LibSetSourceFileSection(hFile,"Declarations",tmpBuf)>
67 %% Add a #define to the model's public header file model.h
69 %assign pubName = LibGetMdlPubHdrBaseName()
70 %assign modelH = LibCreateSourceFile("Header", "Simulink", pubName)
74 #define ACCELERATION 9.81
78 %<LibSetSourceFileSection(modelH,"Defines",tmpBuf)>
80 %% Add a #define to the model's private header file model_private.h
82 %assign prvName = LibGetMdlPrvHdrBaseName()
83 %assign privateH = LibCreateSourceFile("Header", "Simulink", prvName)
87 #define STARTING_POINT 100.0
91 %<LibSetSourceFileSection(privateH,"Defines",tmpBuf)>
93 %% Add a #include to the model's C file model.c
95 %assign srcName = LibGetMdlSrcBaseName()
96 %assign modelC = LibCreateSourceFile("Source", "Simulink", srcName)
99 /* #include "mytables.h" */
102 %<LibSetSourceFileSection(modelC,"Includes",tmpBuf)>
104 %% Create a simple main. Files are located in MATLAB/rtw/c/tlc/mw.
106 %if LibIsSingleRateModel() || LibIsSingleTasking()
107 %include "bareboard_srmain.tlc"
108 %<FcnSingleTaskingMain()>
110 %include "bareboard_mrmain.tlc"
111 %<FcnMultiTaskingMain()>