Highlights from
Embedded Coder Support Package for Green Hills MULTI IDE (R2012b)

image thumbnail

Embedded Coder Support Package for Green Hills MULTI IDE (R2012b)

by

 

Embedded Coder integration for creating models that run directly in Green Hills MULTI IDE

getIRInfo_multilink_mpc7400(action, varargin)
function [linkPjtGenInfo, schedPjtGenInfo] = getIRInfo_multilink_mpc7400(action, varargin)
%GETIRINFO_MULTILINK_MPC7400 Initialize the PjtGenInfo fields.

%   $Revision: 1.1.6.1 $
%   $Date: 2012/04/02 21:40:25 $
%   Copyright 2007-2010 The MathWorks, Inc.

switch lower(action)
    case 'init'
        [linkPjtGenInfo, schedPjtGenInfo] = initPjtGenInfo(varargin{:});
    case 'process_synchronous_rates'
        [linkPjtGenInfo, schedPjtGenInfo] = processSynchronousSampleRates(varargin{:});
    case 'process_manage_timer'
        [linkPjtGenInfo, schedPjtGenInfo] = processManageTimeInfo(varargin{:});
    otherwise
        linkPjtGenInfo.error = 1;
        linkPjtGenInfo.errormsg = sprintf('%s: Unrecognized option: %s', upper(mfilename), action);
end

%% ------------------------------------------------------------------------
function [linkPjtGenInfo, schedPjtGenInfo] = initPjtGenInfo(linkPjtGenInfo, schedPjtGenInfo)
%INITIRINFO Initialize the PjtGenInfo fields.

%% ------------------------------------------------------------------------
function [linkPjtGenInfo, schedPjtGenInfo] = processSynchronousSampleRates(linkPjtGenInfo, schedPjtGenInfo, RTWSampleTimes, varargin)
%PROCESSSYNCHRONOUSSAMPLERATES Process synchronous rates and set up timer interrupt.

% Find out if there is any synchronous rate. If there is, setup a timer
% interrupt. Note that RTWSampleTimes structure is sorted (sync rates
% first)

isPILorLib = linkfoundation.pil.isLibCodeGeneration(linkPjtGenInfo.modelName) || ...
    linkfoundation.pil.isPILCodeGeneration(linkPjtGenInfo.modelName);

if ~isPILorLib && ...
        (schedPjtGenInfo.BaseSampleTime ~= -1) % there is at least one synchronous rate
    schedPjtGenInfo.timerIntNeeded = 1;
    schedPjtGenInfo.timerIntPriority = RTWSampleTimes{1}.Priority;
    schedPjtGenInfo.timerIntPeriod = floor(linkPjtGenInfo.cpuClkRate * schedPjtGenInfo.BaseSampleTime / linkPjtGenInfo.lowResClkDivider);
    if (schedPjtGenInfo.timerIntPeriod > 2^32-1)
        linkPjtGenInfo.error = 1;
        linkPjtGenInfo.errormsg = ['The base sample time of the model is too long ' ...
            'to fit in the 32-bit timer period register.'];
        return
    elseif (schedPjtGenInfo.timerIntPeriod < 150)
        linkPjtGenInfo.error = 1;
        linkPjtGenInfo.errormsg = 'The base sample time of the model is too short (less than 50 CPU clock cycles).';
        return
    end
    
    linkPjtGenInfo.numTimers = linkPjtGenInfo.numTimers + 1;
    linkPjtGenInfo.timers{linkPjtGenInfo.numTimers} = -1; %% allocate Core timer for base rate
    linkPjtGenInfo.timerperiod{linkPjtGenInfo.numTimers} = schedPjtGenInfo.timerIntPeriod;
end

% Timer configuration is needed only if bare board profiler is enabled.
if (linkPjtGenInfo.profileGenCode)
    if (linkPjtGenInfo.numTimers < 1)
        linkPjtGenInfo.numTimers = linkPjtGenInfo.numTimers + 1;
        linkPjtGenInfo.timers{linkPjtGenInfo.numTimers} = 0; %% allocate GP timer 0 for profiling
        linkPjtGenInfo.timerperiod{linkPjtGenInfo.numTimers} = (2^32)-1;
    end
end

%% ------------------------------------------------------------------------
function [linkPjtGenInfo, schedPjtGenInfo] = processManageTimeInfo(linkPjtGenInfo, schedPjtGenInfo)
%PROCESSMANAGETIMEINFO Process blocks that manage their own time.

%[EOF] getPjtGenInfo_multilink_mpc7400.m

Contact us