source: ISPProgrammer/UISPProgrammer.pas

Last change on this file was 438, checked in by chronos, 12 years ago
  • Modified: Faster write in TPrestoProgrammer using delayed response check of sent commands.
File size: 3.3 KB
Line 
1unit UISPProgrammer;
2
3{$mode delphi}
4
5interface
6
7uses
8 Classes, SysUtils, Registry, UIntelHexFile,
9 UCPUType, UJobProgressView;
10
11type
12 TLogEvent = procedure (Text: string) of object;
13
14 TISPProgCapability = (ipcRead, ipcWrite, ipcReset, ipcErase);
15 TISPProgCapabilities = set of TISPProgCapability;
16
17 { TISPProgrammer }
18
19 TISPProgrammer = class
20 private
21 FActive: Boolean;
22 FOnActivate: TNotifyEvent;
23 FOnDeactivate: TNotifyEvent;
24 FOnLog: TLogEvent;
25 FCPUType: TCPUType;
26 protected
27 function GetCPUType: TCPUType; virtual;
28 procedure SetCPUType(AValue: TCPUType); virtual;
29 procedure SetActive(AValue: Boolean); virtual; // private
30 public
31 HexFile: TIntelHexFile;
32 FileName: string;
33 Capabilities: TISPProgCapabilities;
34 procedure Log(Text: string);
35 procedure LoadFromRegistry(Root: HKEY; Key: string); virtual;
36 procedure SaveToRegistry(Root: HKEY; Key: string); virtual;
37 procedure Write(Job: TJob); virtual;
38 procedure Read(Job: TJob); virtual;
39 procedure Verify(Job: TJob); virtual;
40 procedure Erase; virtual;
41 procedure Reset; virtual;
42 function ReadIdentification: string; virtual;
43 constructor Create; virtual;
44 destructor Destroy; override;
45 property OnLog: TLogEvent read FOnLog write FOnLog;
46 property Active: Boolean read FActive write SetActive;
47 property CPUType: TCPUType read GetCPUType write SetCPUType;
48 property OnActivate: TNotifyEvent read FOnActivate write FOnActivate;
49 property OnDeactivate: TNotifyEvent read FOnDeactivate write FOnDeactivate;
50 end;
51
52implementation
53
54resourcestring
55 SNotImplemented = 'Not implemented';
56
57{ TISPProgrammer }
58
59function TISPProgrammer.GetCPUType: TCPUType;
60begin
61 Result := FCPUType;
62end;
63
64procedure TISPProgrammer.SetCPUType(AValue: TCPUType);
65begin
66 FCPUType := AValue;
67end;
68
69procedure TISPProgrammer.SetActive(AValue: Boolean);
70begin
71 if FActive = AValue then Exit;
72 FActive := AValue;
73 if AValue then begin
74 if Assigned(FOnActivate) then
75 FOnActivate(Self);
76 end else begin
77 if Assigned(FOnDeactivate) then
78 FOnDeactivate(Self);
79 end;
80end;
81
82procedure TISPProgrammer.Log(Text: string);
83begin
84 if Assigned(FOnLog) then
85 FOnLog(Text);
86end;
87
88procedure TISPProgrammer.LoadFromRegistry(Root: HKEY; Key: string);
89begin
90
91end;
92
93procedure TISPProgrammer.SaveToRegistry(Root: HKEY; Key: string);
94begin
95
96end;
97
98procedure TISPProgrammer.Write(Job: TJob);
99begin
100 raise Exception.Create(SNotImplemented);
101end;
102
103procedure TISPProgrammer.Read(Job: TJob);
104begin
105 raise Exception.Create(SNotImplemented);
106end;
107
108procedure TISPProgrammer.Verify(Job: TJob);
109begin
110 raise Exception.Create(SNotImplemented);
111end;
112
113procedure TISPProgrammer.Erase;
114begin
115 raise Exception.Create(SNotImplemented);
116end;
117
118procedure TISPProgrammer.Reset;
119begin
120 raise Exception.Create(SNotImplemented);
121end;
122
123function TISPProgrammer.ReadIdentification: string;
124begin
125 Result := '';
126 raise Exception.Create(SNotImplemented);
127end;
128
129constructor TISPProgrammer.Create;
130begin
131 //ExtPin := TCommPin.Create;
132 HexFile := TIntelHexFile.Create;
133 HexFile.BytePerLine := 20;
134end;
135
136destructor TISPProgrammer.Destroy;
137begin
138 Active := False;
139 //FreeAndNil(ExtPin);
140 FreeAndNil(HexFile);
141 inherited Destroy;
142end;
143
144end.
145
Note: See TracBrowser for help on using the repository browser.