Главная  Радио и связь 

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 [ 89 ] 90 91 92 93

DIn(Bt,PR);

if Bt and ACK=0 then Result:=False,• rout(PW,0); Delay(30); DIn(Bt,PR);

if Bt and ACK=ACK then Result:=False; end;

function VoltageOK:boolean; begin

Result:=True,•

{DOut(PW,Enbl); Delay(30),• DIn(Bt,PR);

if Bt and Busy=0 then Result:=False;) end;

procedure GetProgArr; Result: BWr[0..ArrSize-1] var S,sAdr,sNum,sTyp,sB :string;

J,Adr,Num,Typ,K,MaxAddr :integer;

begin

MaxAddr:=0;

PosStr:=0;

while PosStr<Size do begin S:=;

while (Char(Buf"[PosStr])<>#13) do begin

S:=S+Char(Buf"[PosStr]);

Inc(PosStr); end;

Inc(PosStr,2); #13 и ":" пропустить для перехода к след строке sNum:=$+Copy(S,2,2); Val(sNum,Num,K); число байт в строке sAdr: = $+Copy(S,4,4) ; Val (sAdr,Adr,K) ; нач.адрес строки во FLASIJ if Adr+Num>MaxAddr then MaxAddr:=Adr+Num;

sTyp:=$+Copy(S,8,2); Val(sTyp,Тур,K); sTyp = 00 для данных Delete(S,l,9); стереть в строке слева все до данных J:=l;

while (Тур=0) and (J<2*Num) do begin sB:=$+Copy(S,J,2); Val(sB,BWr"[Adr],K); Inc(Adr); Inc(J,2); end; end;

ArrSize:=MaxAddr; end; GetProgArr; result in BWr"[0..ArrSize-1]

procedure TForml.BtFileClick(Sender: TObject); var

F :file;

FStm :TStream;



I .-longword; FHandlе:integer; begin

BtPrgFlash.Capt ion: =Прогр.FLASH;

BtPrgFlash.Font.Color:=clBlack;

if not Reload then if OpenDialogl.Execute then

sF i1e:=OpenDi alogl.Fi1eName;

if FileExists(sFile) then begin

FHandle:=FileOpen(SFile,fmOpenRead);

DTFile:= от +DateToStr(FileDateToDateTime(FileGetDate(FHandle))); DTFile:-DTFile+ +TimeToStr(FileDateToDateTime(FileGetDate(FHandle) FileClose(FHandle);

FileOK:=True;

Labell.Caption:=Файл: +sFile+DTFile; Labell.Font.Color:=clBlack;

Labell.Left:=(Forml.Width-Labell.Width) div 2; AssignFile(F,SFile); Reset(F,l); Size:=FileSize(F); CloseFile(F);

FStm;=TFileStream.Create(SFile,fmOpenReadWrite);

ArrSize:=Size;

GetMem(Buf,Size);

GetMem(BWr,Size);

FStm.Read(Buf",Size);

FStm.Free;

for I:=0 to Size-1 do BWr"[I]:=$ff; GetProgArr; FreeMem(Buf,Size); end;

Reload:=false; end;

procedure TForml.BtChkClick(Sender: TObject);

var sType, sFlash:string; begin

BtPrgFlash.Capt ion: = Прогр.FLASH; BtPrgFlash.Font.Color:=clBlack; if AdapterOK then begin LCI.Caption:-ПОДКЛЮЧЕН; LCI.Font.Color:=clBlack; if VoltageOK then begin LC2.Caption:-; LC2.Font.Color:=clBlack;

RstAVR;

if ProgEnable then PrgReady:=true else PrgReady:=false;



if not PrgReady then begin

LCI.Caption:=Программатор не готов;

LCI.Font.Color:=clRED; end;

case ReadSignature of $0693: begin PageSize:=32; $0793: begin PageSize:=32; $0893: begin PageSize:=32; $0394: begin PageSize:=64; $0197: begin PageSize:=128; $0297: begin PageSize:=128;

sType:=ATMega8515; sFlash:=8K; end; sType:=ATMega8; sFlash:=8к; end; sType:=ATMega8535; sFlash:=8K; end; sType:=ATMegal6; sFlash:=16K; end; sType:=ATMegal03; sFlash:=128K; end; sType:=ATMegal28; sFlash:=128K; end;

$0590: begin PageSize:=0; sType: $0690: begin PageSize:=0; sType: $0991: begin PageSize:=0; sType:

=ATtinyl2; sFlash =ATtinyl5; sFlash =ATtiny26; sFlash

=lK; end =lK; end =2к; end

$0191: begin PageSize:=0; $0192: begin PageSize:=0; $0392: begin PageSize:=0;

begin PageSize:=0; begin PageSize:=0; begin PageSize:=0;

$0193: $0393: else end;

StatusBarl.Panels [0 StatusBarl.Panels[1 StatusBarl.Panels[2

end else begin

LC2.Caption:=ОТСУТСТВУЕТ LC2.Font.Color:=clRed;

end;

end else begin

LCI.Caption:=HE ПОДКЛЮЧЕН; LCI.Font.Color:=clRed; LC2.Caption:=;

end;

end;

sType:=AT90S2313; sFlash

sType:=AT90S4414; sFlash

sType:=AT90S4433; SFlash

sType:=AT90S8515; sFlash

sType:=AT90S8535; sFlash

=2K; end;

=4K; end;

=4K; end;

=8K; end;

=8K; end

sType:=; sFlash:=; end;

.Text:=Тип: +sType; .Text:=Flash: tsFlash; . Text: = Страница: +IntToStr(PageSize);

procedure TForml.BtRdFlashClick(Sender: TObject); var A:word;

S:string; begin

BtChk.OnClick(self); if not PrgReady then Exit; S:=El.Text; A:=StrToInt(S); A:=ProgRead(A);

E3.Text:=Format($%.2x,[Hi(A)])+Format(%.2x,[Lo(A)1);

if ChkReset.Checked then SetAVR;

end;



0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 [ 89 ] 90 91 92 93


0.0066