📄 ccsinspect.m
字号:
function varargout = ccsinspect(varargin)
% CCSINSPECT GUI Inspector of embedded C variables
% CCSINSPECT opens a window for exploring the variables
% of an embedded target loaded into Code Composer Studio(tm).
% All available variables are automatically listed. The user
% can select from this list and export a MATLAB object
% that represents the embedded entity. The resulting
% MATLAB object can be applied for direct interaction
% between MATLAB and the embedded value.
%
% See also: CCSDSP, CREATEOBJ
% $Revision: 1.7 $ $Date: 2002/05/20 17:59:48 $
% Copyright 2002 The MathWorks, Inc.
% Last Modified by GUIDE v2.5 10-Apr-2002 09:58:58
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @ccsinspect_OpeningFcn, ...
'gui_OutputFcn', @ccsinspect_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin & isstr(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
varargout{1:nargout} = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before ccsinspect is made visible.
function ccsinspect_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin unrecognized PropertyName/PropertyValue pairs from the
% command line (see VARARGIN)
% Choose default command line output for ccsinspect
handles.output = hObject;
handles.boardnum =0;
handles.procnum =0;
handles.cc = [];
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes ccsinspect wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = ccsinspect_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
% --- Executes during object creation, after setting all properties.
function VariableList_CreateFcn(hObject, eventdata, handles)
% hObject handle to VariableList (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: listbox controls usually have a white background, change
% 'usewhitebg' to 0 to use default. See ISPC and COMPUTER.
usewhitebg = 1;
if usewhitebg
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
% --- Executes on selection change in VariableList.
function VariableList_Callback(hObject, eventdata, handles)
% hObject handle to VariableList (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = get(hObject,'String') returns VariableList contents as cell array
% contents{get(hObject,'Value')} returns selected item from VariableList
%Change the Address to reflect the new value
vaddr = get(handles.VariableList,'UserData');
vindex = get(handles.VariableList,'Value');
if ~isempty(vindex),
set(handles.Address,'String',vaddr{vindex});
end
% --- Executes on button press in makeLink.
function makeLink_Callback(hObject, eventdata, handles)
% hObject handle to makeLink (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
boardnum = get(handles.BoardNumEdit,'Userdata');
procnum = get(handles.ProcNumEdit,'Userdata');
set(handles.BoardName,'String',' Standby - Loading Code Composer!');
try
cc = ccsdsp('boardnum',boardnum,'procnum',procnum);
catch
errordlg(lasterr,'Code Composer Studio (tm) Link Failure','modal');
return;
end
handles.cc = cc;
guidata(hObject, handles);
set(handles.VariableList,'enable','on');
set(handles.InspectPropButton,'enable','on');
set(handles.obj2workspace,'enable','on');
set(handles.loadProgram,'enable','on');
set(handles.ccsVisible,'enable','on');
set(handles.LinkRefresh,'enable','on');
set(handles.TargetProgramTitle,'enable','on');
set(handles.BoardNameTitle,'enable','on');
set(handles.BoardNumEdit,'enable','off');
set(handles.ProcNumEdit,'enable','off');
set(handles.boardSelectButton,'enable','off');
set(hObject,'enable','off');
if isvisible(cc),
set(handles.ccsVisible,'Value',1);
else
set(handles.ccsVisible,'Value',0);
end
% Set board name
set(handles.BoardName,'String',cc.info.boardname );
LinkRefresh_Callback(handles.LinkRefresh,0,handles);
% --- Executes on button press in LinkRefresh.
function LinkRefresh_Callback(hObject, eventdata, handles)
% hObject handle to LinkRefresh (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Enable everyone!!
cc = handles.cc;
if cc.info.subfamily >= 96, % 6x family
numNibbles = 8;
else % 5x family
numNibbles = 4;
end
% retrieve ALL variables
v = cc.list('variable-short');
vname = fieldnames(v);
vnamecell = [];
vaddr = [];
for i=1:length(vname),
vnamecell{i} = v.(vname{i}).name;
if ~strcmp( vnamecell{i}, vname{i} ),
vnamecell{i} = [ vnamecell{i} ' (' vname{i} ')' ];
end
if ischar(v.(vname{i}).location(1)),
vaddr{i} = 'Register';
else
vaddr{i} = dec2hex(v.(vname{i}).location(1),numNibbles);
end
end
% Configure list of names in listbox for variables (and preserve addresses
% in UserData)
set(handles.VariableList,'String',vnamecell,'UserData',vaddr);
if isempty(vnamecell),
set(handles.VariableList,'Value',[]);
else
set(handles.VariableList,'Value',1);
end
if ~isempty(vaddr)
set(handles.Address,'String',vaddr{1});
end
% retreive name of last file loaded
dspboards = get(actxserver('CodeComposer.Application'),'DspBoards');
pgFile = invoke(invoke(invoke(get(invoke(dspboards,'Item',cc.boardnum),'DspTasks'),'Item',cc.procnum),'CreateDspUser'),'GetFileLoaded');
clear dspboards;
if isempty(pgFile),
set(handles.fileNametext,'String','--- No file loaded ---');
else
[pd,pf,pe] = fileparts(pgFile);
set(handles.fileNametext,'String',[pf pe]);
end
% This disables the Function list (we'll start in the variable list)
% --- Push selected object to Matlab workspace
function obj2workspace_Callback(hObject, eventdata, handles)
% hObject handle to obj2workspace (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
vsel = get(handles.VariableList,'Value');
if ~isempty(vsel),
vnamecell = get(handles.VariableList,'String');
name = vnamecell{vsel};
else
warning('Nothing selected for export to workspace!');
return;
end
bracketindex = strfind( name,'(');
if ~isempty(bracketindex), % Extract valid ML name for variable
mlname = name(bracketindex+1:end-1);
ccname = name(1:bracketindex-1);
else
mlname = name;
ccname = name;
end
obj = handles.cc.createobj(ccname);
assignin('base',mlname,obj);
% --- Executes on button press in InspectPropButton.
function InspectPropButton_Callback(hObject, eventdata, handles)
% hObject handle to InspectPropButton (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
popupInspector(hObject,handles);
% --- Popup inspector
function popupInspector(hObject,handles);
vsel = get(handles.VariableList,'Value');
if ~isempty(vsel),
vnamecell = get(handles.VariableList,'String');
name = vnamecell{vsel};
else
% warning('Nothing selected for export to workspace!');
return;
end
bracketindex = strfind( name,'(');
if ~isempty(bracketindex), % Extract valid ML name for variable
mlname = name(bracketindex+1:end-1);
ccname = name(1:bracketindex-1);
else
mlname = name;
ccname = name;
end
obj = handles.cc.createobj(ccname);
handles.obj = obj;
guidata(hObject, handles);
% uiwait
% assignin('base',mlname,obj);
inspect(handles.obj);
% uiresume
% --- Executes on button press in CloseButton.
function CloseButton_Callback(hObject, eventdata, handles)
% hObject handle to CloseButton (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
close(handles.mainWindow);
% --- Executes during object creation, after setting all properties.
function BoardNumEdit_CreateFcn(hObject, eventdata, handles)
% hObject handle to BoardNumEdit (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background, change
% 'usewhitebg' to 0 to use default. See ISPC and COMPUTER.
usewhitebg = 1;
if usewhitebg
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
function BoardNumEdit_Callback(hObject, eventdata, handles)
% hObject handle to BoardNumEdit (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of BoardNumEdit as text
% str2double(get(hObject,'String')) returns contents of BoardNumEdit as a double
%set(handles.FunctionList,'enable','off');
set(handles.VariableList,'enable','off');
oldbd = handles.boardnum;
newbdstr = get(hObject,'String');
newbdnum = eval(newbdstr,oldbd);
if newbdnum < 0, newbdnum = oldbd; end
newbdnum = round(newbdnum);
set(hObject,'Userdata',newbdnum,'String',num2str(newbdnum));
% --- Executes during object creation, after setting all properties.
function edit2_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background, change
% 'usewhitebg' to 0 to use default. See ISPC and COMPUTER.
usewhitebg = 1;
if usewhitebg
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
% --- Executes during object creation, after setting all properties.
function ProcNumEdit_CreateFcn(hObject, eventdata, handles)
% hObject handle to ProcNumEdit (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background, change
% 'usewhitebg' to 0 to use default. See ISPC and COMPUTER.
usewhitebg = 1;
if usewhitebg
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
function ProcNumEdit_Callback(hObject, eventdata, handles)
% hObject handle to ProcNumEdit (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of ProcNumEdit as text
% str2double(get(hObject,'String')) returns contents of ProcNumEdit as a double
%set(handles.FunctionList,'enable','off');
set(handles.VariableList,'enable','off');
oldpr = handles.boardnum;
newprstr = get(hObject,'String');
newprnum = eval(newbdstr,oldpr);
if newprnum < 0, newbdnum = oldpr; end
newprnum = round(newprnum);
set(hObject,'Userdata',newprnum,'String',num2str(newprnum));
% --- Executes on button press in loadProgram.
function loadProgram_Callback(hObject, eventdata, handles)
% hObject handle to loadProgram (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
targetName = get(handles.BoardName,'String');
[filename, pathname] = uigetfile('*.out',['Load Program Files - ' targetName]);
if ischar(filename) & ischar(pathname),
try
handles.cc.load(fullfile(pathname, filename));
catch
errordlg('Failed during load, please select a valid program file','Program Load Failure');
return;
end
LinkRefresh_Callback(handles.LinkRefresh,0,handles);
end
% --- Executes on button press in boardSelectButton.
function boardSelectButton_Callback(hObject, eventdata, handles)
% hObject handle to boardSelectButton (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
try
[bdnum,prnum] = boardprocsel;
catch
warndlg(...
{ 'Unable to run Board Selection Utility',...
'[bdnum,prnum] = boardprocsel;',...
'Board and Processor must be entered manually',...
lasterr},'GUI Error');
end
if ~isempty(bdnum),
set(handles.BoardNumEdit,'String',int2str(bdnum));
set(handles.BoardNumEdit,'UserData',bdnum);
end
if ~isempty(prnum),
set(handles.ProcNumEdit,'String',int2str(prnum));
set(handles.ProcNumEdit,'UserData',prnum);
end
% --- Executes on button press in ccsVisible.
function ccsVisible_Callback(hObject, eventdata, handles)
% hObject handle to ccsVisible (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of ccsVisible
cc = handles.cc;
nowState = isvisible(cc);
newState = get(hObject,'Value');
if nowState ~= newState,
cc.visible(newState);
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -