Skip to content

Commit

Permalink
Добавлен blankcheck и исправлен прошлый исправленный коммит =)
Browse files Browse the repository at this point in the history
  • Loading branch information
nofeletru committed Jul 8, 2017
1 parent d13d181 commit e0154c4
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 25 deletions.
34 changes: 23 additions & 11 deletions software/main.lfm
Original file line number Diff line number Diff line change
Expand Up @@ -66,21 +66,23 @@ object MainForm: TMainForm
Left = 203
Hint = 'Сравнить содержимое EEPROM'
Top = 2
DropdownMenu = BlankCheckDropDownMenu
ImageIndex = 6
OnClick = ButtonVerifyClick
ParentShowHint = False
ShowHint = True
Style = tbsDropDown
end
object ToolButton1: TToolButton
Left = 239
Left = 251
Height = 32
Top = 2
Width = 10
Caption = 'ToolButton1'
Style = tbsSeparator
end
object ButtonReadID: TToolButton
Left = 249
Left = 261
Hint = 'Прочитать индификатор EEPROM'
Top = 2
ImageIndex = 2
Expand All @@ -89,7 +91,7 @@ object MainForm: TMainForm
ShowHint = True
end
object ButtonBlock: TToolButton
Left = 285
Left = 297
Hint = 'Снять защиту'
Top = 2
DropdownMenu = DropdownMenuLock
Expand All @@ -109,7 +111,7 @@ object MainForm: TMainForm
Style = tbsSeparator
end
object RadioSPI: TRadioButton
Left = 389
Left = 401
Height = 19
Top = 2
Width = 36
Expand All @@ -120,7 +122,7 @@ object MainForm: TMainForm
TabStop = True
end
object RadioI2C: TRadioButton
Left = 425
Left = 437
Height = 19
Top = 2
Width = 37
Expand All @@ -129,7 +131,7 @@ object MainForm: TMainForm
TabOrder = 1
end
object RadioMw: TRadioButton
Left = 462
Left = 474
Height = 19
Top = 2
Width = 107
Expand All @@ -138,7 +140,7 @@ object MainForm: TMainForm
TabOrder = 2
end
object ToolButton2: TToolButton
Left = 333
Left = 345
Height = 32
Top = 2
Width = 10
Expand Down Expand Up @@ -166,7 +168,7 @@ object MainForm: TMainForm
ShowHint = True
end
object ButtonCancel: TToolButton
Left = 343
Left = 355
Hint = 'Прервать текущею операцию'
Top = 2
ImageIndex = 8
Expand All @@ -175,15 +177,15 @@ object MainForm: TMainForm
ShowHint = True
end
object ToolButton5: TToolButton
Left = 379
Left = 391
Height = 32
Top = 2
Width = 10
Caption = 'ToolButton5'
Style = tbsSeparator
end
object ToolButton4: TToolButton
Left = 569
Left = 581
Height = 32
Top = 2
Width = 10
Expand Down Expand Up @@ -373,7 +375,7 @@ object MainForm: TMainForm
object Panel_I2C_DevAddr: TPanel
Left = 448
Height = 37
Top = -6
Top = 0
Width = 336
BevelOuter = bvNone
ClientHeight = 37
Expand Down Expand Up @@ -474,6 +476,8 @@ object MainForm: TMainForm
Top = 93
Width = 802
Align = alClient
Colors.DigitTextEven = clNavy
Colors.DigitTextOdd = clNavy
DigitGrouping = 1
Font.Height = -15
Font.Name = 'Courier New'
Expand Down Expand Up @@ -1926,4 +1930,12 @@ object MainForm: TMainForm
OnClick = MenuItemEditSregClick
end
end
object BlankCheckDropDownMenu: TPopupMenu
left = 480
top = 296
object BlankCheckMenuItem: TMenuItem
Caption = 'Проверка на чистоту'
OnClick = BlankCheckMenuItemClick
end
end
end
63 changes: 49 additions & 14 deletions software/main.pas
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ TMainForm = class(TForm)
MenuAVRISP250KHz: TMenuItem;
MenuAVRISP125KHz: TMenuItem;
LangMenuItem: TMenuItem;
BlankCheckMenuItem: TMenuItem;
MenuItemHardware: TMenuItem;
MenuItemBenchmark: TMenuItem;
MenuItemEditSreg: TMenuItem;
Expand All @@ -95,6 +96,7 @@ TMainForm = class(TForm)
LogPopupMenu: TPopupMenu;
DropdownMenuLock: TPopupMenu;
Panel_I2C_DevAddr: TPanel;
BlankCheckDropDownMenu: TPopupMenu;
ProgressBar: TProgressBar;
RadioI2C: TRadioButton;
RadioMw: TRadioButton;
Expand All @@ -118,6 +120,7 @@ TMainForm = class(TForm)
ButtonCancel: TToolButton;
ToolButton4: TToolButton;
ToolButton5: TToolButton;
procedure BlankCheckMenuItemClick(Sender: TObject);
procedure ButtonEraseClick(Sender: TObject);
procedure ButtonReadClick(Sender: TObject);
procedure ClearLogMenuItemClick(Sender: TObject);
Expand Down Expand Up @@ -153,6 +156,7 @@ TMainForm = class(TForm)
procedure ButtonSaveHexClick(Sender: TObject);
procedure ButtonCancelClick(Sender: TObject);
procedure I2C_DevAddrChange(Sender: TObject);
procedure VerifyFlash(BlankCheck: boolean = false);
private
{ private declarations }
public
Expand Down Expand Up @@ -2343,9 +2347,15 @@ procedure TMainForm.ButtonWriteClick(Sender: TObject);
end;

procedure TMainForm.ButtonVerifyClick(Sender: TObject);
begin
VerifyFlash(false);
end;

procedure TMainForm.VerifyFlash(BlankCheck: boolean = false);
var
I2C_DevAddr: byte;
I2C_ChunkSize: Word = 65535;
i: Longword;
begin
try
ButtonCancel.Tag := 0;
Expand All @@ -2357,7 +2367,7 @@ procedure TMainForm.ButtonVerifyClick(Sender: TObject);
LogPrint(STR_CHECK_SETTINGS, clRed);
Exit;
end;
if KHexEditor.Data.Size > StrToInt(ComboChipSize.Text) then
if (KHexEditor.Data.Size > StrToInt(ComboChipSize.Text)) and (not BlankCheck) then
begin
LogPrint(STR_WRONG_FILE_SIZE, clRed);
Exit;
Expand All @@ -2370,18 +2380,24 @@ procedure TMainForm.ButtonVerifyClick(Sender: TObject);
EnterProgMode25(hUSBdev);
TimeCounter := Time();

RomF.Position :=0;
KHexEditor.SaveToStream(RomF);
RomF.Clear;
if BlankCheck then
begin
for i:=1 to StrToInt(ComboChipSize.Text) do
RomF.WriteByte($FF);
end
else
KHexEditor.SaveToStream(RomF);
RomF.Position :=0;

if ComboSPICMD.ItemIndex = SPI_CMD_KB then
VerifyFlashKB(RomF, 0, KHexEditor.Data.Size);
VerifyFlashKB(RomF, 0, RomF.Size);

if ComboSPICMD.ItemIndex = SPI_CMD_25 then
VerifyFlash25(RomF, 0, KHexEditor.Data.Size);
VerifyFlash25(RomF, 0, RomF.Size);

if ComboSPICMD.ItemIndex = SPI_CMD_95 then
VerifyFlash95(RomF, 0, KHexEditor.Data.Size, StrToInt(ComboChipSize.Text));
VerifyFlash95(RomF, 0, RomF.Size, StrToInt(ComboChipSize.Text));

if ComboSPICMD.ItemIndex = SPI_CMD_45 then
begin
Expand All @@ -2390,7 +2406,7 @@ procedure TMainForm.ButtonVerifyClick(Sender: TObject);
LogPrint(STR_CHECK_SETTINGS, clRed);
Exit;
end;
VerifyFlash45(RomF, 0, StrToInt(ComboPageSize.Text), KHexEditor.Data.Size);
VerifyFlash45(RomF, 0, StrToInt(ComboPageSize.Text), RomF.Size);
end;


Expand Down Expand Up @@ -2418,10 +2434,17 @@ procedure TMainForm.ButtonVerifyClick(Sender: TObject);
end;
TimeCounter := Time();

RomF.Clear;
if BlankCheck then
begin
for i:=1 to StrToInt(ComboChipSize.Text) do
RomF.WriteByte($FF);
end
else
KHexEditor.SaveToStream(RomF);
RomF.Position :=0;
KHexEditor.SaveToStream(RomF);
RomF.Position :=0;
VerifyFlashI2C(RomF, KHexEditor.Data.Size, I2C_ChunkSize, I2C_DevAddr);

VerifyFlashI2C(RomF, RomF.Size, I2C_ChunkSize, I2C_DevAddr);
end;

//Microwire
Expand All @@ -2437,9 +2460,16 @@ procedure TMainForm.ButtonVerifyClick(Sender: TObject);
EnterProgMode25(hUSBdev);
TimeCounter := Time();

RomF.Clear;
if BlankCheck then
begin
for i:=1 to StrToInt(ComboChipSize.Text) do
RomF.WriteByte($FF);
end
else
KHexEditor.SaveToStream(RomF);
RomF.Position :=0;
KHexEditor.SaveToStream(RomF);
RomF.Position :=0;

VerifyFlashMW(RomF, StrToInt(ComboMWBitLen.Text), 0, StrToInt(ComboChipSize.Text));
end;

Expand Down Expand Up @@ -2739,8 +2769,8 @@ procedure TMainForm.FormDestroy(Sender: TObject);

procedure TMainForm.ButtonReadClick(Sender: TObject);
var
I2C_DevAddr: byte = 65535;
I2C_ChunkSize: word;
I2C_DevAddr: byte;
I2C_ChunkSize: word = 65535;
begin
try
ButtonCancel.Tag := 0;
Expand Down Expand Up @@ -3013,6 +3043,11 @@ procedure TMainForm.ButtonEraseClick(Sender: TObject);
end;
end;

procedure TMainForm.BlankCheckMenuItemClick(Sender: TObject);
begin
VerifyFlash(true);
end;

procedure SaveOptions(XMLfile: TXMLDocument);
var
Node, ParentNode: TDOMNode;
Expand Down

0 comments on commit e0154c4

Please sign in to comment.