Skip to content

Commit 81e00ec

Browse files
committed
qt: make erase size depend on selected chip
1 parent 4bdc74e commit 81e00ec

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

qt/chip_db.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
static ChipInfo chipDB[] =
44
{
5-
{ CHIP_ID_NONE, "No Chip" },
6-
{ CHIP_ID_K9F2G08U0C, "K9F2G08U0C" },
5+
{ CHIP_ID_NONE, "No Chip", 0 },
6+
{ CHIP_ID_K9F2G08U0C, "K9F2G08U0C", 0x10000000 },
77
};
88

99
uint32_t getChipDB(ChipInfo *&db)
@@ -12,3 +12,11 @@ uint32_t getChipDB(ChipInfo *&db)
1212

1313
return CHIP_ID_LAST;
1414
}
15+
16+
ChipInfo *getChiInfo(uint32_t id)
17+
{
18+
if (id >= CHIP_ID_LAST)
19+
return 0;
20+
21+
return &chipDB[id];
22+
}

qt/chip_db.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@ enum
1414

1515
typedef struct
1616
{
17-
uint32_t num;
17+
uint32_t id;
1818
char name[MAX_CHIP_NAME_LEN];
19+
uint32_t size;
1920
} ChipInfo;
2021

2122
uint32_t getChipDB(ChipInfo *&db);
23+
ChipInfo *getChiInfo(uint32_t id);
2224

2325
#endif // CHIP_DB_H
2426

qt/main_window.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,10 @@ void MainWindow::slotProgReadDeviceId()
166166

167167
void MainWindow::slotProgErase()
168168
{
169-
if (prog->eraseChip(0x00, 2 * 128 * 1024))
169+
const uint32_t addr = 0x00000000;
170+
ChipInfo *chipInfo = getChiInfo(ui->chipSelectComboBox->currentIndex());
171+
172+
if (prog->eraseChip(addr, chipInfo->size))
170173
log(tr("Failed to erase chip\n"));
171174
else
172175
log(tr("Chip has been erased successfully\n"));

0 commit comments

Comments
 (0)