1 %% SYSTLC: Embedded Coder TMF: ert_default_tmf MAKE: make_rtw \
3 %% SYSTLC: Create Visual C/C++ Solution File for the Embedded Coder\
4 %% TMF: RTW.MSVCBuild MAKE: make_rtw EXTMODE: ext_comm
9 %% Copyright 1994-2011 The MathWorks, Inc.
10 %% Abstract: Embedded real-time system target file.
14 %assign CodeFormat = "Embedded-C"
16 %assign TargetType = "RT"
17 %assign Language = "C"
18 %if !EXISTS("AutoBuildProcedure")
19 %assign AutoBuildProcedure = !GenerateSampleERTMain
22 %% The model_SetEventsForThisBaseRate function is not required for the
23 %% VxWorks environment, i.e., when using an operating system.
24 %assign SuppressSetEventsForThisBaseRateFcn = (TargetOS == "VxWorksExample")
25 %if !EXISTS("InlineSetEventsForThisBaseRateFcn")
26 %assign InlineSetEventsForThisBaseRateFcn = TLC_TRUE
28 %if !EXISTS("SuppressMultiTaskScheduler")
29 %assign SuppressMultiTaskScheduler = TLC_TRUE
32 %assign TargetRegistMutexOp = 1
33 %assign TargetRegistSynchroOp = 1
34 %include "commontargetlib.tlc"
36 %include "codegenentry.tlc"
38 %% The contents between 'BEGIN_RTW_OPTIONS' and 'END_RTW_OPTIONS' in this file
39 %% are used to maintain backward compatibility to R13 and preR13 custom target
40 %% file only. If you want to use this file as a template to develop your
41 %% own system target file, you need to remove the 'CONFIGSET_TARGET_COMPONENT'
42 %% section at the end of this file.
49 rtwoptions(oIdx).prompt = 'ERT code generation options (1)';
50 rtwoptions(oIdx).type = 'Category';
51 rtwoptions(oIdx).enable = 'on';
52 rtwoptions(oIdx).default = 7; % number of items under this category
54 rtwoptions(oIdx).popupstrings = '';
55 rtwoptions(oIdx).tlcvariable = '';
56 rtwoptions(oIdx).tooltip = '';
57 rtwoptions(oIdx).callback = '';
58 rtwoptions(oIdx).opencallback = '';
59 rtwoptions(oIdx).closecallback = '';
60 rtwoptions(oIdx).makevariable = '';
64 rtwoptions(oIdx).prompt = 'MAT-file logging';
65 rtwoptions(oIdx).type = 'Checkbox';
66 rtwoptions(oIdx).default = 'off';
67 rtwoptions(oIdx).tlcvariable = 'MatFileLogging';
68 rtwoptions(oIdx).makevariable = 'MAT_FILE';
69 rtwoptions(oIdx).callback = 'ert_callback_handler';
70 rtwoptions(oIdx).tooltip = sprintf([...
71 'Instrument the generated code to log data to a MATLAB .mat\n',...
72 'file. Deselect this option to reduce ROM.']);
76 rtwoptions(oIdx).prompt = 'Integer code only';
77 rtwoptions(oIdx).type = 'Checkbox';
78 rtwoptions(oIdx).default = 'off';
79 rtwoptions(oIdx).tlcvariable = 'PurelyIntegerCode';
80 rtwoptions(oIdx).makevariable = 'INTEGER_CODE';
81 rtwoptions(oIdx).callback = 'ert_callback_handler';
82 rtwoptions(oIdx).tooltip = sprintf([...
83 'Selected, raise an error if the generated code contains\n',...
84 'floating point data types, and do not include floating\n',...
85 'point utilities in the code generation runtime libsrc library.']);
89 rtwoptions(oIdx).prompt = 'Initialize internal data';
90 rtwoptions(oIdx).type = 'Checkbox';
91 rtwoptions(oIdx).default = 'on';
92 rtwoptions(oIdx).tlcvariable = 'ZeroInternalMemoryAtStartup';
93 rtwoptions(oIdx).tooltip = sprintf([...
94 'Initialize internal data structures to zero during model\n', ...
95 'registration. Deselecting this option reduces ROM.']);
99 rtwoptions(oIdx).prompt = 'Initialize external I/O data';
100 rtwoptions(oIdx).type = 'Checkbox';
101 rtwoptions(oIdx).default = 'on';
102 rtwoptions(oIdx).tlcvariable = 'ZeroExternalMemoryAtStartup';
103 rtwoptions(oIdx).tooltip = sprintf([...
104 'Initialize root I/O data structures to zero during model\n',...
105 'registration. Deselecting this option reduces ROM.']);
109 rtwoptions(oIdx).prompt = 'Terminate function required';
110 rtwoptions(oIdx).type = 'Checkbox';
111 rtwoptions(oIdx).default = 'on';
112 rtwoptions(oIdx).tlcvariable = 'IncludeMdlTerminateFcn';
113 rtwoptions(oIdx).makevariable = 'INCLUDE_MDL_TERMINATE_FCN';
114 rtwoptions(oIdx).tooltip = sprintf([...
115 'Include a model terminate function.']);
121 % NEVER REMOVE THE OPTION CombineOutputUpdateFcns FROM THE UI!
123 % REMOVING THE OPTION FROM THE UI RESULTS IN INEFFICIENT GENERATED CODE.
125 rtwoptions(oIdx).prompt = 'Single output/update function';
126 rtwoptions(oIdx).type = 'Checkbox';
127 rtwoptions(oIdx).default = 'on';
128 rtwoptions(oIdx).tlcvariable = 'CombineOutputUpdateFcns';
129 rtwoptions(oIdx).makevariable = 'COMBINE_OUTPUT_UPDATE_FCNS';
130 rtwoptions(oIdx).tooltip = sprintf([...
131 'Generate the model output and update routines into a\n',...
132 'single step function.']);
136 rtwoptions(oIdx).prompt = 'Insert block descriptions in code';
137 rtwoptions(oIdx).type = 'Checkbox';
138 rtwoptions(oIdx).default = 'off';
139 rtwoptions(oIdx).tlcvariable = 'InsertBlockDesc';
140 rtwoptions(oIdx).tooltip = sprintf([...
141 'Insert the Description field from the Block Properties dialog into the\n', ...
142 'generated C code as a comment. Note that virtual blocks and blocks\n', ...
143 'involved in block reduction optimizations are not included.']);
147 rtwoptions(oIdx).prompt = 'ERT code generation options (2)';
148 rtwoptions(oIdx).type = 'Category';
149 rtwoptions(oIdx).enable = 'on';
150 rtwoptions(oIdx).default = 7; % number of items under this category
154 rtwoptions(oIdx).prompt = 'Create SIL block';
155 rtwoptions(oIdx).type = 'Checkbox';
156 rtwoptions(oIdx).default = 'off';
157 rtwoptions(oIdx).tlcvariable = 'GenerateErtSFunction';
158 rtwoptions(oIdx).makevariable = 'GENERATE_ERT_S_FUNCTION';
159 rtwoptions(oIdx).tooltip = sprintf([...
160 'Wrap the generated code inside an S-Function block.\n', ...
161 'This allows you to validate the generated code in\n', ...
166 rtwoptions(oIdx).prompt = 'Generate ASAP2 file';
167 rtwoptions(oIdx).type = 'Checkbox';
168 rtwoptions(oIdx).default = 'off';
169 rtwoptions(oIdx).tlcvariable = 'GenerateASAP2';
170 rtwoptions(oIdx).makevariable = 'GENERATE_ASAP2';
171 rtwoptions(oIdx).tooltip = sprintf([...
172 'Create a ASAM compliant ASAP2 data definition file for the\n',...
173 'generated C code. ASAP2 is a standard interface to production\n',...
174 'systems. The file is used by calibration tools which support\n',...
179 rtwoptions(oIdx).prompt = 'Initialize floats and doubles to 0.0';
180 rtwoptions(oIdx).type = 'Checkbox';
181 rtwoptions(oIdx).default = 'on';
182 rtwoptions(oIdx).tlcvariable = 'InitFltsAndDblsToZero';
183 rtwoptions(oIdx).tooltip = sprintf([...
184 'Control how internal storage for floats and doubles is initialized.\n', ...
185 'When selected, additional code is generated to set float and double\n', ...
186 'storage explicitly to the value 0.0. Otherwise, all internal\n', ...
187 'storage is cleared to the integer bit pattern 0 (that is, all bits\n', ...
188 'are off). If the representation of floating point zero used by your\n', ...
189 'compiler and target CPU is identical to the the integer bit pattern\n', ...
190 '0, you can gain efficiency (i.e., less ROM) by not selecting this\n', ...
195 rtwoptions(oIdx).prompt = 'Ignore custom storage classes';
196 rtwoptions(oIdx).type = 'Checkbox';
197 rtwoptions(oIdx).default = 'off';
198 rtwoptions(oIdx).tlcvariable = 'IgnoreCustomStorageClasses';
199 rtwoptions(oIdx).tooltip = sprintf([...
200 'Treat custom storage classes as ''Auto'' storage class.']);
204 rtwoptions(oIdx).prompt = 'External mode';
205 rtwoptions(oIdx).type = 'Checkbox';
206 rtwoptions(oIdx).default = 'off';
207 rtwoptions(oIdx).tlcvariable = 'ExtMode';
208 rtwoptions(oIdx).makevariable = 'EXT_MODE';
209 rtwoptions(oIdx).tooltip = sprintf([...
210 'Adds TCP/IP communication support for use with\n',...
211 'Simulink external mode.']);
215 % Reserved for MathWorks internal testing
216 rtwoptions(oIdx).prompt = 'External mode testing';
217 rtwoptions(oIdx).type = 'NonUI';
218 rtwoptions(oIdx).default = '0';
219 rtwoptions(oIdx).tlcvariable = 'ExtModeTesting';
220 rtwoptions(oIdx).makevariable = 'TMW_EXTMODE_TESTING';
224 rtwoptions(oIdx).prompt = 'Suppress error status in real-time model data structure';
225 rtwoptions(oIdx).type = 'Checkbox';
226 rtwoptions(oIdx).default = 'off';
227 rtwoptions(oIdx).tlcvariable = 'SuppressErrorStatus';
228 rtwoptions(oIdx).tooltip = sprintf( ...
229 ['By default, the real-time model data structure (rtM)\n', ...
230 'includes an error status field (data type string). This\n', ...
231 'field lets you log and monitor error messages via macros\n', ...
232 'provided for this purpose (see model.h). The error\n', ...
233 'status field is initialized to NULL. If this option is\n', ...
234 'selected, the error status field is not included in rtM.\n', ...
235 'Selecting this option may also cause the real-time\n', ...
236 'object to disappear completely from the generated code.\n', ...
237 'If you do not need to log or monitor error status, select\n', ...
242 rtwoptions(oIdx).prompt = 'Parameter structure';
243 rtwoptions(oIdx).type = 'Popup';
244 rtwoptions(oIdx).popupstrings = 'Hierarchical|NonHierarchical';
245 rtwoptions(oIdx).default = 'Hierarchical';
246 rtwoptions(oIdx).tlcvariable = 'InlinedParameterPlacement';
247 rtwoptions(oIdx).enable = 'on';
248 rtwoptions(oIdx).tooltip = sprintf([...
249 'Hierarchical: Where possible, generate independent\n', ...
250 'parameter data structures for reusable subsystems. \n', ...
251 'NonHierarchical: Generate a single parameter data structure\n', ...
252 'including reusable subsystem level parameters']);
253 rtwoptions(oIdx).opencallback = [ ...
254 'obj0Tag = ''Parameter structure_PopupFieldTag'';', ...
255 'obj0 = findobj(DialogFig,''Tag'',obj0Tag);', ...
256 'val = get_param(model, ''RTWInlineParameters'');', ...
257 'set(obj0, ''Enable'', val);', ...
262 rtwoptions(oIdx).prompt = 'ERT code generation options (3)';
263 rtwoptions(oIdx).type = 'Category';
264 rtwoptions(oIdx).enable = 'on';
265 rtwoptions(oIdx).default = 6; % number of items under this category
269 rtwoptions(oIdx).prompt = 'Generate an example main program';
270 rtwoptions(oIdx).type = 'Checkbox';
271 rtwoptions(oIdx).default = 'on';
272 rtwoptions(oIdx).tlcvariable = 'GenerateSampleERTMain';
273 rtwoptions(oIdx).tooltip = sprintf([...
274 'Generate an example main program demonstrating\n', ...
275 'how to deploy the generated code. The program is\n', ...
276 'generated into ert_main.c.']);
278 % Enable/disable file name (edit lable and edit field)
279 rtwoptions(oIdx).callback = [ ...
280 'DialogFig = get(gcbo,''Parent'');',...
281 'obj0Tag = ''Generate an example main program_CheckboxTag'';', ...
282 'obj1Tag = ''Target operating system_PopupFieldTag'';', ...
283 'obj0 = findobj(DialogFig,''Tag'',obj0Tag);', ...
284 'obj1 = findobj(DialogFig,''Tag'',obj1Tag);', ...
285 'val = get(obj0,''Value'');', ...
286 'if val == 1;val=''on'';else;val=''off'';end;', ...
287 'set(obj1, ''Enable'', val);', ...
292 rtwoptions(oIdx).prompt = 'Target operating system';
293 rtwoptions(oIdx).type = 'Popup';
294 rtwoptions(oIdx).popupstrings = 'BareBoardExample|VxWorksExample';
295 rtwoptions(oIdx).default = 'BareBoardExample';
296 rtwoptions(oIdx).tlcvariable = 'TargetOS';
297 rtwoptions(oIdx).enable = 'on';
298 rtwoptions(oIdx).tooltip = sprintf([...
299 'Specify the target operating system. When "BareBoardExample"\n', ...
300 'is selected, the generated ert_main.c contains an example\n', ...
301 'main program, demonstrating how to deploy the generated algorithm\n', ...
302 'code on a bare board (no operating system) real-time target.\n', ...
303 'When "VxWorksExample" is selected, the ert_main.c contains an\n', ...
304 'example main program, demonstrating how to deploy the generated\n', ...
305 'algorithm code on the VxWorks real-time operating system.']);
306 % Synchronize with "generating an example main program" option
307 rtwoptions(oIdx).opencallback = [ ...
308 'obj0Tag = ''Generate an example main program_CheckboxTag'';', ...
309 'obj1Tag = ''Target operating system_PopupFieldTag'';', ...
310 'obj0 = findobj(DialogFig,''Tag'',obj0Tag);', ...
311 'obj1 = findobj(DialogFig,''Tag'',obj1Tag);', ...
312 'val = get(obj0,''Value'');', ...
313 'if val == 1;val=''on'';else;val=''off'';end;', ...
314 'set(obj1, ''Enable'', val);', ...
319 rtwoptions(oIdx).prompt = 'Generate reusable code';
320 rtwoptions(oIdx).type = 'Checkbox';
321 rtwoptions(oIdx).default = 'off';
322 rtwoptions(oIdx).tlcvariable = 'MultiInstanceERTCode';
323 rtwoptions(oIdx).makevariable = 'MULTI_INSTANCE_CODE';
324 rtwoptions(oIdx).tooltip = sprintf([...
325 'Generate reusable/reentrant code. Not selected, the\n',...
326 'generated code statically allocates all necessary\n',...
327 'data and accesses it directly, creating non-reusable\n',...
328 'and non-reentrant code. Selected, non-constant data\n',...
329 'is not allocated for the generated code; rather this\n',...
330 'data must be allocated externally and passed into\n',...
331 'the generated code via function arguments, creating\n',...
332 'reusable and reentrant code.']);
333 rtwoptions(oIdx).callback = [ ...
334 'DialogFig = get(gcbo,''Parent'');',...
335 'obj0Tag = ''Generate reusable code_CheckboxTag'';', ...
336 'obj1Tag = ''Reusable code error diagnostic_PopupFieldTag'';', ...
337 'obj2Tag = ''Pass model I/O arguments as structure reference_CheckboxTag'';', ...
338 'obj0 = findobj(DialogFig,''Tag'',obj0Tag);', ...
339 'obj1 = findobj(DialogFig,''Tag'',obj1Tag);', ...
340 'obj2 = findobj(DialogFig,''Tag'',obj2Tag);', ...
341 'val = get(obj0,''Value'');', ...
342 'if val == 1;val=''on'';else;val=''off'';end;', ...
343 'set(obj1, ''Enable'', val);', ...
344 'set(obj2, ''Enable'', val);', ...
349 rtwoptions(oIdx).prompt = 'Pass model I/O arguments as structure reference';
350 rtwoptions(oIdx).type = 'Checkbox';
351 rtwoptions(oIdx).default = 'off';
352 rtwoptions(oIdx).tlcvariable = 'RootIOStructures';
353 rtwoptions(oIdx).enable = 'on';
354 rtwoptions(oIdx).tooltip = sprintf([...
355 'Specify how the model inputs and outputs are passed\n',...
356 'to the model step functions. Passing by structure\n',...
357 'reference reduces the number of function arguments.\n',...
358 'Selected, the model I/O is passed by structure reference.\n',...
359 'Otherwise, it''s passed as individual arguments.']);
360 rtwoptions(oIdx).opencallback = [ ...
361 'obj0Tag = ''Generate reusable code_CheckboxTag'';', ...
362 'obj1Tag = ''Pass model I/O arguments as structure reference_CheckboxTag'';', ...
363 'obj0 = findobj(DialogFig,''Tag'',obj0Tag);', ...
364 'obj1 = findobj(DialogFig,''Tag'',obj1Tag);', ...
365 'val = get(obj0,''Value'');', ...
366 'if val == 1;val=''on'';else;val=''off'';end;', ...
367 'set(obj1, ''Enable'', val);', ...
372 rtwoptions(oIdx).prompt = 'Reusable code error diagnostic';
373 rtwoptions(oIdx).type = 'Popup';
374 rtwoptions(oIdx).popupstrings = 'None|Warning|Error';
375 rtwoptions(oIdx).default = 'Error';
376 rtwoptions(oIdx).tlcvariable = 'MultiInstanceErrorCode';
377 rtwoptions(oIdx).enable = 'on';
378 rtwoptions(oIdx).tooltip = sprintf([...
379 'Specify the error diagnostic behavior for when\n',...
380 'data defined in the model violates the ability\n',...
381 'to reuse the code.']);
382 rtwoptions(oIdx).opencallback = [ ...
383 'obj0Tag = ''Generate reusable code_CheckboxTag'';', ...
384 'obj1Tag = ''Reusable code error diagnostic_PopupFieldTag'';', ...
385 'obj0 = findobj(DialogFig,''Tag'',obj0Tag);', ...
386 'obj1 = findobj(DialogFig,''Tag'',obj1Tag);', ...
387 'val = get(obj0,''Value'');', ...
388 'if val == 1;val=''on'';else;val=''off'';end;', ...
389 'set(obj1, ''Enable'', val);', ...
394 rtwoptions(oIdx).prompt = 'Target floating point math environment';
395 rtwoptions(oIdx).type = 'Popup';
396 rtwoptions(oIdx).popupstrings = 'ANSI_C|ISO_C';
397 rtwoptions(oIdx).default = 'ANSI_C';
398 rtwoptions(oIdx).tlcvariable = 'CodeReplacementLibrary';
399 rtwoptions(oIdx).tooltip = sprintf([...
400 'If your target compiler supports the ISO C (ISO/IEC 9899:1999)\n', ...
401 'math library, we recommend selecting the ISO C option and \n', ...
402 'setting your compiler''s ISO C flags. This will generate calls \n', ...
403 'to the ISO C functions wherever possible (for example, sqrtf()\n', ...
404 'instead of sqrt() for single precision data) and ensure that\n', ...
405 'you obtain the best performance your target compiler offers. \n', ...
406 'If your target compiler does not support ISO C math library \n', ...
407 'functions, use the ANSI C (ANSI X3.159-1989) option \n', ...
412 rtwoptions(oIdx).prompt = 'ERT code templates';
413 rtwoptions(oIdx).type = 'Category';
414 rtwoptions(oIdx).enable = 'on';
415 rtwoptions(oIdx).default = 5; % number of items under this category
419 rtwoptions(oIdx).prompt = 'Enable custom file banners';
420 rtwoptions(oIdx).type = 'NonUI';
421 rtwoptions(oIdx).default = '1';
422 rtwoptions(oIdx).tlcvariable = 'ERTCustomFileBanners';
426 rtwoptions(oIdx).prompt = 'Source file (.c) banner template';
427 rtwoptions(oIdx).type = 'Edit';
428 rtwoptions(oIdx).default = 'example_banner.tlc';
429 rtwoptions(oIdx).tlcvariable = 'ERTSrcFileBannerTemplate';
430 rtwoptions(oIdx).tooltip = sprintf([...
431 'Name of source file (*.c) banner template. The location\n',...
432 'of the specified file must be on the TLC include path. See\n',...
433 'example file MATLAB/rtw/c/tlc/mw/example_banner.tlc.']);
437 rtwoptions(oIdx).prompt = 'Header file (.h) banner template';
438 rtwoptions(oIdx).type = 'Edit';
439 rtwoptions(oIdx).default = 'example_banner.tlc';
440 rtwoptions(oIdx).tlcvariable = 'ERTHdrFileBannerTemplate';
441 rtwoptions(oIdx).tooltip = sprintf([...
442 'Name of header file (*.h) banner template. The location\n',...
443 'of the specified file must be on the TLC include path. See\n',...
444 'example file MATLAB/rtw/c/tlc/mw/example_banner.tlc.']);
448 rtwoptions(oIdx).prompt = 'Customize and create source files';
449 rtwoptions(oIdx).type = 'NonUI';
450 rtwoptions(oIdx).default = '1';
451 rtwoptions(oIdx).tlcvariable = 'ERTCreateCustomFiles';
455 rtwoptions(oIdx).prompt = 'File customization template';
456 rtwoptions(oIdx).type = 'Edit';
457 rtwoptions(oIdx).default = 'example_file_process.tlc';
458 rtwoptions(oIdx).tlcvariable = 'ERTCustomFileTemplate';
459 rtwoptions(oIdx).tooltip = sprintf([...
460 'Name of template file to create additional and customize\n',...
461 'existing source files. The location of the specified\n',...
462 'file must be on the TLC include path. See example file\n',...
463 'MATLAB/rtw/c/tlc/mw/example_file_process.tlc.']);
465 %----------------------------------------%
466 % Configure code generation settings %
467 %----------------------------------------%
469 rtwgensettings.BuildDirSuffix = '_ert_rtw';
474 %% The content between 'BEGIN_CONFIGSET_TARGET_COMPONENT' and
475 %% 'END_CONFIGSET_TARGET_COMPONENT' is for the MathWorks internal use
476 %% only. You must remove this section if you intend to use this file
477 %% as a template for your own system target development.
479 BEGIN_CONFIGSET_TARGET_COMPONENT
481 targetComponentClass = 'Simulink.ERTTargetCC';
483 END_CONFIGSET_TARGET_COMPONENT