]> rtime.felk.cvut.cz Git - jenkicar/rpp-simulink.git/commitdiff
Add Matlab script for generation of target specific rpp_lib.slx library
authorMichal Horn <hornmich@fel.cvut.cz>
Wed, 22 Apr 2015 16:12:16 +0000 (18:12 +0200)
committerMichal Horn <hornmich@fel.cvut.cz>
Wed, 22 Apr 2015 16:12:16 +0000 (18:12 +0200)
rpp/blocks/Makefile
rpp/blocks/_tms570_rpp/rpp_lib.slx [new file with mode: 0644]
rpp/blocks/rpp_generate_lib.m [new file with mode: 0644]

index a55e1134346310691ee17f13197e7407c8247e65..9d19eb7846c1b438583b6fc534e9bfe17a7f63ad 100644 (file)
@@ -22,6 +22,11 @@ diff-doc: $(HTML)
 update-doc: $(HTML)
        matlab -nodesktop -nojvm -r "try, rpp_update_doc('update'); catch ME, disp(getReport(ME)); exit(1); end; exit(0)" | sed -e "s/\x1b\(\[?1[hl]\|[=>]\)//g" | tee update-doc.log
 
+include ../lib/Makefile.config
+generate-lib:
+       matlab -nodesktop -nojvm -r "try, rpp_generate_lib(); catch ME, disp(getReport(ME)); exit(1); end; exit(0)" | sed -e "s/\x1b\(\[?1[hl]\|[=>]\)//g" | tee generate-lib.log
+       cp --force ./_$(TARGET)/rpp_lib.slx ./rpp_lib.slx
+       
 define PRINT_COMMIT_MSG
 (echo "Update block masks by running rpp_update_doc.m"; echo; echo "Changelog:"; sed -n -e '/^Processing rpp_lib/,$$ p' update-doc.log)
 endef
diff --git a/rpp/blocks/_tms570_rpp/rpp_lib.slx b/rpp/blocks/_tms570_rpp/rpp_lib.slx
new file mode 100644 (file)
index 0000000..101e024
Binary files /dev/null and b/rpp/blocks/_tms570_rpp/rpp_lib.slx differ
diff --git a/rpp/blocks/rpp_generate_lib.m b/rpp/blocks/rpp_generate_lib.m
new file mode 100644 (file)
index 0000000..fc97cc3
--- /dev/null
@@ -0,0 +1,88 @@
+% Copyright (C) 2013-2014 Czech Technical University in Prague
+%
+% Authors:
+%     - Michal Horn <hornmich@fel.cvut.cz>
+%
+% This document contains proprietary information belonging to Czech
+% Technical University in Prague. Passing on and copying of this
+% document, and communication of its contents is not permitted
+% without prior written authorization.
+%
+% File : rpp_generate_lib.m
+% Abstract:
+%     Generates library rpp_lib.slx for targets
+%
+% References:
+%     http://www.mathworks.com/help/matlab/ref/mex.html
+%     http://www.mathworks.com/help/matlab/matlab_external/custom-building-mex-files.html
+
+%% This array contains a set of blocks, which are distributed
+%% with the [platform TMS570 RPP. The blocks names are derived
+%% from the names of their slx files without the .slx suffix.
+tms570_rpp_blocks = {
+       'rpp_ain',
+       'rpp_aout',
+       'rpp_can_rx',
+       'rpp_can_setup',
+       'rpp_can_tx',
+       'rpp_din',
+       'rpp_din_cfg',
+       'rpp_dout',
+       'rpp_fr_cfg',
+       'rpp_fr_rx',
+       'rpp_fr_tx',
+       'rpp_hbr',
+       'rpp_ircin',
+       'rpp_log',
+       'rpp_overrun',
+       'rpp_power',
+       'rpp_sci_cfg',
+       'rpp_sci_printf',
+       'rpp_sci_rx',
+       'rpp_sci_tx'
+};
+
+%% This array contains a list of all targets, for which the
+%% library will be generated.
+%% Each record contains two items:
+%%     1. the name of the directory containing the generated
+%%        library for the target,
+%%     2. the reference to the list of blocks assigned to the
+%%        target.
+targets = {
+       {'_tms570_rpp', tms570_rpp_blocks}
+};
+
+resultLibName = 'rpp_lib';
+
+for i=1:length(targets),
+       disp(['Generating library for target: ', targets{i}{1}]);
+       libFilePath=[targets{i}{1}, '/', resultLibName, '.slx'];
+       load_system(libFilePath);
+       set_param(resultLibName, 'Lock', 'off');
+       blocks = find_system(resultLibName, 'Type', 'block');
+       disp('Removing old blocks:');
+       for j=1:length(blocks),
+               disp(['    ', blocks{j}]);
+               delete_block(blocks{j});
+       end
+       disp('Adding new blocks:');
+       for j=1:length(targets{i}{2}),
+               blockFilePath=[targets{i}{2}{j}, '.slx'];
+               disp(['    from: ', blockFilePath, ':']);
+               load_system(blockFilePath)
+               blocks = find_system(targets{i}{2}{j}, 'Type', 'block');
+               for k=1:length(blocks),
+                       [tok, blockName] = strtok(blocks{k}, '/');
+                       blockName = [resultLibName, blockName];
+                       disp(['        ', blocks{k}, ' as ', blockName]);
+                       add_block(blocks{k}, blockName);
+               end
+               close_system(blockFilePath, 0);
+       end
+       disp(['Closing and saving file ', libFilePath]);
+       set_param(resultLibName, 'Lock', 'on');
+       close_system(libFilePath, 1);
+end
+
+