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

registerGHSMULTI()
function ret = registerGHSMULTI()
%REGISTERGHSMULTI Defines IDE Link Adaptor for use with GHS MULTI

%   Copyright 2009-2012 The MathWorks, Inc.

ret = ghsmultiext.Utilities.getSupportPackageCustomInfo;
       
% automation factory handle
ret.AutomationFactory = @getGHSMULTIAutomationHandle;

% suffix for build folder
ret.BuildFolderSuffix = '_ghsmulti';

% tools-specific info
ret.Tools.PreprocSymbolDelimiter = '-D';
ret.Tools.IncludePathDelimiter = '-I';
ret.Tools.PreprocSymbols = {};

% adaptor codegen package
ret.ProcessorObjectFactory = @getCodeGenObject;
ret.ProjectOptions         = @getAdditionalProjectOptions;
ret.OSObjectFactory        = @getOSObject;
ret.FullLibPathFcn         = @getFullLibPath;
ret.ArtifactNameFcn        = @getCodeGenArtifactName;
ret.LibPjtFilterFcn        = @ghsmultiext.Utilities.getFilesToRemoveIfLibPjt;
ret.FileExtFcn             = @ghsmultiext.Utilities.getFileExt;
ret.IDEBuildOptsFcn        = @getIDEBuildOptions;
ret.PragmaAlignDirective   = @getPragmaAlignDirective;
ret.PragmaSectionDirective = @getPragmaSectionDirective;
ret.InlinedAlignDirective  = @getInlinedAlignDirective;
ret.getIDETag              = @getIDETag;
ret.getChipObj             = @getChipObject;


% list of features supported by this adaptor
ret.Features.BuildActions.Project  = { ...
    'Create_project', ...
    'Archive_library', ...
    'Build', ...
    'Build_and_execute', ...
    'Create_Processor_In_the_Loop_project', ...
    }; 
ret.Features.BuildActions.Makefile = { ...
    'Create_makefile', ...
    'Archive_library', ...
    'Build', ...
    'Build_and_execute', ...
    };
% specify default build action as index into the array of supported build
% actions
ret.Features.DefaultBuildAction.Project  = 4; % 'Build_and_execute'
ret.Features.DefaultBuildAction.Makefile = 4; % 'Build_and_execute'


% Push Button: Compiler Options "Get from IDE"
ret.ConfigParamsDialog.getCompilerOptions = false;
% Push Button: Compiler Options "Reset"
ret.ConfigParamsDialog.resetCompilerOptions = false;
% Push Button: Linker Options "Get from IDE"
ret.ConfigParamsDialog.getLinkerOptions = false;
% Push Button: Linker Options "Reset"
ret.ConfigParamsDialog.resetLinkerOptions = false;
% Combo Box: "Project Options"
ret.ConfigParamsDialog.projectOptions = false;

end


function ret = getIDETag(newTag, ~)
ret = newTag;
end


function ret = getChipObject(device, subFamily, codeGenHook) %#ok<INUSL>
    ret = feval(['MULTILinkTgtPkg.' codeGenHook]);
end


function ret = getCodeGenObject(objName, ProjectBuildInfo)
switch(objName)
    case 'chip',
        ret = getChipObject('', '', ProjectBuildInfo.mCGHook);
end
end

function ret = getAdditionalProjectOptions(ProjectBuildInfo)
ret = [];
% Additional compiler options for MPC55xx and MPC74xx processors
% Both MPC74xx and MPC55xx support code generation on little endian and big
% endian mode and hence require appropriate compiler options to be set
switch ProjectBuildInfo.mCGHook
    case {'mpc7400', 'mpc5500', 'arm'}
        if ProjectBuildInfo.mBigEndian
            endianess = 'BigEndian';
        else
            endianess = 'LittleEndian';
        end
        if strcmpi(endianess,'littleendian')
            ret.Compiler{1} = ' -littleendian';
            ret.Linker = [];
        else
            ret.Compiler{1} = ' -bigendian';
            ret.Linker = [];
        end
    otherwise
end
end

function ret = getOSObject(ProjectBuildInfo) %#ok<INUSD>
ret = [];
end

function x = getFullLibPath(pjtBuildInfo, libPath, libName)
x = fullfile(pjtBuildInfo.mCodeGenDir, libPath, [libName ghsmultiext.Utilities.getFileExt('library')]);
end

function x = getCodeGenArtifactName(pjtBuildInfo, artifactType)
ext = ghsmultiext.Utilities.getFileExt(strrep(artifactType, '-name', ''));
    switch artifactType
        case {'project-name', 'program-name', 'library-name'}
            x = [pjtBuildInfo.mModelName ext];
        case {'project', 'program', 'library'}
            x = fullfile(pjtBuildInfo.mCodeGenDir, [pjtBuildInfo.mModelName ext]);
    end
end

function opts = getIDEBuildOptions
opts = [];
end

function str = getPragmaAlignDirective(varName, alignmentBoundary) %#ok<INUSL>
% Returns syntactically correct data alignment pragma string for GHS MULTI to
% be included in generated code via TLC. 
str = sprintf('#pragma alignvar(%s)', num2str(alignmentBoundary));
end

function str = getInlinedAlignDirective(~)
% Not applicable on this adaptor: return empty
str = [];
end

function str = getPragmaSectionDirective(action, varName, memorySection, initMemory) %#ok<INUSL>
% Returns syntactically correct memory section pragma string for GHS MULTI to
% be included in generated code via TLC.
switch action
    case 'open'
        if initMemory == 1
            str = sprintf('#pragma ghs section data="%s"', memorySection);
        else
            str = sprintf('#pragma ghs section bss="%s"', memorySection);
        end
    case 'close'
        if initMemory == 1
            str = sprintf('#pragma ghs section data=default');
        else
            str = sprintf('#pragma ghs section bss=default');
        end     
end
end

Contact us