📄 mc9s12_make_rtw_hook.m
字号:
function s = mc9S12_make_rtw_hook(method, modelName, rtwRoot, tmf, buildOpts, buildArgs)
% mc9S12_MAKE_RTW_HOOK:
% For the 9S12 target, this is allow Real-Time Workshop Embedded Coder
% to hook cleanly into Real-Time Workshop build process.
%
% Copyright 2002 The MathWorks, Inc.
% $Revision: 1.19 $
% $Date: 2003/03/20 18:42:33 $
%
% modified to suite Wytec Dragon12 boards, fw-02-05
persistent userdata;
persistent atticdata;
persistent srcMCPProjectPathAndFile;
persistent dstMCPProjectPathAndFile;
if nargin == 0
errmsg = ['No arguments provided to mc9S12_make_rtw_hook']
end
switch method
case 'entry'
% memory map now selectable through the options page... fw-03-05
rtwOpt = get_param(gcs, 'RTWoptions');
cpydir = which('mc9S12.tlc');
cpydir(end-10:end) = []; % remove text 'mc9S12.tlc'
if(findstr(rtwOpt, 'Flash_flat'))
srcMCPProjectPathAndFile = [cpydir '\rtw_dp256_flash_flat\rtw_dp256_flash_flat.mcp'];
elseif(findstr(rtwOpt, 'Flash_banked'))
srcMCPProjectPathAndFile = [cpydir '\rtw_dp256_flash_banked\rtw_dp256_flash_banked.mcp'];
else
error('mc9S12_make_rtw_hook: Unknown memory model - ensure the RTW options are set correctly and rebuild');
end
% mpcProjectPathAndFile_RAM = 'C:\Documents and Settings\fwornle\My Documents\_cProgs\Motorola\rtmc9S12_CW_R13\bin\rtw_dp256_ram\rtw_dp256_ram.mcp';
% mpcProjectPathAndFile_Flash = 'C:\Documents and Settings\fwornle\My Documents\_cProgs\Motorola\rtmc9S12_CW_R13\bin\rtw_dp256_flash\rtw_dp256_flash.mcp';
% mpcProjectPathAndFile_Banked = 'C:\Documents and Settings\fwornle\My Documents\_cProgs\Motorola\rtmc9S12_CW_R13\bin\rtw_dp256_banked_flash\rtw_dp256_banked_flash.mcp';
% mpcTargetProjectType = 'ram';
% switch lower(mpcTargetProjectType)
% case 'ram'
% srcMCPProjectPathAndFile = mpcProjectPathAndFile_RAM;
%
% case 'flash'
% srcMCPProjectPathAndFile = mpcProjectPathAndFile_Flash;
%
% case 'banked'
% srcMCPProjectPathAndFile = mpcProjectPathAndFile_Banked;
%
% otherwise
% end
FcnEntryMethod(modelName);
case 'before_tlc'
% remove - fw-02-05
% if (isappdata(0,'hc12driversMaster'))
% rmappdata(0,'hc12driversMaster');
% end
% create COM connection to CW
try
ICodeWarriorApp = actxserver('CodeWarrior.CodeWarriorApp');
while (1 == 1)
e = invoke(ICodeWarriorApp.DefaultProject, 'Close');
end
catch
lasterr('');
end
[srcProjDir, srcProjFile, projSuffix, dummy1] = fileparts(srcMCPProjectPathAndFile);
dstProjDir = pwd;
[dstProjDir, dummy1, dummy3, dummy3] = fileparts(dstProjDir);
dstMCPProjectPathAndFile = [dstProjDir,'\',srcProjFile,projSuffix];
case 'after_tlc'
case 'before_make'
% Generate files containing lists for building any necessary libraries.
% For example, rtwlib.lib.
%
% This is the first case (e.g. 'before_make' ) where "buildOpts" is available.
%
% redirected to local copy of 'hc12_libgen' -> adapt this to suite the Dragon12 (FW-04-04)
my_hc12_libgen(modelName,rtwRoot,tmf,buildOpts,buildArgs);
case 'exit'
if (buildOpts.generateCodeOnly == 0)
%
try
% re-directed to local copy of 'hc12_tgtaction' -- adapt this to
% suit... (FW-04-04)
my_hc12_tgtaction(srcMCPProjectPathAndFile,'build');
setappdata(0,'CodeWarriorNotFound','false');
catch
% Can't locate CodeWarrior
setappdata(0,'CodeWarriorNotFound','true');
disp('Embedded Target for Freescale mc9S12 requires Metrowerks CodeWarrior HC12 version 3.0 (or higher) which was not found')
end
% Run code profiling report
if (exist('htmlreport')==2)
htmlreport;
delete htmlreport.m; % housekeeping
end
%
fprintf(1,'### Successful completion of BUILD for mc9S12 target model: %s\n', modelName);
else
% re-directed to local copy of 'hc12_tgtaction' -- adapt this to
% suit... (FW-04-04)
my_hc12_tgtaction(srcMCPProjectPathAndFile,'codegenonly');
% Code gen only will not produce the htmlreport for code profiling
%
fprintf(1,'### Successful completion of Code Generation for mc9S12 target model: %s\n', modelName);
end
otherwise
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% SUBFUNCTIONS:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function FcnEntryMethod(codeGenModelName)
% Find subsystem in code generation model
hCodeGenBlk = FcnFindCodeGenBlk(codeGenModelName);
if (hCodeGenBlk ~= -1) % i.e. subsystem build, not top-level model
% Check for configurable subsystem
if FcnIsConfigSS(hCodeGenBlk)
% Check that it is using the correct BlockChoice
blockChoice = get_param(hCodeGenBlk, 'BlockChoice');
memberBlocks = get_param(hCodeGenBlk, 'MemberBlocks');
origBlkName = strtok(memberBlocks, ',');
if ~strcmp(blockChoice, origBlkName)
errTxt = sprintf([...
'Invalid block choice selected for building the subsystem ', ...
'for real-time standalone target.\nSelect the first ', ...
'block choice and then start the build process again.']);
error(errTxt);
end
% Fix sample time settings:
hPorts = find_system(get_param(codeGenModelName, 'Handle'), ...
'SearchDepth', 1, ...
'LookUnderMasks', 'on', ...
'FollowLinks', 'on', ...
'BlockType', 'Inport');
hSSInside = find_system(hCodeGenBlk, ...
'SearchDepth', 1, ...
'LookUnderMasks', 'on', ...
'FollowLinks', 'on', ...
'BlockType', 'SubSystem');
hSSInside = hSSInside(hSSInside~=hCodeGenBlk);
hSSPorts = find_system(hSSInside, ...
'SearchDepth', 1, ...
'LookUnderMasks', 'on', ...
'FollowLinks', 'on', ...
'BlockType', 'Inport');
for i=1:length(hPorts)
ssPortTs = get_param(hSSPorts(i), 'SampleTime');
if ((strcmp(ssPortTs, '-1')) | ...
(strcmp(ssPortTs, get_param(hPorts(i), 'SampleTime'))))
% Do not copy sample time setting from SSPort
else
set_param(hPorts(i), 'SampleTime', ssPortTs);
end
end
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function hCodeGenBlk = FcnFindCodeGenBlk(codeGenModelName)
hCodeGenModel = get_param(codeGenModelName, 'Handle');
hCodeGenBlk = find_system(hCodeGenModel, ...
'SearchDepth', 1, ...
'BlockType', 'SubSystem');
if length(hCodeGenBlk)>1
hCodeGenBlk = -1; % Indicates that a top level model is being built
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function result = FcnIsConfigSS(hBlk)
if strcmp(get_param(hBlk, 'BlockType'), 'SubSystem')
if strcmp(get_param(hBlk, 'TemplateBlock'), '')
result = 0;
else
result = 1;
end
else
result = 0;
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -