gusucode.com > target工具箱matlab源码程序 > target/extensions/processor/shared/ti/mdlinfo/getIRInfo_Targets_C2000.m
function [linkPjtGenInfo, schedPjtGenInfo, targetPjtGenInfo] = getIRInfo_Targets_C2000(action, linkPjtGenInfo, schedPjtGenInfo, targetPjtGenInfo) %GETIRINFO_TARGETS_C2000 Populate PjtGenInfo with Target-specific information. % Copyright 2007-2015 The MathWorks, Inc. switch lower(action) case 'init' [linkPjtGenInfo, schedPjtGenInfo, targetPjtGenInfo] = ... initTargetsPjtGenInfo(linkPjtGenInfo, schedPjtGenInfo, targetPjtGenInfo); case 'process_blocks' [linkPjtGenInfo, schedPjtGenInfo, targetPjtGenInfo] = ... processTargetsBlocks(linkPjtGenInfo, schedPjtGenInfo, targetPjtGenInfo); case 'validate' [linkPjtGenInfo, schedPjtGenInfo, targetPjtGenInfo] = ... validatePjtGenResources(linkPjtGenInfo, schedPjtGenInfo, targetPjtGenInfo); otherwise linkPjtGenInfo.error = 1; DAStudio.error('TARGETSHARED:codegen:IRInfoUnrecognizedAction', action); end %% ------------------------------------------------------------------------ function [linkPjtGenInfo, schedPjtGenInfo, targetPjtGenInfo] = initTargetsPjtGenInfo(linkPjtGenInfo, schedPjtGenInfo, targetPjtGenInfo) %INITIRINFO Initialize the PjtGenInfo fields. %---------------------------------- % Target-specific: common %---------------------------------- [linkPjtGenInfo, schedPjtGenInfo, targetPjtGenInfo] = ... getIRInfo_TITargets('init', 'C2000', ... linkPjtGenInfo, schedPjtGenInfo, targetPjtGenInfo); %---------------------------------- % Target-specific: C2000 %---------------------------------- % none %% ------------------------------------------------------------------------ function [linkPjtGenInfo, schedPjtGenInfo, targetPjtGenInfo] = processTargetsBlocks(linkPjtGenInfo, schedPjtGenInfo, targetPjtGenInfo) %PROCESSTARGETBLOCKS Process Target blocks. %-------------------------------- % Common TI blocks %-------------------------------- [linkPjtGenInfo, schedPjtGenInfo, targetPjtGenInfo] = ... getIRInfo_TITargets('process_blocks','C2000', ... linkPjtGenInfo, schedPjtGenInfo, targetPjtGenInfo); if (linkPjtGenInfo.error==1) return; end %-------------------------------- % Specific TI Target C2000 blocks %-------------------------------- blockList = {... 'ADC', ... 'CAN', ... 'CAP', ... 'IQmath', ... 'PWM', ... 'QEP', ... 'SCI', ... 'SPI', ... 'I2C', ... 'WATCHDOG', ... 'DMA', ... 'LIN', ... }; for blockName = blockList if isequal(linkPjtGenInfo.sysinfo.tgtPrefs.chipInfo.subFamily, '281x') && ... isequal(blockName{1}, 'I2C') continue end functionName = ['process' blockName{1} 'blocks']; if isequal(linkPjtGenInfo.sysinfo.tgtPrefs.chipInfo.subFamily, '2834x') && isequal(blockName{1}, 'ADC') continue; end [linkPjtGenInfo, schedPjtGenInfo, targetPjtGenInfo] = feval(functionName, ... linkPjtGenInfo, schedPjtGenInfo, targetPjtGenInfo); if (linkPjtGenInfo.error==1) return; end end flashLoaderPresent = isfield(targetPjtGenInfo.sysinfo, 'peripherals') && ... isfield(targetPjtGenInfo.sysinfo.peripherals, 'DSPBoardDSPChipFlash_loaderEnable_Flash'); if ~linkfoundation.util.isQeBypass && flashLoaderPresent checkIfFlashAccepted (targetPjtGenInfo); end %% ------------------------------------------------------------------------ function [linkPjtGenInfo, schedPjtGenInfo, targetPjtGenInfo] = processADCblocks (linkPjtGenInfo, schedPjtGenInfo, targetPjtGenInfo) %#ok<DEFNU> %ADCBLOCKS Get C2x ADC block info. ADCblocks = linkfoundation.util.FindSystem(linkPjtGenInfo.modelName,targetPjtGenInfo.sysinfo.ADCblocktypes{1}); % Process all ADC blocks if (~isempty(ADCblocks)), targetPjtGenInfo.numADCs = length (ADCblocks); for i=1:length (ADCblocks), if (strcmp(targetPjtGenInfo.sysinfo.ADCblocktypes,'C2802x/03x/05x/06x/M3x/37x/07x ADC')) targetPjtGenInfo.ADC{i}.samplingMode = get_param (ADCblocks{i},'samplingMode'); if strcmp(targetPjtGenInfo.ADC{i}.samplingMode,'Single sample mode') targetPjtGenInfo.ADC{i}.useSOC = get_param (ADCblocks{i},'useSOC1'); targetPjtGenInfo.ADC{i}.channelSel = get_param (ADCblocks{i},'conv1'); else targetPjtGenInfo.ADC{i}.useSOC = strrep(get_param (ADCblocks{i},'useSOC2'), ' and ', '_'); targetPjtGenInfo.ADC{i}.channelSel = get_param (ADCblocks{i},'conv2'); end targetPjtGenInfo.ADC{i}.postINT = get_param (ADCblocks{i},'postInterrupt'); targetPjtGenInfo.ADC{i}.interruptSel = get_param (ADCblocks{i},'InterruptSel'); targetPjtGenInfo.ADC{i}.acquisitionVal = get_param (ADCblocks{i},'SOCAcquisitionWindow'); targetPjtGenInfo.ADC{i}.triggerSOC = get_param (ADCblocks{i},'SOCTriggerSource'); dlgParams = get_param (ADCblocks{i},'DialogParameters'); targetPjtGenInfo.ADC{i}.triggerSOC_Indx = find(strcmpi(dlgParams.SOCTriggerSource.Enum, targetPjtGenInfo.ADC{i}.triggerSOC),1); targetPjtGenInfo.ADC{i}.triggerINT = get_param (ADCblocks{i},'SOCInterruptTrigger'); targetPjtGenInfo.ADC{i}.continuousMode = get_param (ADCblocks{i},'ADCINTContinuous'); if (strcmp(get_param (ADCblocks{i},'endma'),'on')) targetPjtGenInfo.ADC{i}.DMACH = str2num(get_param (ADCblocks{i},'chdma')); else targetPjtGenInfo.ADC{i}.DMACH = 0; end else % non Piccolo targetPjtGenInfo.ADC{i}.useModule = get_param (ADCblocks{i},'useModule'); if (strcmp(targetPjtGenInfo.sysinfo.ADCblocktypes,'C281x ADC')) || (strcmp(targetPjtGenInfo.sysinfo.ADCblocktypes,'C280x/C2833x ADC')) targetPjtGenInfo.ADC{i}.useMode = get_param (ADCblocks{i},'useMode'); %% used in ti_c2800_csl.tlc targetPjtGenInfo.ADC{i}.triggerADCint = get_param (ADCblocks{i},'postInterrupt'); end if strcmp(targetPjtGenInfo.sysinfo.ADCblocktypes,'C280x/C2833x ADC') if ( strcmp(targetPjtGenInfo.ADC{i}.useMode,'Sequential') && strcmp(targetPjtGenInfo.ADC{i}.useModule,'A') ) targetPjtGenInfo.ADC{i}.sourceSOC = get_param (ADCblocks{i},'sourceSOC1'); targetPjtGenInfo.ADC{i}.numch_A = get_param (ADCblocks{i},'numConversionsSingle'); elseif ( strcmp(targetPjtGenInfo.ADC{i}.useMode,'Sequential') && strcmp(targetPjtGenInfo.ADC{i}.useModule,'B') ) targetPjtGenInfo.ADC{i}.sourceSOC = get_param (ADCblocks{i},'sourceSOC2'); targetPjtGenInfo.ADC{i}.numch_B = get_param (ADCblocks{i},'numConversionsSingle'); elseif ( strcmp(targetPjtGenInfo.ADC{i}.useMode,'Sequential') && strcmp(targetPjtGenInfo.ADC{i}.useModule,'A and B') ) targetPjtGenInfo.ADC{i}.sourceSOC = get_param (ADCblocks{i},'sourceSOC'); %% used in ti_c280x_csl.tlc targetPjtGenInfo.ADC{i}.numch_A = get_param (ADCblocks{i},'numConversionsDouble'); elseif ( strcmp(targetPjtGenInfo.ADC{i}.useMode,'Simultaneous') ) targetPjtGenInfo.ADC{i}.sourceSOC = get_param (ADCblocks{i},'sourceSOC'); targetPjtGenInfo.ADC{i}.numch_A = get_param (ADCblocks{i},'numConversionsSingle'); end if (strcmp(get_param (ADCblocks{i},'endma'),'on')) targetPjtGenInfo.ADC{i}.DMACH = str2num(get_param (ADCblocks{i},'chdma')); else targetPjtGenInfo.ADC{i}.DMACH = 0; end targetPjtGenInfo.ADC{i}.xint2_ADCSOC = get_param (ADCblocks{i},'xint2_ADCSOC'); else if strcmp(targetPjtGenInfo.ADC{i}.useModule,'A') || strcmp(targetPjtGenInfo.ADC{i}.useModule,'B') targetPjtGenInfo.ADC{i}.sourceSOC = get_param (ADCblocks{i}, ['sourceSOC' targetPjtGenInfo.ADC{i}.useModule]); else targetPjtGenInfo.ADC{i}.sourceSOC = get_param (ADCblocks{i},'sourceSOC'); end end end end else targetPjtGenInfo.numADCs = 0; end %% ------------------------------------------------------------------------ function [linkPjtGenInfo, schedPjtGenInfo, targetPjtGenInfo] = processCANblocks (linkPjtGenInfo, schedPjtGenInfo, targetPjtGenInfo) %#ok<DEFNU> %CANBLOCKS Get C2x CAN block info. CANblocks1 = linkfoundation.util.FindSystem(linkPjtGenInfo.modelName,targetPjtGenInfo.sysinfo.CANblocktypes{1}); CANblocks2 = linkfoundation.util.FindSystem(linkPjtGenInfo.modelName,targetPjtGenInfo.sysinfo.CANblocktypes{2}); CANblocks = [CANblocks1; CANblocks2]; % process all CAN blocks switch linkPjtGenInfo.sysinfo.tgtPrefs.chipInfo.subFamily case {'281x', '280x','2833x','2803x', '2834x', '2806x'} numCANModule = 0; % Numbers of modules CANModule = {}; % Module array numCAN_As = 0; numCAN_Bs = 0; if (~isempty(CANblocks)), targetPjtGenInfo.numCANs = length (CANblocks); for i=1:length (CANblocks), mboxNo = cast(etargets.Utilities.getEvalParam(CANblocks{i},'mailboxNo'),'double'); useModule = get_param (CANblocks{i},'useModule'); if isempty (mboxNo), mboxname = get_param (CANblocks{i},'name'); linkPjtGenInfo.error = 1; DAStudio.error('TARGETSHARED:codegen:C2000IRInfoCANMailboxNumber', mboxname); else if strcmpi( get_param (CANblocks{i},'postInterrupt'), 'on') targetPjtGenInfo.CAN{i}.postInterrupt = 1; targetPjtGenInfo.CAN{i}.interruptLine = str2num(get_param (CANblocks{i},'InterruptLine')); %#ok<*ST2NM> if strcmpi( get_param (CANblocks{i}, 'masktype'),'C28x eCAN Receive') targetPjtGenInfo.CAN{i}.direction = 'Rx'; end if strcmpi( get_param (CANblocks{i}, 'masktype'),'C28x eCAN Transmit') targetPjtGenInfo.CAN{i}.direction = 'Tx'; targetPjtGenInfo.CAN{i}.blockMode = get_param (CANblocks{i},'enableBlockingMode'); end else targetPjtGenInfo.CAN{i}.postInterrupt = 0; end targetPjtGenInfo.CAN{i}.mailboxNo = mboxNo; targetPjtGenInfo.CAN{i}.useModule = useModule; % Calculate numbers of Rx and Tx blocks per module. if strcmp(useModule, 'eCAN_A') numCAN_As = numCAN_As + 1; % Calculate numbers of Rx blocks when useModule == 'eCAN_A' else %% useModule == 'eCAN_B' numCAN_Bs = numCAN_Bs + 1; % Calculate numbers of Rx blocks when useModule == 'eCAN_B' end end end else targetPjtGenInfo.numCANs = 0; end % Calculate numbers of Module if numCAN_As > 0 numCANModule = numCANModule + 1; CANModule{numCANModule} = 'A'; end if numCAN_Bs > 0 numCANModule = numCANModule + 1; CANModule{numCANModule} = 'B'; end if strcmpi('281x',linkPjtGenInfo.sysinfo.tgtPrefs.chipInfo.subFamily) targetPjtGenInfo.eCANMode = targetPjtGenInfo.sysinfo.peripherals.DSPBoardDSPChipeCANEnhancedCANMode; else targetPjtGenInfo.eCAN_AMode = targetPjtGenInfo.sysinfo.peripherals.DSPBoardDSPChipeCAN_AEnhancedCANMode; end if numCAN_Bs > 0 targetPjtGenInfo.eCAN_BMode = targetPjtGenInfo.sysinfo.peripherals.DSPBoardDSPChipeCAN_BEnhancedCANMode; end targetPjtGenInfo.eCAN.numCANModule = numCANModule; targetPjtGenInfo.eCAN.CANModule = CANModule; otherwise targetPjtGenInfo.numCANs = 0; end %% ------------------------------------------------------------------------ function [linkPjtGenInfo, schedPjtGenInfo, targetPjtGenInfo] = processCAPblocks (linkPjtGenInfo, schedPjtGenInfo, targetPjtGenInfo) %#ok<DEFNU> %CAPBLOCKS Get C2x CAP block info. CAPblocks = linkfoundation.util.FindSystem(linkPjtGenInfo.modelName,targetPjtGenInfo.sysinfo.CAPblocktypes{1}); switch linkPjtGenInfo.sysinfo.tgtPrefs.chipInfo.subFamily case '281x' if (~isempty(CAPblocks)), targetPjtGenInfo.numCAPs = length (CAPblocks); for i=1:length (CAPblocks), targetPjtGenInfo.CAP{i}.useModule = get_param (CAPblocks{i},'useModule'); if (targetPjtGenInfo.CAP{i}.useModule == 'A'), ofs = 0; else ofs = 3; end for j=1:3 targetPjtGenInfo.CAP{i}.unitStatus{j} = strcmpi(get_param (CAPblocks{i}, ['unit' num2str(j) 'Status']), 'on'); timerlabel = lower(get_param (CAPblocks{i}, ['unit' num2str(ofs+j) 'TimeBase'])); timerlabel = strrep (timerlabel, ' ', ''); targetPjtGenInfo.CAP{i}.unitTrigger{j} = ['EV' targetPjtGenInfo.CAP{i}.useModule '_' timerlabel]; end end else targetPjtGenInfo.numCAPs = 0; end case {'280x','2833x','2802x','2803x','2834x','2806x'} if (~isempty(CAPblocks)), targetPjtGenInfo.numCAPs = length (CAPblocks); format long; for i=1:length (CAPblocks), resetEvTs = []; evPolarity = []; selectCAPx = get_param(CAPblocks{i}, 'selectCAPx'); stopValue = get_param(CAPblocks{i}, 'stopValue'); waveformPeriod = cast(etargets.Utilities.getEvalParam(CAPblocks{i}, 'waveformPeriod'),'double'); dutyCycle = cast(etargets.Utilities.getEvalParam(CAPblocks{i}, 'dutyCycle'),'double'); if strcmp(get_param(CAPblocks{i}, 'operatingMode'), 'APWM'), if ~strcmp(get_param(CAPblocks{i}, 'periodSource'), 'Input port'), if strcmp(get_param(CAPblocks{i}, 'periodUnit'), 'Seconds'), waveformPeriod = waveformPeriod * linkPjtGenInfo.cpuClkRate; end end end if strcmp(get_param(CAPblocks{i}, 'dutyUnit'), 'Percentages'), dutyCycle = waveformPeriod * dutyCycle * 0.01; end CAPx = str2num(selectCAPx(end)); if (waveformPeriod > 4294967295) linkPjtGenInfo.error = 1; DAStudio.error('TARGETSHARED:codegen:C2000IRInfoECAPWaveformPeriodCheck',... sprintf('%3.7f',4294967295/linkPjtGenInfo.cpuClkRate)); end numStopValue = str2num(stopValue(end)); for j=1:numStopValue resetEvTs = [resetEvTs strcmp(get_param(CAPblocks{i}, ['resetEv',num2str(j),'Ts']), 'on')]; %#ok<AGROW> evPolarity = [evPolarity strcmp(get_param(CAPblocks{i}, ['ev',num2str(j),'Polarity']), 'Falling Edge')]; %#ok<AGROW> end targetPjtGenInfo.CAP{i}.operatingMode = get_param(CAPblocks{i}, 'operatingMode'); targetPjtGenInfo.CAP{i}.CAPModule = num2str(CAPx); targetPjtGenInfo.CAP{i}.offsetValue = cast(etargets.Utilities.getEvalParam(CAPblocks{i}, 'offsetValue'),'uint32'); targetPjtGenInfo.CAP{i}.counterSynIn = strcmp(get_param(CAPblocks{i}, 'counterSynIn'), 'on'); targetPjtGenInfo.CAP{i}.syncOutput = get_param(CAPblocks{i}, 'syncOutput'); targetPjtGenInfo.CAP{i}.eventPrescaler = cast(etargets.Utilities.getEvalParam(CAPblocks{i}, 'eventPrescaler'),'uint16'); targetPjtGenInfo.CAP{i}.numStopValue = numStopValue; targetPjtGenInfo.CAP{i}.resetEvTs = resetEvTs; targetPjtGenInfo.CAP{i}.evPolarity = evPolarity; targetPjtGenInfo.CAP{i}.selectMode = strcmp(get_param(CAPblocks{i}, 'selectMode'), 'One-Shot'); targetPjtGenInfo.CAP{i}.periodSource = get_param(CAPblocks{i}, 'periodSource'); targetPjtGenInfo.CAP{i}.waveformPeriod = cast(waveformPeriod, 'uint32'); targetPjtGenInfo.CAP{i}.dutySource = get_param(CAPblocks{i}, 'dutySource'); targetPjtGenInfo.CAP{i}.dutyCycle = cast(dutyCycle, 'uint32'); targetPjtGenInfo.CAP{i}.outputPolarity = get_param(CAPblocks{i}, 'outputPolarity'); targetPjtGenInfo.CAP{i}.enableCEVT1Int = strcmp(get_param(CAPblocks{i}, 'enableCEVT1Int'), 'on'); targetPjtGenInfo.CAP{i}.enableCEVT2Int = strcmp(get_param(CAPblocks{i}, 'enableCEVT2Int'), 'on'); targetPjtGenInfo.CAP{i}.enableCEVT3Int = strcmp(get_param(CAPblocks{i}, 'enableCEVT3Int'), 'on'); targetPjtGenInfo.CAP{i}.enableCEVT4Int = strcmp(get_param(CAPblocks{i}, 'enableCEVT4Int'), 'on'); targetPjtGenInfo.CAP{i}.enableCTROVFInt = strcmp(get_param(CAPblocks{i}, 'enableCTROVFInt'), 'on'); targetPjtGenInfo.CAP{i}.enablePRDInt = strcmp(get_param(CAPblocks{i}, 'enablePRDInt'), 'on'); targetPjtGenInfo.CAP{i}.enableCMPInt = strcmp(get_param(CAPblocks{i}, 'enableCMPInt'), 'on'); end format short; else targetPjtGenInfo.numCAPs = 0; end otherwise targetPjtGenInfo.numCAPs = 0; end %% ------------------------------------------------------------------------ function [linkPjtGenInfo, schedPjtGenInfo, targetPjtGenInfo] = processIQmathblocks (linkPjtGenInfo, schedPjtGenInfo, targetPjtGenInfo) %#ok<DEFNU> %IQMATHBLOCKS Get C2x IQ MATH block info. IQmathblocks = find_system(linkPjtGenInfo.modelName,'FollowLinks','on','LookUnderMasks','on','Regexp','on',... 'ReferenceBlock','^tiiqmathlib'); DMCblocks = find_system(linkPjtGenInfo.modelName,'FollowLinks','on','LookUnderMasks','on','Regexp','on',... 'ReferenceBlock','^c28xdmclib'); IQlibblocks = [IQmathblocks; DMCblocks]; % process all IQmath library dependent blocks targetPjtGenInfo.numIQmaths = length(IQlibblocks); %% ------------------------------------------------------------------------ function [linkPjtGenInfo, schedPjtGenInfo, targetPjtGenInfo] = processPWMblocks (linkPjtGenInfo, schedPjtGenInfo, targetPjtGenInfo) %#ok<DEFNU> %PWMBLOCKS Get C2x PWM block info. targetPjtGenInfo.PWMblock16HRPWMmode = 0; % 16 HRPWMs index, C2808 mode = 0, C28044 mode = 1 switch linkPjtGenInfo.sysinfo.tgtPrefs.chipInfo.subFamily case '281x' PWMblocks = linkfoundation.util.FindSystem(linkPjtGenInfo.modelName,targetPjtGenInfo.sysinfo.PWMblocktypes{1}); % process all PWM blocks if (~isempty(PWMblocks)), targetPjtGenInfo.numPWMs = length (PWMblocks); for i=1:length (PWMblocks), targetPjtGenInfo.PWM{i}.useModule = get_param (PWMblocks{i},'useModule'); if (targetPjtGenInfo.PWM{i}.useModule == 'A'), targetPjtGenInfo.PWM{i}.useTimer = 'EVA_timer1'; end if (targetPjtGenInfo.PWM{i}.useModule == 'B'), targetPjtGenInfo.PWM{i}.useTimer = 'EVB_timer3'; end targetPjtGenInfo.PWM{i}.adcstartEvent = get_param (PWMblocks{i},'adcstartEvent'); for j=1:3 targetPjtGenInfo.PWM{i}.unitStatus{j} = strcmpi(get_param (PWMblocks{i}, ['unit' num2str(j) 'Status']), 'on'); end end else targetPjtGenInfo.numPWMs = 0; end case {'280x','2833x','2804x','2802x','2803x','2806x','2834x'} C28044Mode = 0; C2808Mode = 0; PWMblocks = linkfoundation.util.FindSystem(linkPjtGenInfo.modelName,targetPjtGenInfo.sysinfo.PWMblocktypes{1}); % process all PWM blocks if (~isempty(PWMblocks)), targetPjtGenInfo.numPWMs = length (PWMblocks); for i=1:length (PWMblocks), if ~isequal(linkPjtGenInfo.sysinfo.tgtPrefs.chipInfo.subFamily,'2802x') && ~isequal(linkPjtGenInfo.sysinfo.tgtPrefs.chipInfo.subFamily,'2803x') && ... ~isequal(linkPjtGenInfo.sysinfo.tgtPrefs.chipInfo.subFamily,'2806x') targetPjtGenInfo.PWM{i}.checkMode = get_param (PWMblocks{i},'checkMode'); end targetPjtGenInfo.PWM{i}.useModule = get_param (PWMblocks{i},'useModule'); targetPjtGenInfo.PWM{i}.synchronizationOption = get_param (PWMblocks{i},'synchronizationOption'); % Check SYNCI/SYNCO/TZ5/TZ6 pin assignment targetPjtGenInfo.PWM{i}.tzselOSHT1 = get_param (PWMblocks{i},'tzselOSHT1'); targetPjtGenInfo.PWM{i}.tzselOSHT2 = get_param (PWMblocks{i},'tzselOSHT2'); targetPjtGenInfo.PWM{i}.tzselOSHT3 = get_param (PWMblocks{i},'tzselOSHT3'); targetPjtGenInfo.PWM{i}.tzselOSHT4 = get_param (PWMblocks{i},'tzselOSHT4'); targetPjtGenInfo.PWM{i}.tzselOSHT5 = get_param (PWMblocks{i},'tzselOSHT5'); targetPjtGenInfo.PWM{i}.tzselOSHT6 = get_param (PWMblocks{i},'tzselOSHT6'); targetPjtGenInfo.PWM{i}.tzselCBC1 = get_param (PWMblocks{i},'tzselCBC1'); targetPjtGenInfo.PWM{i}.tzselCBC2 = get_param (PWMblocks{i},'tzselCBC2'); targetPjtGenInfo.PWM{i}.tzselCBC3 = get_param (PWMblocks{i},'tzselCBC3'); targetPjtGenInfo.PWM{i}.tzselCBC4 = get_param (PWMblocks{i},'tzselCBC4'); targetPjtGenInfo.PWM{i}.tzselCBC5 = get_param (PWMblocks{i},'tzselCBC5'); targetPjtGenInfo.PWM{i}.tzselCBC6 = get_param (PWMblocks{i},'tzselCBC6'); targetPjtGenInfo.PWM{i}.ePWMxAStatus = get_param (PWMblocks{i},'ePWMxAStatus'); targetPjtGenInfo.PWM{i}.ePWMxBStatus = get_param (PWMblocks{i},'ePWMxBStatus'); targetPjtGenInfo.PWM{i}.tripzonesource = get_param (PWMblocks{i},'tripzonesource'); targetPjtGenInfo.PWM{i}.tzselOSHT_CBC1 = strcmp(get_param (PWMblocks{i},'tzselOSHT1'),'on') + strcmp(get_param (PWMblocks{i},'tzselCBC1'),'on'); targetPjtGenInfo.PWM{i}.tzselOSHT_CBC2 = strcmp(get_param (PWMblocks{i},'tzselOSHT2'),'on') + strcmp(get_param (PWMblocks{i},'tzselCBC2'),'on'); targetPjtGenInfo.PWM{i}.tzselOSHT_CBC3 = strcmp(get_param (PWMblocks{i},'tzselOSHT3'),'on') + strcmp(get_param (PWMblocks{i},'tzselCBC3'),'on'); targetPjtGenInfo.PWM{i}.tzselOSHT_CBC4 = strcmp(get_param (PWMblocks{i},'tzselOSHT4'),'on') + strcmp(get_param (PWMblocks{i},'tzselCBC4'),'on'); targetPjtGenInfo.PWM{i}.tzselOSHT_CBC5 = strcmp(get_param (PWMblocks{i},'tzselOSHT5'),'on') + strcmp(get_param (PWMblocks{i},'tzselCBC5'),'on'); targetPjtGenInfo.PWM{i}.tzselOSHT_CBC6 = strcmp(get_param (PWMblocks{i},'tzselOSHT6'),'on') + strcmp(get_param (PWMblocks{i},'tzselCBC6'),'on'); targetPjtGenInfo.PWM{i}.enHRPWM = get_param(PWMblocks{i}, 'enHRPWM'); targetPjtGenInfo.PWM{i}.enSFO = get_param(PWMblocks{i}, 'enSFO'); targetPjtGenInfo.PWM{i}.enableDBePWMxA = get_param (PWMblocks{i},'enableDBePWMxA'); targetPjtGenInfo.PWM{i}.enableDBePWMxB = get_param (PWMblocks{i},'enableDBePWMxB'); UserModule = targetPjtGenInfo.PWM{i}.useModule; if ~isequal(linkPjtGenInfo.sysinfo.tgtPrefs.chipInfo.subFamily,'2802x') && ~isequal(linkPjtGenInfo.sysinfo.tgtPrefs.chipInfo.subFamily,'2803x') && ... ~isequal(linkPjtGenInfo.sysinfo.tgtPrefs.chipInfo.subFamily,'2806x') if strcmp(targetPjtGenInfo.PWM{i}.checkMode,'on') C28044Mode = C28044Mode + 1; else C2808Mode = C2808Mode + 1; end end targetPjtGenInfo.PWM{i}.enHRPeriod ='off'; %% make a fake value if isequal(targetPjtGenInfo.sysinfo.PWMblocktypes{1},'C2802x/03x/05x/06x/M3x/37x/07x ePWM') targetPjtGenInfo.PWM{i}.enDCEvent = ~isequal(get_param (PWMblocks{i},'gendcaevt1'),'Event disabled') ||... ~isequal(get_param (PWMblocks{i},'gendcaevt2'),'Event disabled') || ~isequal(get_param (PWMblocks{i},'gendcbevt1'),'Event disabled') ||... ~isequal(get_param (PWMblocks{i},'gendcbevt2'),'Event disabled'); targetPjtGenInfo.PWM{i}.enHRPeriod = get_param(PWMblocks{i}, 'hrpe'); targetPjtGenInfo.PWM{i}.enAutoConve = get_param(PWMblocks{i}, 'enautoconv'); targetPjtGenInfo.PWM{i}.tzselEVENTTZ1 = isequal(get_param (PWMblocks{i},'dcah'),'Trip Zone 1 input(TZ1)') || isequal(get_param (PWMblocks{i},'dcal'),'Trip Zone 1 input(TZ1)') ||... isequal(get_param (PWMblocks{i},'dcbh'),'Trip Zone 1 input(TZ1)') || isequal(get_param (PWMblocks{i},'dcbl'),'Trip Zone 1 input(TZ1)'); targetPjtGenInfo.PWM{i}.tzselEVENTTZ2 = isequal(get_param (PWMblocks{i},'dcah'),'Trip Zone 2 input(TZ2)') || isequal(get_param (PWMblocks{i},'dcal'),'Trip Zone 2 input(TZ2)') ||... isequal(get_param (PWMblocks{i},'dcbh'),'Trip Zone 2 input(TZ2)') || isequal(get_param (PWMblocks{i},'dcbl'),'Trip Zone 2 input(TZ2)'); targetPjtGenInfo.PWM{i}.tzselEVENTTZ3 = isequal(get_param (PWMblocks{i},'dcah'),'Trip Zone 3 input(TZ3)') || isequal(get_param (PWMblocks{i},'dcal'),'Trip Zone 3 input(TZ3)') ||... isequal(get_param (PWMblocks{i},'dcbh'),'Trip Zone 3 input(TZ3)') || isequal(get_param (PWMblocks{i},'dcbl'),'Trip Zone 3 input(TZ3)'); else if str2num(UserModule(regexp(UserModule,'[0-9]'))) > 4 if strcmp(targetPjtGenInfo.PWM{i}.enHRPWM,'on') if ~(strcmp(linkPjtGenInfo.DSPchipLabel,'f2809') ... || strcmp(linkPjtGenInfo.DSPchipLabel,'f28044') ... || strcmp(linkPjtGenInfo.DSPchipLabel,'f28234') ... || strcmp(linkPjtGenInfo.DSPchipLabel,'f28235') ... || strcmp(linkPjtGenInfo.DSPchipLabel,'f28334') ... || strcmp(linkPjtGenInfo.DSPchipLabel,'f28335') ... || strcmp(linkPjtGenInfo.DSPchipLabel(1:5),'c2834')) linkPjtGenInfo.error = 1; DAStudio.error('TARGETSHARED:codegen:C2000IRInfoHRPWMModuleCheck', linkPjtGenInfo.DSPchipLabel); end end end end if strcmp(get_param (PWMblocks{i},'periodUnits'), 'Seconds'), if str2num(get_param (PWMblocks{i},'timerPeriod_sec'))*linkPjtGenInfo.cpuClkRate/str2num(get_param(PWMblocks{i},'clockPrescale'))/str2num(get_param(PWMblocks{i},'HSclockPrescale')) > 65535, linkPjtGenInfo.error = 1; DAStudio.error('TARGETSHARED:codegen:C2000IRInfoHRPWMTimerPeriodCheck',... sprintf('%2.7f',65535*str2num(get_param(PWMblocks{i},'clockPrescale'))*str2num(get_param(PWMblocks{i},'HSclockPrescale'))/linkPjtGenInfo.cpuClkRate)); end end end % PWMblock16HRPWMmode = 0 as C2808x/C28x3x ePWM mode, PWMblock16HRPWMmode = 1 as C28044 16 HRPWMs mode, if (C28044Mode == length (PWMblocks)) targetPjtGenInfo.PWMblock16HRPWMmode = 1; % all ePWMs enable 16 HRPWM mode - C28044 mode elseif (C2808Mode == length (PWMblocks)) targetPjtGenInfo.PWMblock16HRPWMmode = 0; % all ePWMs disable 16 HRPWM mode - C2808 mode end else targetPjtGenInfo.numPWMs = 0; end otherwise targetPjtGenInfo.numPWMs = 0; end %% ------------------------------------------------------------------------ function [linkPjtGenInfo, schedPjtGenInfo, targetPjtGenInfo] = processQEPblocks (linkPjtGenInfo, schedPjtGenInfo, targetPjtGenInfo) %#ok<DEFNU> %QEPBLOCKS Get C2x QEP block info. QEPblocks = linkfoundation.util.FindSystem(linkPjtGenInfo.modelName,targetPjtGenInfo.sysinfo.QEPblocktypes{1}); %process all QEP blocks switch linkPjtGenInfo.sysinfo.tgtPrefs.chipInfo.subFamily case '281x' if (~isempty(QEPblocks)), targetPjtGenInfo.numQEPs = length (QEPblocks); for i=1:length (QEPblocks), targetPjtGenInfo.QEP{i}.useModule = get_param (QEPblocks{i},'useModule'); if (targetPjtGenInfo.QEP{i}.useModule == 'A'), targetPjtGenInfo.QEP{i}.useTimer = 'EVA_timer2'; end if (targetPjtGenInfo.QEP{i}.useModule == 'B'), targetPjtGenInfo.QEP{i}.useTimer = 'EVB_timer4'; end end else targetPjtGenInfo.numQEPs = 0; end case {'280x','2833x','2803x','2806x','2834x'} if (~isempty(QEPblocks)), targetPjtGenInfo.numQEPs = length (QEPblocks); for i=1:length (QEPblocks), targetPjtGenInfo.QEP{i}.useModule = get_param (QEPblocks{i},'useModule'); if strcmp(targetPjtGenInfo.QEP{i}.useModule,'eQEP1'), targetPjtGenInfo.QEP{i}.useTimer = 'ePWM1'; end if strcmp(targetPjtGenInfo.QEP{i}.useModule,'eQEP2'), targetPjtGenInfo.QEP{i}.useTimer = 'ePWM2'; end targetPjtGenInfo.QEP{i}.INDEXPINCHECK = get_param (QEPblocks{i},'indexInitializationcheck'); targetPjtGenInfo.QEP{i}.STROBEPINCHECK = get_param (QEPblocks{i},'strobeInitializationcheck'); targetPjtGenInfo.QEP{i}.ENABLECAPTURE = get_param (QEPblocks{i},'enableEqepcapture'); targetPjtGenInfo.QEP{i}.SYNCOPINCHECK = get_param (QEPblocks{i},'spselPolarityselection'); end else targetPjtGenInfo.numQEPs = 0; end otherwise targetPjtGenInfo.numQEPs = 0; end %% ------------------------------------------------------------------------ function [linkPjtGenInfo, schedPjtGenInfo, targetPjtGenInfo] = processSCIblocks (linkPjtGenInfo, schedPjtGenInfo, targetPjtGenInfo) %#ok<DEFNU> %SCIBLOCKS Get C2x SCI block info. Rx = 1; Tx = 2; RxSCIblocks = linkfoundation.util.FindSystem(linkPjtGenInfo.modelName,targetPjtGenInfo.sysinfo.SCIblocktypes{Rx}); TxSCIblocks = linkfoundation.util.FindSystem(linkPjtGenInfo.modelName,targetPjtGenInfo.sysinfo.SCIblocktypes{Tx}); SCIblocks = []; SCIblocks(Rx).name = cellstr(RxSCIblocks); % Block name(s) of SCI Rx block(s) SCIblocks(Tx).name = cellstr(TxSCIblocks); % Block name(s) of SCI Tx block(s) SCIblocks(Rx).num = length(RxSCIblocks); % Number of SCI Rx blocks SCIblocks(Tx).num = length(TxSCIblocks); % Number of SCI Tx blocks for k = [Rx Tx] targetPjtGenInfo.SCI(k).module_A = 0; targetPjtGenInfo.SCI(k).module_B = 0; targetPjtGenInfo.SCI(k).module_C = 0; targetPjtGenInfo.SCI_PostInterrupt(k).module_A = 0; targetPjtGenInfo.SCI_PostInterrupt(k).module_B = 0; targetPjtGenInfo.SCI_PostInterrupt(k).module_C = 0; targetPjtGenInfo.SCI_PostInterrupt(k).fifoIntLevel_A = 0; targetPjtGenInfo.SCI_PostInterrupt(k).fifoIntLevel_B = 0; targetPjtGenInfo.SCI_PostInterrupt(k).fifoIntLevel_C = 0; if (SCIblocks(k).num ~= 0) for j = 1:1:SCIblocks(k).num if (get_param(SCIblocks(k).name{j}, 'sciModule') == 'A') if (targetPjtGenInfo.SCI(k).module_A == 0) targetPjtGenInfo.SCI(k).module_A = 1; end if(strcmp(get_param(SCIblocks(k).name{j},'postInterrupt'),'on')) targetPjtGenInfo.SCI_PostInterrupt(k).module_A = 1; targetPjtGenInfo.SCI_PostInterrupt(k).fifoIntLevel_A = get_param(SCIblocks(k).name{j},'numFifo'); end elseif (get_param(SCIblocks(k).name{j}, 'sciModule') == 'B') if (targetPjtGenInfo.SCI(k).module_B == 0) targetPjtGenInfo.SCI(k).module_B = 1; end if(strcmp(get_param(SCIblocks(k).name{j},'postInterrupt'),'on')) targetPjtGenInfo.SCI_PostInterrupt(k).module_B = 1; targetPjtGenInfo.SCI_PostInterrupt(k).fifoIntLevel_B = get_param(SCIblocks(k).name{j},'numFifo'); end elseif (get_param(SCIblocks(k).name{j}, 'sciModule') == 'C') if (targetPjtGenInfo.SCI(k).module_C == 0) targetPjtGenInfo.SCI(k).module_C = 1; end if(strcmp(get_param(SCIblocks(k).name{j},'postInterrupt'),'on')) targetPjtGenInfo.SCI_PostInterrupt(k).module_C = 1; targetPjtGenInfo.SCI_PostInterrupt(k).fifoIntLevel_C = get_param(SCIblocks(k).name{j},'numFifo'); end else linkPjtGenInfo.error = 1; DAStudio.error('TARGETSHARED:codegen:C2000IRInfoSCIUnrecognizedModule', get_param(SCIblocks(k).name{j}, 'sciModule')); return end end end % if(SCIblocks(k).num ~=0 end %for k= [Rx Tx] % process all SCI blocks targetPjtGenInfo.numSCIs = SCIblocks(Rx).num + SCIblocks(Tx).num; %% ------------------------------------------------------------------------ function [linkPjtGenInfo, schedPjtGenInfo, targetPjtGenInfo] = processLINblocks (linkPjtGenInfo, schedPjtGenInfo, targetPjtGenInfo) %#ok<DEFNU> %LINBLOCKS Get C2803x LIN block info. if ~strcmpi(linkPjtGenInfo.sysinfo.tgtPrefs.chipInfo.subFamily, '2803x') targetPjtGenInfo.numLINs = 0; else Rx = 1; Tx = 2; RxLINblocks = linkfoundation.util.FindSystem(linkPjtGenInfo.modelName,targetPjtGenInfo.sysinfo.LINblocktypes{Rx}); TxLINblocks = linkfoundation.util.FindSystem(linkPjtGenInfo.modelName,targetPjtGenInfo.sysinfo.LINblocktypes{Tx}); LINblocks = []; LINblocks(Rx).name = cellstr(RxLINblocks); % Block name(s) of LIN Rx block(s) LINblocks(Tx).name = cellstr(TxLINblocks); % Block name(s) of LIN Tx block(s) LINblocks(Rx).num = length(RxLINblocks); % Number of LIN Rx blocks LINblocks(Tx).num = length(TxLINblocks); % Number of LIN Tx blocks for k = [Rx Tx] targetPjtGenInfo.LIN(k).module_A = 0; targetPjtGenInfo.LIN_PostInterrupt(k).bufferIntLevel_A = 0; targetPjtGenInfo.LIN_SendChecksum(k).module_A = 0; targetPjtGenInfo.LIN_PhyBusErrInterrupt(k).module_A = 'Disabled'; targetPjtGenInfo.LIN_CompChecksum(k).module_A = 0; targetPjtGenInfo.LIN_BitErrInterrupt(k).module_A = 'Disabled'; targetPjtGenInfo.LIN_ChecksumErrInterrupt(k).module_A = 'Disabled'; targetPjtGenInfo.LIN_FrameErrInterrupt(k).module_A = 'Disabled'; targetPjtGenInfo.LIN_OverrunErrInterrupt(k).module_A = 'Disabled'; targetPjtGenInfo.LIN_IDParityErrInterrupt(k).module_A = 'Disabled'; targetPjtGenInfo.LIN_IDMatchInterrupt(k).module_A = 'Disabled'; targetPjtGenInfo.LIN_dataType(k).module_A = 'single'; if (LINblocks(k).num ~= 0) for j = 1:1:LINblocks(k).num if (get_param(LINblocks(k).name{j}, 'useModule') == 'A') if (targetPjtGenInfo.LIN(k).module_A == 0) targetPjtGenInfo.LIN(k).module_A = 1; end targetPjtGenInfo.LIN_PostInterrupt(k).bufferIntLevel_A = get_param(LINblocks(k).name{j},'numBufferInt'); if(k == Tx) targetPjtGenInfo.LIN_SendChecksum(k).module_A = strcmp(get_param(LINblocks(k).name{j},'sendChecksum'),'on'); targetPjtGenInfo.LIN_PhyBusErrInterrupt(k).module_A = get_param(LINblocks(k).name{j},'phyBusErrInterrupt'); targetPjtGenInfo.LIN_BitErrInterrupt(k).module_A = get_param(LINblocks(k).name{j},'bitErrInterrupt'); else targetPjtGenInfo.LIN_CompChecksum(k).module_A = strcmp(get_param(LINblocks(k).name{j},'compChecksum'),'on'); targetPjtGenInfo.LIN_ChecksumErrInterrupt(k).module_A = get_param(LINblocks(k).name{j},'checksumErrInterrupt'); targetPjtGenInfo.LIN_FrameErrInterrupt(k).module_A = get_param(LINblocks(k).name{j},'frameErrInterrupt'); targetPjtGenInfo.LIN_OverrunErrInterrupt(k).module_A = get_param(LINblocks(k).name{j},'overrunErrInterrupt'); targetPjtGenInfo.LIN_IDParityErrInterrupt(k).module_A = get_param(LINblocks(k).name{j},'IDParityErrInterrupt'); targetPjtGenInfo.LIN_IDMatchInterrupt(k).module_A = get_param(LINblocks(k).name{j},'IDMatchInterrupt'); targetPjtGenInfo.LIN_dataType(k).module_A = get_param(LINblocks(k).name{j},'dataType'); end end end end % if(LINblocks(k).num ~=0 end %for k= [Rx Tx] % process all LIN blocks targetPjtGenInfo.numLINs = LINblocks(Rx).num + LINblocks(Tx).num; end %% ------------------------------------------------------------------------ function [linkPjtGenInfo, schedPjtGenInfo, targetPjtGenInfo] = processSPIblocks (linkPjtGenInfo, schedPjtGenInfo, targetPjtGenInfo) %#ok<DEFNU> %SPIBLOCKS Get C2x SPI block info. RxSPIblocks = linkfoundation.util.FindSystem(linkPjtGenInfo.modelName,targetPjtGenInfo.sysinfo.SPIblocktypes{1}); TxSPIblocks = linkfoundation.util.FindSystem(linkPjtGenInfo.modelName,targetPjtGenInfo.sysinfo.SPIblocktypes{2}); SPIblocks = [RxSPIblocks; TxSPIblocks]; % process all SPI blocks if (~isempty(SPIblocks)), targetPjtGenInfo.SPI.numRxblocks = length(RxSPIblocks); targetPjtGenInfo.SPI.numTxblocks = length(TxSPIblocks); switch linkPjtGenInfo.sysinfo.tgtPrefs.chipInfo.subFamily case {'280x','2833x','2804x','2802x','2803x','2806x','2834x'} mode_A = targetPjtGenInfo.sysinfo.peripherals.DSPBoardDSPChipSPI_AMode; if (strcmp(linkPjtGenInfo.DSPchipLabel,'f2809') || strcmp(linkPjtGenInfo.DSPchipLabel,'f2808') || strcmp(linkPjtGenInfo.DSPchipLabel,'f2806')... || strcmp(linkPjtGenInfo.DSPchipLabel,'f2802') || strcmp(linkPjtGenInfo.DSPchipLabel,'f2801') || strcmp(linkPjtGenInfo.DSPchipLabel,'c2802')... || strcmp(linkPjtGenInfo.DSPchipLabel,'c2801') || strcmp(linkPjtGenInfo.DSPchipLabel,'f28035_cpu') || strcmp(linkPjtGenInfo.DSPchipLabel,'f28035_cla')... || isequal(linkPjtGenInfo.sysinfo.tgtPrefs.chipInfo.subFamily, '2806x')) mode_B = targetPjtGenInfo.sysinfo.peripherals.DSPBoardDSPChipSPI_BMode; end if (strcmp(linkPjtGenInfo.DSPchipLabel,'f2809') || strcmp(linkPjtGenInfo.DSPchipLabel,'f2808') || strcmp(linkPjtGenInfo.DSPchipLabel,'f2806')) mode_C = targetPjtGenInfo.sysinfo.peripherals.DSPBoardDSPChipSPI_CMode; mode_D = targetPjtGenInfo.sysinfo.peripherals.DSPBoardDSPChipSPI_DMode; end targetPjtGenInfo.SPI.Rx.A.postInterrupt = 0; targetPjtGenInfo.SPI.Rx.A.dataLength = 0; targetPjtGenInfo.SPI.Rx.B.postInterrupt = 0; targetPjtGenInfo.SPI.Rx.B.dataLength = 0; targetPjtGenInfo.SPI.Rx.C.postInterrupt = 0; targetPjtGenInfo.SPI.Rx.C.dataLength = 0; targetPjtGenInfo.SPI.Rx.D.postInterrupt = 0; targetPjtGenInfo.SPI.Rx.D.dataLength = 0; targetPjtGenInfo.SPI.Tx.A.postInterrupt = 0; targetPjtGenInfo.SPI.Tx.B.postInterrupt = 0; targetPjtGenInfo.SPI.Tx.C.postInterrupt = 0; targetPjtGenInfo.SPI.Tx.D.postInterrupt = 0; targetPjtGenInfo.SPI.EnableThreeWire_A = 'off'; targetPjtGenInfo.SPI.EnableThreeWire_B = 'off'; %% [SPI_A_EnableThreeWire SPI_B_EnableThreeWire] if isequal(linkPjtGenInfo.sysinfo.tgtPrefs.chipInfo.subFamily,'2802x') targetPjtGenInfo.SPI.EnableThreeWire_A = targetPjtGenInfo.sysinfo.peripherals.DSPBoardDSPChipSPI_AEnableThreeWire; end if (isequal(linkPjtGenInfo.sysinfo.tgtPrefs.chipInfo.subFamily,'2803x') || isequal(linkPjtGenInfo.sysinfo.tgtPrefs.chipInfo.subFamily,'2806x')) targetPjtGenInfo.SPI.EnableThreeWire_A = targetPjtGenInfo.sysinfo.peripherals.DSPBoardDSPChipSPI_AEnableThreeWire; targetPjtGenInfo.SPI.EnableThreeWire_B = targetPjtGenInfo.sysinfo.peripherals.DSPBoardDSPChipSPI_BEnableThreeWire; end numSPIAs=[0 0]; %% [Rx Tx] numSPIBs=[0 0]; %% [Rx Tx] numSPICs=[0 0]; %% [Rx Tx] numSPIDs=[0 0]; %% [Rx Tx] numSPIModule= 0; SPIModule={}; % Calculate numbers of blocks per module. for i=1:length(RxSPIblocks) enableRxInt = strcmp(get_param (RxSPIblocks{i},'enableRxInt'), 'on'); dataLength = str2num(get_param (RxSPIblocks{i},'dataLength')); switch (get_param (RxSPIblocks{i},'selectModule')) case 'SPI_A' numSPIAs(1) = numSPIAs(1) + 1; targetPjtGenInfo.SPI.Rx.A.postInterrupt = enableRxInt; targetPjtGenInfo.SPI.Rx.A.dataLength = dataLength; case 'SPI_B' numSPIBs(1) = numSPIBs(1) + 1; targetPjtGenInfo.SPI.Rx.B.postInterrupt = enableRxInt; targetPjtGenInfo.SPI.Rx.B.dataLength = dataLength; case 'SPI_C' numSPICs(1) = numSPICs(1) + 1; targetPjtGenInfo.SPI.Rx.C.postInterrupt = enableRxInt; targetPjtGenInfo.SPI.Rx.C.dataLength = dataLength; case 'SPI_D' numSPIDs(1) = numSPIDs(1) + 1; targetPjtGenInfo.SPI.Rx.D.postInterrupt = enableRxInt; targetPjtGenInfo.SPI.Rx.D.dataLength = dataLength; end end for i=1:length(TxSPIblocks) enableTxInt = strcmp(get_param (TxSPIblocks{i},'enableTxInt'), 'on'); switch (get_param (TxSPIblocks{i},'selectModule')) case 'SPI_A' numSPIAs(2) = numSPIAs(2) + 1; targetPjtGenInfo.SPI.Tx.A.postInterrupt = enableTxInt; case 'SPI_B' numSPIBs(2) = numSPIBs(2) + 1; targetPjtGenInfo.SPI.Tx.B.postInterrupt = enableTxInt; case 'SPI_C' numSPICs(2) = numSPICs(2) + 1; targetPjtGenInfo.SPI.Tx.C.postInterrupt = enableTxInt; case 'SPI_D' numSPIDs(2) = numSPIDs(2) + 1; targetPjtGenInfo.SPI.Tx.D.postInterrupt = enableTxInt; end end if strcmp(mode_A, 'Slave') numSPIAs = fliplr(numSPIAs); end if(sum(numSPIAs) > 0) numSPIModule = numSPIModule +1; SPIModule{numSPIModule} = 'A'; end if (strcmp(linkPjtGenInfo.DSPchipLabel,'f2809') || strcmp(linkPjtGenInfo.DSPchipLabel,'f2808') || strcmp(linkPjtGenInfo.DSPchipLabel,'f2806')... || strcmp(linkPjtGenInfo.DSPchipLabel,'f2802') || strcmp(linkPjtGenInfo.DSPchipLabel,'f2801') || strcmp(linkPjtGenInfo.DSPchipLabel,'c2802')... || strcmp(linkPjtGenInfo.DSPchipLabel,'c2801') || strcmp(linkPjtGenInfo.DSPchipLabel,'f28035_cpu') || strcmp(linkPjtGenInfo.DSPchipLabel,'f28035_cla')... || isequal(linkPjtGenInfo.sysinfo.tgtPrefs.chipInfo.subFamily, '2806x')) if strcmp(mode_B, 'Slave') numSPIBs = fliplr(numSPIBs); end if(sum(numSPIBs) > 0) numSPIModule = numSPIModule +1; SPIModule{numSPIModule} = 'B'; end end if strcmp(linkPjtGenInfo.DSPchipLabel,'f2809') || strcmp(linkPjtGenInfo.DSPchipLabel,'f2808') || strcmp(linkPjtGenInfo.DSPchipLabel,'f2806') if strcmp(mode_C, 'Slave') numSPICs = fliplr(numSPICs); end if strcmp(mode_D, 'Slave') numSPIDs = fliplr(numSPIDs); end if(sum(numSPICs) > 0) numSPIModule = numSPIModule +1; SPIModule{numSPIModule} = 'C'; end if(sum(numSPIDs) > 0) numSPIModule = numSPIModule +1; SPIModule{numSPIModule} = 'D'; end end if strcmpi(linkPjtGenInfo.DSPchipLabel(1:5),'C2834') if(sum(numSPIDs) > 0) numSPIModule = numSPIModule +1; SPIModule{numSPIModule} = 'D'; end end targetPjtGenInfo.SPI.numSPIModule = numSPIModule; targetPjtGenInfo.SPI.SPIModule = SPIModule; targetPjtGenInfo.SPI.SPIRxTxblocks = [numSPIAs numSPIBs numSPICs numSPIDs]; case '281x' targetPjtGenInfo.SPI.enLoopback = targetPjtGenInfo.sysinfo.peripherals.DSPBoardDSPChipSPIEnableLoopback; targetPjtGenInfo.SPI.Rx.postInterrupt = 0; targetPjtGenInfo.SPI.Rx.dataLength = 0; targetPjtGenInfo.SPI.Tx.postInterrupt = 0; targetPjtGenInfo.SPI.numRxblocks = length (RxSPIblocks); if (~isempty(RxSPIblocks)) for i=1:length (RxSPIblocks), targetPjtGenInfo.SPI.Rx(i).postInterrupt = strcmpi(get_param(RxSPIblocks{i},'enableRxInt'),'on'); targetPjtGenInfo.SPI.Rx(i).dataLength = str2num(get_param(RxSPIblocks{i},'dataLength')); end end if (~isempty(TxSPIblocks)) for i=1:length (TxSPIblocks), targetPjtGenInfo.SPI.Tx(i).postInterrupt = strcmpi(get_param(TxSPIblocks{i},'enableTxInt'),'on'); end end otherwise, end targetPjtGenInfo.numSPIs = length(SPIblocks); else targetPjtGenInfo.numSPIs = 0; end %% ------------------------------------------------------------------------ function [linkPjtGenInfo, schedPjtGenInfo, targetPjtGenInfo] = processI2Cblocks (linkPjtGenInfo, schedPjtGenInfo, targetPjtGenInfo) %#ok<DEFNU> %I2CBLOCKS Get C2x I2C block info. RxI2Cblocks = 0; TxI2Cblocks = 0; try RxI2Cblocks = linkfoundation.util.FindSystem(linkPjtGenInfo.modelName,targetPjtGenInfo.sysinfo.I2Cblocktypes{1}); TxI2Cblocks = linkfoundation.util.FindSystem(linkPjtGenInfo.modelName,targetPjtGenInfo.sysinfo.I2Cblocktypes{2}); I2Cblocks = [RxI2Cblocks; TxI2Cblocks]; catch I2Cblocks = []; end % process all I2C blocks if (~isempty(I2Cblocks)) switch linkPjtGenInfo.sysinfo.tgtPrefs.chipInfo.subFamily case {'280x','2833x','2804x','2802x','2803x','2806x','2834x'} targetPjtGenInfo.numI2Cs = length (I2Cblocks); targetPjtGenInfo.numI2Cs_Rx = length (RxI2Cblocks); targetPjtGenInfo.numI2Cs_Tx = length (TxI2Cblocks); end else targetPjtGenInfo.numI2Cs = 0; targetPjtGenInfo.numI2Cs_Rx = 0; targetPjtGenInfo.numI2Cs_Tx = 0; end %% ------------------------------------------------------------------------ function [linkPjtGenInfo, schedPjtGenInfo, targetPjtGenInfo] = processWATCHDOGblocks(linkPjtGenInfo, schedPjtGenInfo, targetPjtGenInfo) %#ok<DEFNU> %I2CBLOCKS Get C2x I2C block info. try Watchdogblocks = linkfoundation.util.FindSystem(linkPjtGenInfo.modelName,targetPjtGenInfo.sysinfo.WATCHDOGblocktypes{1}); catch %#ok<*CTCH> Watchdogblocks = []; end % process all Watchdog blocks if (~isempty(Watchdogblocks)) if strcmp(targetPjtGenInfo.sysinfo.peripherals.DSPBoardDSPChipWatchdogEnable_watchdog,'off') msg = DAStudio.message('TARGETSHARED:codegen:WatchdogEnableCheck'); warndlg(msg); end end %% ------------------------------------------------------------------------ function [linkPjtGenInfo, schedPjtGenInfo, targetPjtGenInfo] = validatePjtGenResources(linkPjtGenInfo, schedPjtGenInfo, targetPjtGenInfo) %% ------------------------------------------------------------------------ function [linkPjtGenInfo, schedPjtGenInfo, targetPjtGenInfo] = processDMAblocks(linkPjtGenInfo, schedPjtGenInfo, targetPjtGenInfo) %#ok<DEFNU> if isequal(linkPjtGenInfo.sysinfo.tgtPrefs.chipInfo.subFamily,'2833x') || isequal(linkPjtGenInfo.sysinfo.tgtPrefs.chipInfo.subFamily, '2834x') ||... isequal(linkPjtGenInfo.sysinfo.tgtPrefs.chipInfo.subFamily, '2806x') %DMA info. enable_idx = 0; num_intsrc={'0','0','0','0','0','0'}; num_extch = [0,0,0,0,0,0]; % Get DMA channels information from target preferences for i=1:6 if strcmp(eval(['targetPjtGenInfo.sysinfo.peripherals.DSPBoardDSPChipDMA_ch',... num2str(i),'EnableDMAChannel']),'on') enable_idx = enable_idx + 1; targetPjtGenInfo.DMA{enable_idx}.TPDMACH = num2str(i); targetPjtGenInfo.DMA{enable_idx}.EnableDMAChannel = eval(... ['targetPjtGenInfo.sysinfo.peripherals.DSPBoardDSPChipDMA_ch',... num2str(i),'EnableDMAChannel']); targetPjtGenInfo.DMA{enable_idx}.DataSize = eval(... ['targetPjtGenInfo.sysinfo.peripherals.DSPBoardDSPChipDMA_ch',... num2str(i),'DataSize']); targetPjtGenInfo.DMA{enable_idx}.InterruptSrc = eval(... ['targetPjtGenInfo.sysinfo.peripherals.DSPBoardDSPChipDMA_ch',... num2str(i),'InterruptSrc']); targetPjtGenInfo.DMA{enable_idx}.ExternalPin = eval(... ['targetPjtGenInfo.sysinfo.peripherals.DSPBoardDSPChipDMA_ch',... num2str(i),'ExternalPin']); targetPjtGenInfo.DMA{enable_idx}.BurstSize = eval(... ['targetPjtGenInfo.sysinfo.peripherals.DSPBoardDSPChipDMA_ch',... num2str(i),'BurstSize']); targetPjtGenInfo.DMA{enable_idx}.TransferSize = eval(... ['targetPjtGenInfo.sysinfo.peripherals.DSPBoardDSPChipDMA_ch',... num2str(i),'TransferSize']); targetPjtGenInfo.DMA{enable_idx}.WrapSrcSize = eval(... ['targetPjtGenInfo.sysinfo.peripherals.DSPBoardDSPChipDMA_ch',... num2str(i),'WrapSrcSize']); targetPjtGenInfo.DMA{enable_idx}.WrapDstSize = eval(... ['targetPjtGenInfo.sysinfo.peripherals.DSPBoardDSPChipDMA_ch',... num2str(i),'WrapDstSize']); targetPjtGenInfo.DMA{enable_idx}.SrcBeginAdd = eval(... ['targetPjtGenInfo.sysinfo.peripherals.DSPBoardDSPChipDMA_ch',... num2str(i),'SrcBeginAdd']); targetPjtGenInfo.DMA{enable_idx}.SrcBurstStep = eval(... ['targetPjtGenInfo.sysinfo.peripherals.DSPBoardDSPChipDMA_ch',... num2str(i),'SrcBurstStep']); targetPjtGenInfo.DMA{enable_idx}.SrcTransStep = eval(... ['targetPjtGenInfo.sysinfo.peripherals.DSPBoardDSPChipDMA_ch',... num2str(i),'SrcTransStep']); targetPjtGenInfo.DMA{enable_idx}.SrcWrapStep = eval(... ['targetPjtGenInfo.sysinfo.peripherals.DSPBoardDSPChipDMA_ch',... num2str(i),'SrcWrapStep']); targetPjtGenInfo.DMA{enable_idx}.DstBeginAdd = eval(... ['targetPjtGenInfo.sysinfo.peripherals.DSPBoardDSPChipDMA_ch',... num2str(i),'DstBeginAdd']); targetPjtGenInfo.DMA{enable_idx}.DstBurstStep = eval(... ['targetPjtGenInfo.sysinfo.peripherals.DSPBoardDSPChipDMA_ch',... num2str(i),'DstBurstStep']); targetPjtGenInfo.DMA{enable_idx}.DstTransStep = eval(... ['targetPjtGenInfo.sysinfo.peripherals.DSPBoardDSPChipDMA_ch',... num2str(i),'DstTransStep']); targetPjtGenInfo.DMA{enable_idx}.DstWrapStep = eval(... ['targetPjtGenInfo.sysinfo.peripherals.DSPBoardDSPChipDMA_ch',... num2str(i),'DstWrapStep']); targetPjtGenInfo.DMA{enable_idx}.GenInterrupt = eval(... ['targetPjtGenInfo.sysinfo.peripherals.DSPBoardDSPChipDMA_ch',... num2str(i),'GenInterrupt']); targetPjtGenInfo.DMA{enable_idx}.EnableOneShot = eval(... ['targetPjtGenInfo.sysinfo.peripherals.DSPBoardDSPChipDMA_ch',... num2str(i),'EnableOneShot']); targetPjtGenInfo.DMA{enable_idx}.SyncEnable = eval(... ['targetPjtGenInfo.sysinfo.peripherals.DSPBoardDSPChipDMA_ch',... num2str(i),'SyncEnable']); targetPjtGenInfo.DMA{enable_idx}.EnableContinuous = eval(... ['targetPjtGenInfo.sysinfo.peripherals.DSPBoardDSPChipDMA_ch',... num2str(i),'EnableContinuous']); targetPjtGenInfo.DMA{enable_idx}.EnableDSTSync = eval(... ['targetPjtGenInfo.sysinfo.peripherals.DSPBoardDSPChipDMA_ch',... num2str(i),'EnableDSTSync']); if i==1 targetPjtGenInfo.DMA{enable_idx}.SetCh1ToHigh = eval(... ['targetPjtGenInfo.sysinfo.peripherals.DSPBoardDSPChipDMA_ch',... num2str(i),'SetCh1ToHigh']); end targetPjtGenInfo.DMA{enable_idx}.EnableOverFlow = eval(... ['targetPjtGenInfo.sysinfo.peripherals.DSPBoardDSPChipDMA_ch',... num2str(i),'EnableOverFlow']); if strcmp('XINT',targetPjtGenInfo.DMA{enable_idx}.InterruptSrc(1:4)) num_intsrc{i} = targetPjtGenInfo.DMA{enable_idx}.InterruptSrc(5:end); num_extch(i) = str2num(targetPjtGenInfo.DMA{enable_idx}.ExternalPin); end end end % % For each of 6 DMA channels check if muti-channel used XINT % If they don't use the same GPIO pins, generate error. % if enable_idx > 0 for i = 1:6 if str2num(num_intsrc{i}) > 0 pin_same_idx = strcmp(num_intsrc{i},num_intsrc); if ((num_extch(pin_same_idx)-fliplr(num_extch(pin_same_idx))) ~= 0) linkPjtGenInfo.error = 1; DAStudio.error('TARGETSHARED:codegen:DMAXINTValidation'); end end end end targetPjtGenInfo.numDMA =enable_idx; end %% ------------------------------------------------------------------------ function checkIfFlashAccepted (targetPjtGenInfo) group = 'MathWorks_TIC2000'; item = 'TI_C2000LIB_EnableFlashSetting'; Configset = getActiveConfigSet(bdroot(gcs)); Build_action = get_param(Configset,'buildAction'); Enable_idex = targetPjtGenInfo.sysinfo.peripherals.DSPBoardDSPChipFlash_loaderEnable_Flash; if ~ispref(group, item) setpref(group,item,''); end isFlashAccepted = getpref(group, item); if strcmp(Build_action,'Build_and_execute') if ~strcmp(Enable_idex,'Disable') if ( isempty(isFlashAccepted) || (~isFlashAccepted) ) %GUI for enableFLAShsetting enableQuestion_Flash; end end end %[EOF] getIRInfo_Targets_C2000.m