classdef createXMLforTIInterrupts
    % CREATEXMLFORTIINTERRUPTS Creates xml files for the interrupt definition of different TI targets

    % Copyright 2021-2024 The MathWorks, Inc.

    properties
        subFamilyName;
        interruptInfofile;
        eventsInfoFile;
        interruptFileName;
        interruptGroupNames;
        intdef;
        interruptNameID;
        registerID;
        interruptGroupID;
        FIELD;
        INTBT; 
    end


    methods(Static)

        %% Get list of sub families from pinmap folder
        function subDirs = getTargetSubFamilies()
            tgtFolder = codertarget.target.getTargetFolder('TI C2000');
            subFamily = dir(fullfile(tgtFolder,'+codertarget','+tic2000','+pinmap'));
            % Extract only those that are directories.
            dirFlags = [subFamily.isdir] & ~strcmp({subFamily.name},'.') & ~strcmp({subFamily.name},'..');
            subDirs = subFamily(dirFlags);
        end
    end

    %% Populate the XML Files
    methods
        function obj = createXMLforTIInterrupts()
            subDirs = obj.getTargetSubFamilies();
            %Enable New Hardware board
            previewNewHardwareBoard('Yes');
            hardwareBoards = codertarget.target.getAllHardwareBoards('TI C2000');
            tgtFolder = codertarget.target.getTargetFolder('TI C2000');
            interruptFilePath = fullfile(tgtFolder, 'registry', 'interrupts');
            for i = 1:length(subDirs)
                % Get subfamily name
                obj.subFamilyName = extractAfter(subDirs(i).name,'+');
                obj.interruptInfofile = ['codertarget.tic2000.pinmap.',obj.subFamilyName,'.getInterruptDefinitions'];
                % Filter out subfamilies for which interrupt definition file is not present
                if nargout(obj.interruptInfofile) > 4
                    [obj.interruptNameID,obj.registerID,obj.interruptGroupID,...
                        obj.interruptGroupNames, obj.FIELD, obj.INTBT ] = feval(str2func(obj.interruptInfofile));
                else
                    [obj.interruptNameID,obj.registerID,obj.interruptGroupID,...
                        obj.interruptGroupNames] = feval(str2func(obj.interruptInfofile));
                end
                if strcmp(obj.subFamilyName,'F280x') || strcmp(obj.subFamilyName,'F281x') || strcmp(obj.subFamilyName,'F2804x')...
                        || strcmp(obj.subFamilyName,'F2806x') || strcmp(obj.subFamilyName,'F2805x') || strcmp(obj.subFamilyName,'F2803x')...
                        || strcmp(obj.subFamilyName,'F2802x') || strcmp(obj.subFamilyName,'F2833x') || strcmp(obj.subFamilyName,'F2834x')...
                        || strcmp(obj.subFamilyName,'F28M35x') || strcmp(obj.subFamilyName,'F28M36x')
                    obj.eventsInfoFile = 'codertarget.tic2000.pinmap.getFamily2InterruptEvents';
                else
                    %F28002x, F28003x, F2837x, F28004x, F2838x, F2807x
                    obj.eventsInfoFile = 'codertarget.tic2000.pinmap.getFamily1InterruptEvents';
                end
                % Interrupt definition file name is
                % <obj.subFamilyName>_interrupts.xml for e.g. F28003xSubFamily_interrupts.xml                
                obj.interruptFileName = fullfile(interruptFilePath, [obj.subFamilyName,'SubFamilyInterrupts.xml']);
                obj.intdef = obj.loc_setInterruptDefinition();
                % Create all interrupt groups
                for grpidx=1:length(obj.interruptGroupNames)
                    obj.intdef.addNewInterruptGroup(obj.interruptGroupNames{grpidx});
                end
                obj.intdef = obj.loc_addInterruptGroups();
                obj.intdef = obj.loc_addnonpieinterrupts();
                if any(ismember(obj.interruptGroupNames, 'CLA Trigger Sources'))
                    obj.intdef = obj.loc_addCLATriggerSources();
                end
                obj.intdef.serialize;
                % Save as mat file
                matlabshared.svd.internal.saveInterruptDefinitionToMATFile(obj.intdef);
                 if strcmp(obj.subFamilyName,'F2837xS')
                    obj.subFamilyName = 'F2837x';
                 end
                if ~ismember(obj.subFamilyName,{'F2838x'})
                    % Don't generate none files for heterogeneous targets
                    % For hetergeneous target, none files needs to be
                    % shipped

                    for boardIdx = 1:length(hardwareBoards)
                        hardwareBoard = hardwareBoards(boardIdx);
                        if ~isempty(hardwareBoard.ProcessingUnitInfo)
                            subFamily = hardwareBoards(boardIdx).SubFamily;
                            boardName = hardwareBoards(boardIdx).Name;
                            if strcmp(obj.subFamilyName, ['F',subFamily]) || ...
                                    strcmp([obj.subFamilyName,'S'], ['F',subFamily]) ||...
                                    strcmp([obj.subFamilyName,'D'],  ['F',subFamily])
                                obj.intdef.setName(boardName);
                                fileName = strrep(boardName, ' ', '');
                                noneFileName = fullfile(interruptFilePath, [fileName, '_None_interrupts.xml']); %#ok<AGROW>
                                obj.intdef.setDefinitionFileName(noneFileName);
                                bcdef = obj.intdef.getBuildConfigurationInfo;
                                bcdef.DefinitionFileName = '';
                                obj.intdef.BuildConfigurationInfo = bcdef;
                                obj.intdef.serialize;
                                intdef = obj.intdef;
                                [~,fileName] = fileparts(noneFileName);
                                save(fullfile(interruptFilePath,[fileName '.mat']),'intdef','-mat');
                            end
                        end
                    end
                end
            end
            %Disable new hardware board
            previewNewHardwareBoard('No');
        end


        %-------------------------------------------------------------------------
        % Creates a vector ID table for the interrupt based on cpu and pie number
        %-------------------------------------------------------------------------
        function irqnum = loc_createVectorIDTable(~,cpuLength,pieLength)
            irqnum = zeros(cpuLength,pieLength);
            for cpunum = 1: cpuLength
                for pienum = 1 : pieLength
                    if pienum > 8
                        irqnum(cpunum,pienum) = 128 + (cpunum-1)*8 + mod((pienum-1),8);
                    else
                        irqnum(cpunum,pienum) = 32 + (cpunum-1)*8 + mod((pienum-1),8);
                    end
                end
            end
        end
        %--------------------------------------------------------------------------
        % Finds the group to which a given interrupt(isrName) belongs to from the
        % available groups(interruptGroupID)
        %--------------------------------------------------------------------------
        function isrGrpName = loc_getTIInterruptGroup(obj,isrName)

            flag =0;
            for i = 1 : length(obj.interruptGroupID)
                len = length(obj.interruptGroupID{i});
                if contains(isrName,'CIPC')|| contains(isrName,'CMTOCPUXIPC')
                    % different condition for 2838x IPC interrupts
                    isrGrpName = 'IPC';
                    flag =1;
                elseif contains(isrName,'MXINT')||contains(isrName,'MRINT')
                    isrGrpName = 'MCBSP';
                    flag =1;
                elseif ismember(isrName,{'CPUCRC_INT','CLA1CRC_INT'})
                    isrGrpName = 'CRC';
                    flag =1;
                elseif ismember(isrName,{'SEQ1INT','SEQ2INT'})
                    % Add seq1int and seq2 int to group ADC
                    isrGrpName = 'ADC';
                    flag =1;
                elseif contains(isrName,'MTOCIPC')
                    %special condition for F28m35x IPC interrupts
                    isrGrpName = 'IPC';
                    flag =1;
                elseif len < length(isrName) && strcmp(isrName(1:len),obj.interruptGroupID{i})
                    isrGrpName = obj.interruptGroupID{i};
                    flag = 1;
                end
            end
            if flag==0
                isrGrpName ='MISC';
            end
        end
        %--------------------------------------------------------------------------
        % Sets the interrupt definition
        %-------------------------------------------------------------------------
        function intdef = loc_setInterruptDefinition(obj)
            intdef = codertarget.interrupts.HWInterruptInfo;
            intdef.setDefinitionFileName(obj.interruptFileName);
            %Setting Synchronous IRQ number for the base rate - timer0 interrupt
            intdef.setSynchronousSchIRQNumber(38);
            if strcmp(obj.subFamilyName,'F2837xS')
                hwname = 'F2837x';
            else
                hwname = obj.subFamilyName;
            end
            intdef.setName(hwname);
            intdef.setTargetName('TI C2000');
            intdef.setEnableInterruptPeripheralFcn('HWI_TIC28x_EnablePeripheralInterrupt');
            intdef.setDisableInterruptPeripheralFcn('HWI_TIC28x_DisablePeripheralInterrupt');
            intdef.setConfigureIRQFcn('HWI_TIC28x_ConfigureIRQ');
            intdef.setEnableIRQFcn('HWI_TIC28x_EnableIRQ');
            intdef.setDisableIRQFcn('HWI_TIC28x_DisableIRQ');
            intdef.setEpilogue('HWI_TIC28x_AcknowledgeIrq($(ISR_NUMBER));');
            %intdef.setSupportDefaultEventInInterrupt(true);
            intdef.setCallConfigureAfterScheduler(true);
            intdef.setPriorityOrder(false);
            intdef.setArbitration(false);
            % Max value represents maximum interrupts possible in a model
            % Setting it to max value of uint8
            intdef.setPriorityRangeStruct(struct('Min',0,'Max',256));
            intdef.setSoftwareManagedPriority(true,'codertarget.tic2000.internal.managePriorityC2000');
            intdef.setGenerateInInterruptsSource(false);
            intdef.addBlockCallbackFcn('BlockInitFcn','codertarget.registry.registerTIC2000HWInterruptBlocks');
            bcdef = codertarget.attributes.BuildConfigurationInfo;
            % Source files with enable, configure and disable functions
            bcdef.SourceFiles = {'$(MATLAB_ROOT)/toolbox/c2b/tic2000/src/MW_c2000ISR.c'};
            bcdef.IncludeFiles = {'MW_c2000ISR.h'};
            bcdef.IncludePaths = fullfile('$(MATLAB_ROOT)/toolbox/c2b/tic2000/inc');
            bcdef.SupportedToolchains = 'all';
            intdef.addNewBuildConfigurationInfo(bcdef);
        end
        %--------------------------------------------------------------------------
        % Adds the non pie interrupt
        %-------------------------------------------------------------------------
        function intdef = loc_addnonpieinterrupts(obj)
            intdef = obj.intdef;
            NONPIE = {'TIMER1_INT', 'TIMER2_INT', 'DATALOG_INT', 'RTOS_INT','EMU_INT','NMI_INT','ILLEGAL_INT',...
                'USER1_INT','USER2_INT','USER3_INT','USER4_INT','USER5_INT','USER6_INT','USER7_INT',...
                'USER8_INT','USER9_INT','USER10_INT','USER11_INT','USER12_INT'};
            % Add interrupt table for non peripheral interrupts
            % all interrupts are put in Non PIE Interrupts except Timer1 and
            % Timer2
            for i=1:length(NONPIE)
                isrNumber = 12 + i;
                isrName = NONPIE{i};
                if (i==1||i==2)
                    intrgrp = intdef.getInterruptGroup('CPU Timer');
                    grp = 'TIM';
                    if ismember(obj.subFamilyName,{'F280x','F281x','F2802x','F2803x','F2804x','F2805x','F2806x','F2833x'...
                            'F28M35x','F28M36x'})
                        % Above targets use TINT0/1/2 to represent Timer interrupts
                        isrName = ['TINT',num2str(i)];
                    end
                else
                    intrgrp = intdef.getInterruptGroup('Non PIE Interrupts');
                    grp = 'NPI';
                end

                isr = intrgrp.addNewInterrupt(isrName,isrNumber);
                intrgrp.setIsrDefinitionSignature('interrupt void $(ISR_NAME)(void)');
                isr.setPriority(0);
                evtStruct = feval(str2func(obj.eventsInfoFile),grp,isrName,obj.subFamilyName);
                if ~isempty(evtStruct.evtName)
                    for evtnum = 1:length(evtStruct.evtName)
                        evt = isr.addNewEvent(evtStruct.evtName(evtnum));
                        if strcmp(grp,'TIM')
                            regid = 'CpuTimer1Regs';
                            [evtStatusString , evtClearString] = obj.loc_getEventFlagStrings(isrName, regid, evtStruct, evtnum, grp, isr);
                        else
                            [evtStatusString , evtClearString] = obj.loc_getNPEventFlagStrings(isrName, evtStruct, evtnum, isr);
                        end
                        evt.setEventStatus(evtStatusString);
                        evt.setClearEventStatus(evtClearString);
                    end
                end
            end
        end
        %--------------------------------------------------------------------------
        % Adds the interrupt groups and events
        %-------------------------------------------------------------------------
        function intdef = loc_addInterruptGroups(obj)
            intdef = obj.intdef;
            %% Create Vector ID Table
            m = size(obj.interruptNameID,1);
            n = size(obj.interruptNameID,2);
            vectorID = obj.loc_createVectorIDTable(m,n);
            % Add interrupt table for peripheral interrupts
            for intnum=1:size(obj.interruptNameID,1)
                for pienum=1:size(obj.interruptNameID,2)
                    % get interrupt group to which the interrupt belongs
                    isrName = obj.interruptNameID{intnum,pienum};
                    regid = obj.registerID{intnum,pienum};
                    grp = obj.loc_getTIInterruptGroup(isrName);
                    if ~isempty(grp)
                        grpIndex = find(contains(obj.interruptGroupID(:),grp),1);
                        intrgrp = intdef.getInterruptGroup(obj.interruptGroupNames{grpIndex});
                        isr = intrgrp.addNewInterrupt(isrName,vectorID(intnum,pienum));
                        intrgrp.setIsrDefinitionSignature('interrupt void $(ISR_NAME)(void)');
                        isr.setPriority(0);
                        % Set events for each interrupt group
                        evtStruct = feval(str2func(obj.eventsInfoFile),grp,isrName,obj.subFamilyName);
                        if ~isempty(evtStruct.evtName)
                            for evtnum = 1:length(evtStruct.evtName)
                                evt = isr.addNewEvent(evtStruct.evtName(evtnum));
                                [evtStatusString , evtClearString] = obj.loc_getEventFlagStrings(isrName, regid, evtStruct,evtnum, grp, isr);
                                evt.setEventStatus(evtStatusString);
                                evt.setClearEventStatus(evtClearString);
                            end
                        end
                    end
                end
            end
        end
        %--------------------------------------------------------------------------
        % Adds Event flags
        %-------------------------------------------------------------------------
        function [evtStatusString,evtClearString] = loc_getEventFlagStrings(obj,isrName, regid, evtStruct, evtnum, grp, isr)

            if ~isempty(evtStruct.evtFlag{evtnum})
                if length(evtStruct.evtFlagReg) == 1
                    regnum =1;
                else
                    regnum = evtnum;
                end
                % For CLA and CAN, dynamic flag clearing required
                if strcmp(grp,'CLA')
                    % for CLA, status flag check not required as status flag is cleared
                    % as soon as cla task starts
                    % CLA<taskNumber>_Clear_TriggerSourceFlag();
                    evtStatusString = '';
                    evtClearString = sprintf("%s",evtStruct.evtClearFlag{evtnum});
                elseif strcmp(grp,'ECAN')
                    % ECanaRegs.CANES.bit.RM/TM==1 ->Msg Rx and Tx event
                    % ECanaRegs.CANGIF0/1.bit.<evtame>0/1==1
                    % Can<module><intline>_ClearFlag(); -> CANA1_ClearFlag()
                    if ismember(evtStruct.evtName{evtnum},{'Message transmitted','Message received'})
                        evtStatusString = sprintf("%s.%s.bit.%s",regid,'CANES',evtStruct.evtFlag{evtnum});
                    else
                        evtStatusString = sprintf("%s.%s.bit.%s",regid,evtStruct.evtFlagReg{regnum},evtStruct.evtFlag{evtnum});
                    end
                    evtClearString = sprintf("%s",evtStruct.evtClearFlag{evtnum});
                elseif strcmp(grp,'CAN')
                    % CanaRegs.CAN_ES.bit.RxOk/TxOk ==1
                    % Can<module><intline>_ClearFlag(); -> CANA1_ClearFlag()
                    if strcmp(isrName,'CANA0_INT')||strcmp(isrName,'CANA1_INT')
                        isr.setIsrPrologue('union CAN_ES_REG canESRead = CanaRegs.CAN_ES;')
                    elseif strcmp(isrName,'CANB0_INT')||strcmp(isrName,'CANB1_INT')
                        isr.setIsrPrologue('union CAN_ES_REG canESRead = CanbRegs.CAN_ES;')
                    end
                    evtStatusString = sprintf("%s.bit.%s",'canESRead',evtStruct.evtFlag{evtnum});
                    evtClearString = sprintf("%s",evtStruct.evtClearFlag{evtnum});
                elseif strcmp(grp,'HRCAP') ||(strcmp(grp,'EPWM') && contains(isrName,'TZ'))
                    %EALLOW;
                    %Ecap1Regs.ECCLR.bit.<evt_name>=1;
                    %Ecap1Regs.ECCLR.bit.INT=1;
                    %EDIS;
                    evtStatusString = sprintf("%s.%s.bit.%s==1",regid,evtStruct.evtFlagReg{regnum},evtStruct.evtFlag{evtnum});
                    evtClearString = sprintf("EALLOW;\n%s.%s.bit.%s=1;\nEDIS;",regid,evtStruct.evtClearFlagReg{regnum},evtStruct.evtClearFlag{evtnum});
                    isr.setIsrEpilogue(char(sprintf("EALLOW;\n%s.%s.bit.INT=1;\nEDIS;",regid,evtStruct.evtClearFlagReg{regnum})));
                elseif strcmp(grp,'EQEP') || strcmp(grp,'ECAP') 
                    %Does not need EALLOW AND EDIS
                    %Ecap1Regs.ECCLR.bit.<evt_name>=1;
                    %Ecap1Regs.ECCLR.bit.INT=1;                    
                    evtStatusString = sprintf("%s.%s.bit.%s==1",regid,evtStruct.evtFlagReg{regnum},evtStruct.evtFlag{evtnum});
                    evtClearString = sprintf("%s.%s.bit.%s=1;",regid,evtStruct.evtClearFlagReg{regnum},evtStruct.evtClearFlag{evtnum});
                    if strcmp(isrName,'ECAP6_2_INT')||strcmp(isrName,'ECAP7_2_INT')||strcmp(isrName,'ECAP3_2_INT')
                        isr.setIsrEpilogue(char(sprintf("%s.%s.bit.CALIBINT=1;",regid,evtStruct.evtClearFlagReg{regnum})));
                    else
                        isr.setIsrEpilogue(char(sprintf("%s.%s.bit.INT=1;",regid,evtStruct.evtClearFlagReg{regnum})));
                    end
                elseif strcmp(grp,'ADC')
                    if strcmp(obj.subFamilyName,'F280x')|| strcmp(obj.subFamilyName,'F2833x')||...
                            strcmp(obj.subFamilyName,'F2804x')||strcmp(obj.subFamilyName,'F281x')
                        if contains(isrName,'SEQ')
                            evtStatusString = sprintf("%s.%s.bit.%s==1",regid,evtStruct.evtFlagReg{regnum},evtStruct.evtFlag{evtnum});
                            evtClearString = sprintf("%s.%s.bit.%s=1;",regid,evtStruct.evtClearFlagReg{regnum},evtStruct.evtClearFlag{evtnum});
                        else
                            evtStatusString ='';
                            evtClearString = sprintf("\nAdcRegs.ADCST.bit.INT_SEQ1_CLR=1;\nAdcRegs.ADCST.bit.INT_SEQ2_CLR=1;");
                        end
                    elseif strcmp(obj.subFamilyName,'F28M35x')||strcmp(obj.subFamilyName,'F28M36x')
                        % Clear both ADC Module Registers, Don't check status as we
                        % are not aware of the module
                        evtStatusString ='';
                        evtClearString = sprintf("%s.%s.bit.%s=1;",regid,evtStruct.evtClearFlagReg{regnum},evtStruct.evtClearFlag{evtnum});
                        evtClearString = sprintf("%s\n%s.%s.bit.%s=1;",evtClearString,'Adc2Regs',evtStruct.evtClearFlagReg{regnum},evtStruct.evtClearFlag{evtnum});
                    else
                        if ~ismember(evtStruct.evtName{evtnum},{'EOC event','Overflow event'})
                            evtStatusString = sprintf("%s.%s.bit.%s==1",regid,evtStruct.evtFlagReg{regnum},evtStruct.evtFlag{evtnum});
                            evtClearString = sprintf("%s.%s.bit.%s=0;",regid,evtStruct.evtClearFlagReg{regnum},evtStruct.evtClearFlag{evtnum});
                            evtClearString = sprintf("%s\n%s.%s.bit.%s=1;",evtClearString,regid,'ADCEVTCLR',evtStruct.evtClearFlag{evtnum});
                        else
                            evtStatusString = sprintf("%s.%s.bit.%s==1",regid,evtStruct.evtFlagReg{regnum},evtStruct.evtFlag{evtnum});
                            evtClearString = sprintf("%s.%s.bit.%s=1;",regid,evtStruct.evtClearFlagReg{regnum},evtStruct.evtClearFlag{evtnum});
                        end
                    end
                elseif strcmp(grp,'CLB')
                    tileNumber = isrName(4);
                    evtStatusString ='';
                    evtClearString = sprintf("CLB_clearInterruptTag(CLB%s_BASE);",tileNumber);
                elseif strcmp(grp,'I2C')
                    %Demo Code
                    % union I2CISRC_REG intsrc = I2caRegs.I2CISRC;
                    % if(intsrc.all == <intsourcenumber>)
                    if strcmp(isrName,'I2CA_INT')|| strcmp(isrName,'I2CA_HIGH_INT')||strcmp(isrName,'I2CINT1A')
                        isr.setIsrPrologue('union I2CISRC_REG intsrc = I2caRegs.I2CISRC;');
                        evtStatusString = sprintf("(intsrc.all==%s)",num2str(evtnum));
                    elseif strcmp(isrName,'I2CB_INT')
                        isr.setIsrPrologue('union I2CISRC_REG intsrc = I2cbRegs.I2CISRC;');
                        evtStatusString = sprintf("(intsrc.all==%s)",num2str(evtnum));
                    end
                    evtClearString ='';
                    if strcmp(isrName,'I2CA_FIFO_INT')|| strcmp(isrName,'I2CB_FIFO_INT')|| strcmp(isrName,'I2CINT2A')
                        evtStatusString = sprintf("%s.%s.bit.%s==1",regid,evtStruct.evtFlagReg{regnum},evtStruct.evtFlag{evtnum});
                        evtClearString = sprintf("%s.%s.bit.%s=1;",regid,evtStruct.evtClearFlagReg{regnum},evtStruct.evtClearFlag{evtnum});
                    end
                elseif strcmp(isrName,'EMIF_ERROR_INT')
                    if contains(evtStruct.evtName{evtnum},'EMIF1')
                        evtStatusString = sprintf("%s.%s.bit.%s==1",'Emif1Regs',evtStruct.evtFlagReg{regnum},evtStruct.evtFlag{evtnum});
                        evtClearString = sprintf("%s.%s.bit.%s=1;",'Emif1Regs',evtStruct.evtClearFlagReg{regnum},evtStruct.evtClearFlag{evtnum});
                    else
                        evtStatusString = sprintf("%s.%s.bit.%s==1",'Emif2Regs',evtStruct.evtFlagReg{regnum},evtStruct.evtFlag{evtnum});
                        evtClearString = sprintf("%s.%s.bit.%s=1;",'Emif2Regs',evtStruct.evtClearFlagReg{regnum},evtStruct.evtClearFlag{evtnum});
                    end
                elseif strcmp(grp,'BGCRC')||strcmp(grp,'CRC')||strcmp(isrName,'CLA1PROMCRC_INT')
                    evtStatusString = sprintf("%s.%s.bit.%s==1",regid,evtStruct.evtFlagReg{regnum},evtStruct.evtFlag{evtnum});
                    evtClearString = sprintf("EALLOW;\n%s.%s.bit.%s=1;\nEDIS;",regid,evtStruct.evtClearFlagReg{regnum},evtStruct.evtClearFlag{evtnum});
                    isr.setIsrEpilogue(char(sprintf("EALLOW;\n%s.%s.bit.INT=1;\nEDIS;",regid,evtStruct.evtClearFlagReg{regnum},evtStruct.evtClearFlag{evtnum})));
                elseif ismember(isrName,{'SYS_ERR_INT','CM_STATUS_INT'})
                    evtStatusString = sprintf("%s.%s.bit.%s==1",regid,evtStruct.evtFlagReg{regnum},evtStruct.evtFlag{evtnum});
                    evtClearString = sprintf("EALLOW;\n%s.%s.bit.%s=1;\nEDIS;",regid,evtStruct.evtClearFlagReg{regnum},evtStruct.evtClearFlag{evtnum});
                    isr.setIsrEpilogue(char(sprintf("EALLOW;\n%s.%s.bit.GINT=1;EDIS;",regid,evtStruct.evtClearFlagReg{regnum},evtStruct.evtClearFlag{evtnum})));
                elseif strcmp(isrName,'UPPA_INT')
                    %UppaRegs.ENINTST.bit.<evtname>==1
                    %UppaRegs.ENINTST.bit.<evtname>=1
                    %UppaRegs.GINTCLR.bit.GINTCLR=1
                    evtStatusString = sprintf("%s.%s.bit.%s==1",regid,evtStruct.evtFlagReg{regnum},evtStruct.evtFlag{evtnum});
                    evtClearString = sprintf("EALLOW;\n%s.%s.bit.%s=1;\nEDIS;",regid,evtStruct.evtClearFlagReg{regnum},evtStruct.evtClearFlag{evtnum});
                    isr.setIsrEpilogue(char(sprintf("EALLOW;\n%s.GINTCLR.bit.GINTCLR=1;\nEDIS;",regid)));
                elseif strcmp(grp,'LIN')
                    evtStatusString = sprintf("%s.%s.bit.%s==1",regid,evtStruct.evtFlagReg{regnum},evtStruct.evtFlag{evtnum});
                    evtClearString = sprintf("EALLOW;\n%s.%s.bit.%s=1;\nEDIS;",regid,evtStruct.evtClearFlagReg{regnum},evtStruct.evtClearFlag{evtnum});
                    if ~strcmp(obj.subFamilyName,'F2803x')
                        %LINA_0_INT
                        %Global flagclear not required for F2803x
                        intLine = isrName(6);
                        isr.setIsrEpilogue(char(sprintf("EALLOW;\n%s.LIN_GLB_INT_CLR.bit.INT%s_FLAG_CLR=1;\nEDIS;",regid,intLine)));
				    end						
                elseif ismember(grp,{'PDP','CMP','CAP','T1','T2','T3','T4'})
                    evtStatusString = sprintf("%s.%s.bit.%s==1",regid,evtStruct.evtFlagReg{regnum},evtStruct.evtFlag{evtnum});
                    maskregister = replace(evtStruct.evtClearFlagReg{regnum},'F','M');
                    evtClearString = sprintf("%s.%s.bit.%s=1;",regid,maskregister,evtStruct.evtClearFlag{evtnum});
                    evtClearString = sprintf("%s\n%s.%s.all=1<<%s;",evtClearString,regid,evtStruct.evtClearFlagReg{regnum},...
                        num2str(evtStruct.flagbit));
				elseif strcmp(grp, 'MCAN')
                        %uint32_t intrStatus;
                        %intrStatus = MCAN_getIntrStatus(MCAN0_BASE);
                        %if(intrStatus & 0x1 == 1)
                        %MCAN_clearIntrStatus(MCAN0_BASE, 0x1)
                        if contains(isrName,'MCANA') || contains(isrName,'MCANB')
                            module = isrName(5);
                        else
                            module = '0';
                        end
                        isr.setIsrPrologue(char(sprintf("uint32_t intrStatus;\nintrStatus = MCAN_getIntrStatus(MCAN%s_BASE);",module)));
                        evtBitMask = dec2hex(pow2(evtnum-1));
                        evtStatusString = sprintf("(intrStatus & 0x%s) == 1",evtBitMask);
                        evtClearString = sprintf("MCAN_clearIntrStatus(MCAN%s_BASE, %s);", module, evtBitMask);
                else
                    evtStatusString = sprintf("%s.%s.bit.%s==1",regid,evtStruct.evtFlagReg{regnum},evtStruct.evtFlag{evtnum});
                    if ~isempty(evtStruct.evtClearFlagReg{regnum}) && ~isempty(evtStruct.evtClearFlag{evtnum})
                        evtClearString = sprintf("EALLOW;%s.%s.bit.%s=1;EDIS;",regid,evtStruct.evtClearFlagReg{regnum},evtStruct.evtClearFlag{evtnum});
                    else
                        evtClearString = '';
                    end
                end
            else
                evtStatusString = '';
                evtClearString = '';
            end
        end
        %---------------------------------------------------------------------------------------------
        %NP flags
        %---------------------------------------------------------------------------------------------
        function [evtStatusString,evtClearString]= loc_getNPEventFlagStrings(~, isrName, evtStruct, evtnum, isr)
            if ~isempty(evtStruct.evtFlag{evtnum})
                if length(evtStruct.evtFlagReg) == 1
                    regnum = 1;
                else
                    regnum = evtnum;
                end

                if strcmp(isrName,'NMI_INT')
                    evtStatusString = sprintf("NmiIntruptRegs.%s.bit.%s==1",evtStruct.evtFlagReg{regnum},evtStruct.evtFlag{evtnum});
                    %NmiIntruptRegs.NMIFLGCLR.bit.<evt_name> =1;
                    %NmiIntruptRegs.NMIFLGCLR.bit.NMIINT =1;
                    evtClearString = sprintf("EALLOW;\nNmiIntruptRegs.%s.bit.%s=1;\nEDIS;",evtStruct.evtClearFlagReg{regnum},evtStruct.evtClearFlag{evtnum});
                    isr.setIsrEpilogue(char(sprintf("EALLOW;\nNmiIntruptRegs.NMIFLGCLR.bit.NMIINT=1;\nEDIS;")));

                end
            else
                evtStatusString = '';
                evtClearString = '';
            end
        end
        %---------------------------------------------------------------------------------------------
        % CLA trigger sources
        %---------------------------------------------------------------------------------------------
        function intdef = loc_addCLATriggerSources(obj)
            intdef = obj.intdef;
            CLATrigSources = '';
            CLAInterruptMaps = '';
            isrNumber = '';
            nonPieNumber = 260;
            if ismember(obj.subFamilyName, {'F2806x'})
                CLATrigSources = {'ADC_INT1', 'EPWM1INT', 'ADC_INT2', 'EPWM2INT', 'ADC_INT3', 'EPWM3INT', ...
                    'EPWM4INT','EQEP1INT', 'EQEP2INT', 'ECAP1INT', 'ECAP2INT', 'ECAP3INT', 'ADC_INT5',...
                    'EPWM5INT','EPWM6INT', 'ADC_INT7', 'EPWM7INT','ADC_INT8', 'TIMER0_INT'};
                CLAInterruptMaps = {'ADCINT1', 'EPWM1_INT','ADCINT2', 'EPWM2_INT', 'ADCINT3','EPWM3_INT',...
                    'EPWM4_INT', 'EQEP1_INT', 'EQEP2_INT', 'ECAP1_INT', 'ECAP2_INT', 'ECAP3_INT', 'ADCINT5',...
                    'EPWM5_INT','EPWM6_INT', 'ADCINT7','EPWM7_INT','ADCINT8', 'TINT0'};
            elseif ismember(obj.subFamilyName,{'F2805x','F2803x'})
                CLATrigSources = {'ADC_INT1', 'EPWM1INT', 'ADC_INT2', 'EPWM2INT', 'ADC_INT3', 'EPWM3INT', ...
                    'EPWM4INT','EQEP1INT', 'ECAP1INT', 'ADC_INT5',...
                    'EPWM5INT','EPWM6INT', 'ADC_INT7', 'EPWM7INT','ADC_INT8', 'TIMER0_INT'};
                CLAInterruptMaps = {'ADCINT1', 'EPWM1_INT','ADCINT2', 'EPWM2_INT', 'ADCINT3','EPWM3_INT',...
                    'EPWM4_INT', 'EQEP1_INT', 'ECAP1_INT', 'ADCINT5',...
                    'EPWM5_INT','EPWM6_INT', 'ADCINT7','EPWM7_INT','ADCINT8', 'TINT0'};
            elseif ismember(obj.subFamilyName, {'F2807x','F2837xS'})
                %Type 1
                CLAInterruptMaps = {'ADCA1_INT', 'ADCA2_INT', 'ADCA3_INT', 'ADCA4_INT', ...
                    'ADCA_EVT_INT', 'ADCB1_INT', 'ADCB2_INT', 'ADCB3_INT', 'ADCB4_INT', ...
                    'ADCB_EVT_INT','ADCC1_INT', 'ADCC2_INT', 'ADCC3_INT', 'ADCC4_INT', ...
                    'ADCC_EVT_INT','ADCD1_INT', 'ADCD2_INT', 'ADCD3_INT', 'ADCD4_INT', ...
                    'ADCD_EVT_INT','XINT1_INT', 'XINT2_INT', 'XINT3_INT', 'XINT4_INT', 'XINT5_INT' ...
                    'EPWM1_INT','EPWM2_INT', 'EPWM3_INT', 'EPWM4_INT', 'EPWM5_INT', ...
                    'EPWM6_INT','EPWM7_INT', 'EPWM8_INT', 'EPWM9_INT', 'EPWM10_INT', ...
                    'EPWM11_INT','EPWM12_INT', 'TIMER0_INT', 'TINT1', 'TINT2', ...
                    'MCBSPA_TX_INT','MCBSPA_RX_INT', 'MCBSPB_TX_INT', 'MCBSPB_RX_INT', 'ECAP1_INT', ...
                    'ECAP2_INT','ECAP3_INT', 'ECAP4_INT', 'ECAP5_INT', 'ECAP6_INT', ...
                    'EQEP1_INT','EQEP2_INT', 'EQEP3_INT', 'SD1_INT', 'SD2_INT', ...
                    'UPPA_INT','SPIA_TX_INT', 'SPIA_RX_INT', 'SPIB_TX_INT', 'SPIB_RX_INT', ...
                    'SPIC_TX_INT','SPIC_RX_INT'};
                CLATrigSources = {'ADCAINT1', 'ADCAINT2', 'ADCAINT3', 'ADCAINT4', ...
                    'ADCAEVT', 'ADCBINT1', 'ADCBINT2', 'ADCBINT3', 'ADCBINT4', ...
                    'ADCBEVT','ADCCINT1', 'ADCCINT2', 'ADCCINT3', 'ADCCINT4', ...
                    'ADCCEVT','ADCDINT1', 'ADCDINT2', 'ADCDINT3', 'ADCDINT4', ...
                    'ADCDEVT','XINT1', 'XINT2', 'XINT3', 'XINT4', 'XINT5' ...
                    'EPWM1INT','EPWM2INT', 'EPWM3INT', 'EPWM4INT', 'EPWM5INT', ...
                    'EPWM6INT','EPWM7INT', 'EPWM8INT', 'EPWM9INT', 'EPWM10INT', ...
                    'EPWM11INT','EPWM12INT', 'TINT0', 'TINT1', 'TINT2', ...
                    'MXEVTA','MREVTA', 'MXEVTB', 'MREVTB', 'ECAP1INT', ...
                    'ECAP2INT','ECAP3INT', 'ECAP4INT', 'ECAP5INT', 'ECAP6INT', ...
                    'EQEP1INT','EQEP2INT', 'EQEP3INT', 'SD1INT', 'SD2INT', ...
                    'UPP1_INT','SPITXINTA', 'SPIRXINTA', 'SPITXINTB', 'SPIRXINTB', ...
                    'SPITXINTC','SPIRXINTC'};

            elseif ismember(obj.subFamilyName, {'F28004x'})
                %Type 2
                CLAInterruptMaps = {'ADCA1_INT', 'ADCA2_INT', 'ADCA3_INT', 'ADCA4_INT', ...
                    'ADCA_EVT_INT', 'ADCB1_INT', 'ADCB2_INT', 'ADCB3_INT', 'ADCB4_INT', ...
                    'ADCB_EVT_INT','ADCC1_INT', 'ADCC2_INT', 'ADCC3_INT', 'ADCC4_INT', ...
                    'ADCC_EVT_INT','XINT1_INT', 'XINT2_INT', 'XINT3_INT', 'XINT4_INT', 'XINT5_INT' ...
                    'EPWM1_INT','EPWM2_INT', 'EPWM3_INT', 'EPWM4_INT', 'EPWM5_INT', ...
                    'EPWM6_INT','EPWM7_INT', 'EPWM8_INT', 'TIMER0_INT', 'TINT1', 'TINT2', ...
                    'ECAP1_INT','ECAP2_INT','ECAP3_INT', 'ECAP4_INT', 'ECAP5_INT', 'ECAP6_INT', ...
                    'ECAP7_INT', 'EQEP1_INT','EQEP2_INT', 'ECAP6_2_INT', 'ECAP7_2_INT', 'SDFM1_INT', ...
                    'SDFM1DR1_INT', 'SDFM1DR2_INT','SDFM1DR3_INT', 'SDFM1DR4_INT', 'PMBUSA_INT', ...
                    'SPIA_TX_INT', 'SPIA_RX_INT', 'SPIB_TX_INT', 'SPIB_RX_INT', 'LINA_0_INT',...
                    'LINA_1_INT', 'CLA1PROMCRC_INT','FSITX_INT1','FSITX_INT2', 'FSIRX_INT1', 'FSIRX_INT2'};
                CLATrigSources = {'ADCA1', 'ADCA2', 'ADCA3', ...
                    'ADCA4', 'ADCAEVT', 'ADCB1', 'ADCB2', 'ADCB3', 'ADCB4', 'ADCBEVT', ...
                    'ADCC1', 'ADCC2', 'ADCC3', 'ADCC4', 'ADCCEVT', 'XINT1', 'XINT2','XINT3', ...
                    'XINT4', 'XINT5', 'EPWM1INT', 'EPWM2INT', 'EPWM3INT', 'EPWM4INT','EPWM5INT', 'EPWM6INT', ...
                    'EPWM7INT', 'EPWM8INT', 'TINT0', 'TINT1', 'TINT2', 'ECAP1INT', 'ECAP2INT', 'ECAP3INT', ...
                    'ECAP4INT', 'ECAP5INT', 'ECAP6INT', 'ECAP7INT', 'EQEP1INT', 'EQEP2INT', 'ECAP6INT2', ...
                    'ECAP7INT2', 'SDFM1INT', 'SDFM1DRINT1', 'SDFM1DRINT2', 'SDFM1DRINT3', 'SDFM1DRINT4', ...
                    'PMBUSAINT', 'SPITXAINT', 'SPIRXAINT', 'SPITXBINT', 'SPIRXBINT', 'LINAINT0', 'LINAINT1', ...
                    'CLA1PROMCRC', 'FSITXAINT1', 'FSITXAINT2', 'FSIRXAINT1', 'FSIRXAINT2'};
            elseif ismember(obj.subFamilyName, {'F2838x'})
                %Type 2.1
                CLAInterruptMaps = {'ADCA1_INT', 'ADCA2_INT', 'ADCA3_INT', 'ADCA4_INT', ...
                    'ADCA_EVT_INT', 'ADCB1_INT', 'ADCB2_INT', 'ADCB3_INT', 'ADCB4_INT', ...
                    'ADCB_EVT_INT','ADCC1_INT', 'ADCC2_INT', 'ADCC3_INT', 'ADCC4_INT', ...
                    'ADCC_EVT_INT','ADCD1_INT', 'ADCD2_INT', 'ADCD3_INT', 'ADCD4_INT', ...
                    'ADCD_EVT_INT','XINT1_INT', 'XINT2_INT', 'XINT3_INT', 'XINT4_INT', 'XINT5_INT' ...
                    'EPWM1_INT','EPWM2_INT', 'EPWM3_INT', 'EPWM4_INT', 'EPWM5_INT', ...
                    'EPWM6_INT','EPWM7_INT', 'EPWM8_INT', 'EPWM9_INT','EPWM10_INT', 'EPWM11_INT', ...
                    'EPWM12_INT', 'EPWM13_INT', 'EPWM14_INT','EPWM15_INT', 'EPWM16_INT', ...
                    'MCANA_EVT0', 'MCANA_EVT1', 'MCANA_EVT2', 'TIMER0_INT', 'TINT1', 'TINT2', ...
                    'MCBSPA_TX_INT', 'MCBSPA_RX_INT', 'MCBSPB_TX_INT', 'MCBSPB_RX_INT', ...
                    'ECAP1_INT','ECAP2_INT','ECAP3_INT', 'ECAP4_INT', 'ECAP5_INT', 'ECAP6_INT', ...
                    'ECAP7_INT', 'EQEP1_INT','EQEP2_INT', 'EQEP3_INT', 'ECAP6_2_INT', 'ECAP7_2_INT', ...
                    'SDFM1_INT', 'SDFM2_INT', 'ECATSYNC0_INT', 'ECATSYNC1_INT', ...
                    'PMBUSA_INT', 'SPIA_TX_INT', 'SPIA_RX_INT', 'SPIB_TX_INT', 'SPIB_RX_INT', ...
                    'SPIC_TX_INT', 'SPIC_RX_INT', 'SPID_TX_INT', 'SPID_RX_INT', ...
                    'CLA1CRC_INT', 'FSITXA1_INT' ,'FSITXA2_INT','FSIRXA1_INT', ...
                    'FSIRXA2_INT', 'SDFM1DR1_INT', 'SDFM1DR2_INT', 'SDFM1DR3_INT', 'SDFM1DR4_INT', ...
                    'SDFM2DR1_INT', 'SDFM2DR2_INT', 'SDFM2DR3_INT', 'SDFM2DR4_INT', ...
                    'FSITXB1_INT', 'FSITXB2_INT', 'FSIRXB1_INT', 'FSIRXB2_INT', 'FSIRXC1_INT', 'FSIRXC2_INT', ...
                    'FSIRXD1_INT', 'FSIRXD2_INT', 'FSIRXE1_INT', 'FSIRXE2_INT', ...
                    'FSIRXF1_INT', 'FSIRXF2_INT', 'FSIRXG1_INT', 'FSIRXG2_INT', 'FSIRXH1_INT', 'FSIRXH2_INT'};
                CLATrigSources = {'ADCA1', 'ADCA2', 'ADCA3', ...
                    'ADCA4', 'ADCAEVT', 'ADCB1', 'ADCB2', 'ADCB3', 'ADCB4', 'ADCBEVT', ...
                    'ADCC1', 'ADCC2', 'ADCC3', 'ADCC4', 'ADCCEVT', 'ADCD1','ADCD2','ADCD3', ...
                    'ADCD4','ADCDEVT', 'XINT1', 'XINT2','XINT3','XINT4', 'XINT5', 'EPWM1INT', ...
                    'EPWM2INT', 'EPWM3INT', 'EPWM4INT','EPWM5INT', 'EPWM6INT', ...
                    'EPWM7INT', 'EPWM8INT', 'EPWM9INT','EPWM10INT', 'EPWM11INT', 'EPWM12INT', ...
                    'EPWM13INT', 'EPWM14INT', 'EPWM15INT', 'EPWM16INT', 'MCANA_FEVT0', 'MCANA_FEVT1', 'MCANA_FEVT2', ...
                    'TINT0', 'TINT1', 'TINT2', 'MXINTA', 'MRINTA', 'MXINTB', 'MRINTB', ...
                    'ECAP1INT', 'ECAP2INT', 'ECAP3INT', 'ECAP4INT', 'ECAP5INT', 'ECAP6INT', 'ECAP7INT', ...
                    'EQEP1INT', 'EQEP2INT', 'EQEP3INT', 'ECAP6INT2', 'ECAP7INT2', 'SDFM1INT', 'SDFM2INT', ...
                    'ECATSYNC0INT', 'ECATSYNC1INT', 'PMBUSAINT', 'SPITXAINT', 'SPIRXAINT', 'SPITXBINT', 'SPIRXBINT', 'SPITXCINT', ...
                    'SPIRXCINT', 'SPITXDINT', 'SPIRXDINT', 'CLA1CRCINT', 'FSITXAINT1', 'FSITXAINT2', 'FSIRXAINT1', 'FSIRXAINT2', ...
                    'SDFM1DRINT1', 'SDFM1DRINT2', 'SDFM1DRINT3', 'SDFM1DRINT4', 'SDFM2DRINT1', ...
                    'SDFM2DRINT2', 'SDFM2DRINT3', 'SDFM2DRINT4', 'FSITXBINT1', 'FSITXBINT2', 'FSIRXBINT1', ...
                    'FSIRXBINT2', 'FSIRXCINT1', 'FSIRXCINT2', 'FSIRXDINT1', 'FSIRXDINT2', 'FSIRXEINT1', ...
                    'FSIRXEINT2', 'FSIRXFINT1', 'FSIRXFINT2', 'FSIRXGINT1', 'FSIRXGINT2', 'FSIRXHINT1', ...
                    'FSIRXHINT2'};

            elseif ismember(obj.subFamilyName, {'F28003x'})
                %Type 2.2
                CLAInterruptMaps = {'ADCA1_INT', 'ADCA2_INT', 'ADCA3_INT', ...
                    'ADCA4_INT', 'ADCA_EVT_INT', 'ADCB1_INT', 'ADCB2_INT', 'ADCB3_INT', 'ADCB4_INT', 'ADCB_EVT_INT', ...
                    'ADCC1_INT', 'ADCC2_INT', 'ADCC3_INT', 'ADCC4_INT', 'ADCC_EVT_INT', ...
                    'XINT1_INT', 'XINT2_INT','XINT3_INT','XINT4_INT', 'XINT5_INT', ...
                    'EPWM1_INT', 'EPWM2_INT', 'EPWM3_INT', 'EPWM4_INT', ...
                    'EPWM5_INT', 'EPWM6_INT', 'EPWM7_INT', 'EPWM8_INT', ...
                    'MCANA_FEVT0', 'MCANA_FEVT1', 'MCANA_FEVT2', ...
                    'TIMER0_INT', 'TIMER1_INT', 'TIMER2_INT', ...
                    'ECAP1_INT', 'ECAP2_INT', 'ECAP3_INT', ...
                    'EQEP1_INT', 'EQEP2_INT', 'ECAP3_2_INT', ...
                    'SDFM1_INT', 'SDFM1DR1_INT', 'SDFM1DR2_INT', 'SDFM1DR3_INT', 'SDFM1DR4_INT', ...
                    'SDFM2_INT', 'SDFM2DR1_INT', 'SDFM2DR2_INT', 'SDFM2DR3_INT', 'SDFM2DR4_INT', 'PMBUSA_INT' ...
                    'SPIA_TX_INT', 'SPIA_RX_INT', 'SPIB_TX_INT', 'SPIB_RX_INT', ...
                    'LINA_1_INT', 'LINA_0_INT', 'LINB_1_INT', 'LINB_0_INT', 'BGCRC_CLA1_INT'...
                    'FSITXA1_INT', 'FSITXA2_INT', 'FSIRXA1_INT', 'FSIRXA2_INT', ...
                    'CLB1_INT', 'CLB2_INT', 'CLB3_INT', 'CLB4_INT', 'HICA_INT' ...
                    'DMA_CH1_INT', 'DMA_CH2_INT', 'DMA_CH3_INT', 'DMA_CH4_INT', 'DMA_CH5_INT', 'DMA_CH6_INT'};
                CLATrigSources = {'ADCA1', 'ADCA2', 'ADCA3', ...
                    'ADCA4', 'ADCAEVT', 'ADCB1', 'ADCB2', 'ADCB3', 'ADCB4', 'ADCBEVT', ...
                    'ADCC1', 'ADCC2', 'ADCC3', 'ADCC4', 'ADCCEVT', ...
                    'XINT1', 'XINT2','XINT3','XINT4', 'XINT5', ...
                    'EPWM1INT', 'EPWM2INT', 'EPWM3INT', 'EPWM4INT', ...
                    'EPWM5INT', 'EPWM6INT', 'EPWM7INT', 'EPWM8INT', ...
                    'MCANA_FEVT0', 'MCANA_FEVT1', 'MCANA_FEVT2', ...
                    'TINT0', 'TINT1', 'TINT2', ...
                    'ECAP1INT', 'ECAP2INT', 'ECAP3INT', ...
                    'EQEP1INT', 'EQEP2INT', 'ECAP3INT2', ...
                    'SDFM1INT', 'SDFM1DRINT1', 'SDFM1DRINT2', 'SDFM1DRINT3', 'SDFM1DRINT4', ...
                    'SDFM2INT', 'SDFM2DRINT1', 'SDFM2DRINT2', 'SDFM2DRINT3', 'SDFM2DRINT4', 'PMBUSAINT' ...
                    'SPITXAINT', 'SPIRXAINT', 'SPITXBINT', 'SPIRXBINT', ...
                    'LINAINT1', 'LINAINT0', 'LINBINT1', 'LINBINT0', 'CLA1CRCINT'...
                    'FSITXAINT1', 'FSITXAINT2', 'FSIRXAINT1', 'FSIRXAINT2', ...
                    'CLB1INT', 'CLB2INT', 'CLB3INT', 'CLB4INT', 'HICAINT' ...
                    'DMACH1INT', 'DMACH2INT', 'DMACH3INT', 'DMACH4INT', 'DMACH5INT', 'DMACH6INT'};
            
            elseif ismember(obj.subFamilyName, {'F28p65x'})
                % Add Trigger sources and Interrupt Maps for TI F28P65x
                % targets
                CLATrigSources = codertarget.tic2000.masks.cla.type2p3.getMaskParams('TrigSources');
                CLATrigSources = CLATrigSources(2:end);
                CLAInterruptMaps = codertarget.tic2000.masks.cla.type2p3.getMaskParams('InterruptMaps');
                CLAInterruptMaps = CLAInterruptMaps(2:end);
            end

            % Add CLA Software triggers to interrupt xml
            for i = 1:8
                intrgrp = intdef.getInterruptGroup('CLA Trigger Sources');
                isrName = ['Software_Task',num2str(i)];
                % Giving a dummy value to trig source 'Software'
                nonPieNumber = nonPieNumber + 1;
                isrNumber = nonPieNumber; 
                isr = intrgrp.addNewInterrupt(isrName, isrNumber);
                intrgrp.setIsrDefinitionSignature('interrupt void $(ISR_NAME)(void)');
                isr.setPriority(0);
                evt = isr.addNewEvent('CLA trigger event');
                evtStatusString = '';
                evtClearString = '';
                evt.setEventStatus(evtStatusString);
                evt.setClearEventStatus(evtClearString);
            end
            % Add CLA trigger sources to interrupt xml
            for i=1:length(CLATrigSources)
                cpunum = 0;
                pienum = 0;
                intrgrp = intdef.getInterruptGroup('CLA Trigger Sources');
                isrName = CLATrigSources{i};
                % Need to add interrupt number for each trigger source
                if ismember(isrName, {'MCANA_FEVT0', 'MCANA_FEVT1', 'MCANA_FEVT2','MCANB_FEVT0', 'MCANB_FEVT1', 'MCANB_FEVT2'})
                     % For trigger sources which are not in interrupt table
                    % isrNmumber is given a dummy value
                    nonPieNumber = nonPieNumber + 1;
                    isrNumber = nonPieNumber;
                elseif strcmp(isrName, 'TINT1')
                    isrNumber = 13;
                elseif strcmp(isrName, 'TINT2')
                    isrNumber = 14;                    
                else
                    [cpunum, pienum] = find(strcmp(CLAInterruptMaps{i},obj.interruptNameID));
                    if pienum > 8
                        irqnum = 128 + (cpunum-1)*8 + mod((pienum-1),8);
                    else
                        irqnum = 32 + (cpunum-1)*8 + mod((pienum-1),8);
                    end
                    isrNumber = irqnum;
                end                
                isr = intrgrp.addNewInterrupt(isrName,isrNumber);
                intrgrp.setIsrDefinitionSignature('interrupt void $(ISR_NAME)(void)');
                isr.setPriority(0);
                evt = isr.addNewEvent('CLA trigger event');
                evtStatusString = '';
                if ~ismember(isrName, {'MCANA_FEVT0', 'MCANA_FEVT1', 'MCANA_FEVT2', 'MCANB_FEVT0', 'MCANB_FEVT1', 'MCANB_FEVT2', 'TINT1','TINT2'}) ...
                    && ~(contains(isrName,'SPI') && contains(isrName,'TX'))
                    if(~isempty(obj.INTBT{cpunum, pienum}))
                        if contains(isrName, 'ECAP')
                             evtClearString = sprintf("EALLOW;\n%s.ECCLR.all = %s.ECFLG.all;\nEDIS;",obj.registerID{cpunum, pienum},obj.registerID{cpunum, pienum});
                        else
                             evtClearString = sprintf("EALLOW;\n%s.%s.bit.%s=1;\nEDIS;",obj.registerID{cpunum, pienum},...
                             obj.FIELD{cpunum, pienum},obj.INTBT{cpunum, pienum});
                        end
                    else
                        evtClearString = '';
                    end
                else
                    evtClearString = '';
                end
                evt.setEventStatus(evtStatusString);
                evt.setClearEventStatus(evtClearString);
            end
        end
    end
end