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

getBlockInfo_HwInterrupt_multilink_mpc5500(linkPjtGenInfo, schedPjtGenInfo)
function [linkPjtGenInfo, schedPjtGenInfo] = getBlockInfo_HwInterrupt_multilink_mpc5500(linkPjtGenInfo, schedPjtGenInfo)
%GETBLOCKINFO_HWINTERRUPT_MULTILINK_MPC5500 Get information about a 'Hardware Interrupt' block.

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

%----------------------------------------------------------
% Look for HW Interrupt blocks in the model
%----------------------------------------------------------
hwInterruptBlocks = linkfoundation.util.FindSystem(linkPjtGenInfo.modelName,'MPC5500 Interrupt Block');

%----------------------------------------------------------
% Check for error conditions
%----------------------------------------------------------
numHwIntBlks = length(hwInterruptBlocks);
if numHwIntBlks==0
    % No HW Interrupt block present in the model
    return;
elseif numHwIntBlks> 1
    % Only 1 HW Interrupt is allowed in the model
    linkPjtGenInfo.error = 1;
    linkPjtGenInfo.errormsg = 'Only one Hardware Interrupt block is allowed in the model';
    return
end

%----------------------------------------------------------
% Update 'schedPjtGenInfo' if a HW Interrupt block is present
%----------------------------------------------------------
% linkPjtGenInfo.numInterrupts  - Number of interrupts in the model
% linkPjtGenInfo.interrupts     - List of interrupt numbers
% linkPjtGenInfo.priority       - List of interrupt priorities
% linkPjtGenInfo.isrpreempt     - List of interrupt preempts
%
% linkPjtGenInfo.softwareVectMode
% linkPjtGenInfo.baseRatePriority
% linkPjtGenInfo.asmFileName
% linkPjtGenInfo.offset
%----------------------------------------------------------

if ~isempty(hwInterruptBlocks)

    % Get information specified by user
    irqnum = get_param (hwInterruptBlocks, 'irqnumbers');
    interruptNumbers = eval(cell2mat(irqnum));
    
    priort = get_param(hwInterruptBlocks,'syspriorities');
    sysPriority = eval(cell2mat(priort)); 
    
    preemp = get_param(hwInterruptBlocks,'irqpreempts');
    irqPreempt = eval(cell2mat(preemp));
    
    softmode = get_param(hwInterruptBlocks,'softwaremode');
    linkPjtGenInfo.softwareVectMode = strcmpi(softmode,'on');
    
    linkPjtGenInfo.baseRatePriority = getBaseTaskPriority(linkPjtGenInfo.modelName);

    linkPjtGenInfo.asmFileName = '';
    if ~(linkPjtGenInfo.softwareVectMode)
        linkPjtGenInfo.asmFileName = 'multilink_mpc5500_hw_vect.asm';
    end
    
    for i=1:length(interruptNumbers)      
        % Increment number of interrupts by 1
        linkPjtGenInfo.numInterrupts = linkPjtGenInfo.numInterrupts + 1;

        % Assign the interrupt number - given by user
        linkPjtGenInfo.interrupts{linkPjtGenInfo.numInterrupts} = interruptNumbers(i);

        % Assign the interrupt priority - given by user
        linkPjtGenInfo.priority{linkPjtGenInfo.numInterrupts}   = int32(sysPriority(i));
        
        % Assign the interrupt preempt - given by user
        if length(irqPreempt)>1
            linkPjtGenInfo.isrpreempt{linkPjtGenInfo.numInterrupts} = irqPreempt(i);
        else
            linkPjtGenInfo.isrpreempt{linkPjtGenInfo.numInterrupts} = irqPreempt(1);
        end     
        
        if (linkPjtGenInfo.softwareVectMode)
            linkPjtGenInfo.offset{linkPjtGenInfo.numInterrupts} = '';
        else
            linkPjtGenInfo.offset{linkPjtGenInfo.numInterrupts} = dec2hex(hex2dec('40000000')+interruptNumbers(i)*16);
        end
        
    end
    
end

%% --------------------------------------------------------------------------------
function baseTaskPriority = getBaseTaskPriority(modelName)
baseTaskPriority = 7;  %default
cs = getActiveConfigSet(modelName);
solverType = get_param(cs, 'SolverType');
if ( ~strcmp(solverType, 'Fixed-step')  )
    return %we shouldn't be here in the first place...
end
sampleTimeConst = get_param(cs, 'SampleTimeConstraint');
if ( strcmp(sampleTimeConst, 'Specified') )
    % Priorities are specified by the user and we always ensure that
    % these lie in between 1-15 (TSK)
    sampleTimeProp = get_param(cs,'SampleTimeProperty');
    baseTaskPriority = sampleTimeProp.Priority;
end

%[EOF] getBlockInfo_HwInterrupt_multilink_MPC5500.m

Contact us