28
28
#define HEADER_HEX_WIDTH 340
29
29
#define BUFFER_ROW_HEIGHT 20
30
30
31
- #define START_ADDRESS 0x00000000
32
-
33
31
#define CHIP_NAME_DEFAULT " NONE"
34
32
#define CHIP_INDEX_DEFAULT 0
35
33
#define CHIP_INDEX2ID (index ) (index - 1 )
@@ -59,6 +57,13 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent),
59
57
logger->setTextEdit (ui->logTextEdit );
60
58
61
59
initBufTable ();
60
+ #ifdef Q_OS_WIN32
61
+ QFont font (" Courier New" , 9 );
62
+ ui->firstSpinBox ->setFont (font);
63
+ ui->lastSpinBox ->setFont (font);
64
+ #endif
65
+ ui->firstSpinBox ->setEnabled (false );
66
+ ui->lastSpinBox ->setEnabled (false );
62
67
63
68
prog = new Programmer (this );
64
69
updateProgSettings ();
@@ -126,6 +131,22 @@ void MainWindow::setUiStateSelected(bool isSelected)
126
131
ui->actionRead ->setEnabled (isSelected);
127
132
ui->actionWrite ->setEnabled (isSelected);
128
133
ui->actionReadBadBlocks ->setEnabled (isSelected);
134
+
135
+ ui->firstSpinBox ->setEnabled (isSelected);
136
+ ui->lastSpinBox ->setEnabled (isSelected);
137
+ if (isSelected)
138
+ {
139
+ QString chipName = ui->chipSelectComboBox ->currentText ();
140
+ quint32 blocksCount = currentChipDb->blockCountGetByName (chipName);
141
+ ui->firstSpinBox ->setMaximum (blocksCount - 1 );
142
+ ui->firstSpinBox ->setValue (0 );
143
+ ui->lastSpinBox ->setMaximum (blocksCount - 1 );
144
+ ui->lastSpinBox ->setValue (blocksCount - 1 );
145
+ quint64 chipSize = prog->isIncSpare () ?
146
+ currentChipDb->extendedTotalSizeGetByName (chipName) :
147
+ currentChipDb->totalSizeGetByName (chipName);
148
+ ui->blockSizeValueLabel ->setText (QString (" 0x%1" ).arg (chipSize / blocksCount, 8 , 16 , QLatin1Char ( ' 0' )));
149
+ }
129
150
}
130
151
131
152
void MainWindow::slotProgConnectCompleted (quint64 status)
@@ -205,23 +226,21 @@ void MainWindow::slotProgEraseCompleted(quint64 status)
205
226
void MainWindow::slotProgEraseProgress (quint64 progress)
206
227
{
207
228
uint32_t progressPercent;
208
- QString chipName = ui->chipSelectComboBox ->currentText ();
209
- quint64 eraseSize = prog->isIncSpare () ?
210
- currentChipDb->extendedTotalSizeGetByName (chipName) :
211
- currentChipDb->totalSizeGetByName (chipName);
212
229
213
- progressPercent = progress * 100ULL / eraseSize ;
230
+ progressPercent = progress * 100ULL / areaSize ;
214
231
setProgress (progressPercent);
215
232
}
216
233
217
234
void MainWindow::slotProgErase ()
218
235
{
219
- QString chipName = ui->chipSelectComboBox ->currentText ();
220
- quint64 eraseSize = prog->isIncSpare () ?
221
- currentChipDb->extendedTotalSizeGetByName (chipName) :
222
- currentChipDb->totalSizeGetByName (chipName);
236
+ quint64 start_address =
237
+ ui->blockSizeValueLabel ->text ().toULongLong (nullptr , 16 )
238
+ * ui->firstSpinBox ->value ();
239
+ areaSize =
240
+ ui->blockSizeValueLabel ->text ().toULongLong (nullptr , 16 )
241
+ * (ui->lastSpinBox ->value () + 1 ) - start_address;
223
242
224
- if (!eraseSize )
243
+ if (!areaSize )
225
244
{
226
245
qCritical () << " Chip size is not set" ;
227
246
return ;
@@ -236,7 +255,7 @@ void MainWindow::slotProgErase()
236
255
connect (prog, SIGNAL (eraseChipProgress (quint64)), this ,
237
256
SLOT (slotProgEraseProgress (quint64)));
238
257
239
- prog->eraseChip (START_ADDRESS, eraseSize );
258
+ prog->eraseChip (start_address, areaSize );
240
259
}
241
260
242
261
void MainWindow::slotProgReadCompleted (quint64 readBytes)
@@ -277,12 +296,8 @@ void MainWindow::slotProgReadCompleted(quint64 readBytes)
277
296
void MainWindow::slotProgReadProgress (quint64 progress)
278
297
{
279
298
uint32_t progressPercent;
280
- QString chipName = ui->chipSelectComboBox ->currentText ();
281
- quint64 readSize = prog->isIncSpare () ?
282
- currentChipDb->extendedTotalSizeGetByName (chipName) :
283
- currentChipDb->totalSizeGetByName (chipName);
284
299
285
- progressPercent = progress * 100ULL / readSize ;
300
+ progressPercent = progress * 100ULL / areaSize ;
286
301
setProgress (progressPercent);
287
302
288
303
buffer.mutex .lock ();
@@ -293,12 +308,14 @@ void MainWindow::slotProgReadProgress(quint64 progress)
293
308
294
309
void MainWindow::slotProgRead ()
295
310
{
296
- QString chipName = ui->chipSelectComboBox ->currentText ();
297
- quint64 readSize = prog->isIncSpare () ?
298
- currentChipDb->extendedTotalSizeGetByName (chipName) :
299
- currentChipDb->totalSizeGetByName (chipName);
311
+ quint64 start_address =
312
+ ui->blockSizeValueLabel ->text ().toULongLong (nullptr , 16 )
313
+ * ui->firstSpinBox ->value ();
314
+ areaSize =
315
+ ui->blockSizeValueLabel ->text ().toULongLong (nullptr , 16 )
316
+ * (ui->lastSpinBox ->value () + 1 ) - start_address;
300
317
301
- if (!readSize )
318
+ if (!areaSize )
302
319
{
303
320
qCritical () << " Chip size is not set" ;
304
321
return ;
@@ -342,7 +359,7 @@ void MainWindow::slotProgRead()
342
359
ui->filePathLineEdit ->setDisabled (true );
343
360
ui->selectFilePushButton ->setDisabled (true );
344
361
345
- prog->readChip (&buffer, START_ADDRESS, readSize , true );
362
+ prog->readChip (&buffer, start_address, areaSize , true );
346
363
}
347
364
348
365
void MainWindow::slotProgWriteCompleted (int status)
@@ -366,7 +383,7 @@ void MainWindow::slotProgWriteProgress(quint64 progress)
366
383
{
367
384
uint32_t progressPercent;
368
385
369
- progressPercent = progress * 100ULL / progSize ;
386
+ progressPercent = progress * 100ULL / areaSize ;
370
387
setProgress (progressPercent);
371
388
372
389
std::unique_lock<std::mutex> lck (buffer.mutex );
@@ -426,13 +443,24 @@ void MainWindow::slotProgWrite()
426
443
return ;
427
444
}
428
445
429
- progSize = static_cast <uint32_t >(workFile.size ());
446
+ quint64 start_address =
447
+ ui->blockSizeValueLabel ->text ().toULongLong (nullptr , 16 )
448
+ * ui->firstSpinBox ->value ();
449
+
450
+ areaSize = workFile.size ();
430
451
431
- if (progSize % pageSize)
452
+ if (areaSize % pageSize)
432
453
{
433
- progSize = (progSize / pageSize + 1 ) * pageSize;
454
+ areaSize = (areaSize / pageSize + 1 ) * pageSize;
434
455
}
435
456
457
+ quint64 setSize =
458
+ ui->blockSizeValueLabel ->text ().toULongLong (nullptr , 16 )
459
+ * (ui->lastSpinBox ->value () + 1 ) - start_address;
460
+
461
+ if (setSize < areaSize)
462
+ areaSize = setSize;
463
+
436
464
qInfo () << " Writing data ..." ;
437
465
438
466
connect (prog, SIGNAL (writeChipCompleted (int )), this ,
@@ -462,7 +490,7 @@ void MainWindow::slotProgWrite()
462
490
}
463
491
464
492
buffer.ready = true ;
465
- prog->writeChip (&buffer, START_ADDRESS, progSize , pageSize);
493
+ prog->writeChip (&buffer, start_address, areaSize , pageSize);
466
494
}
467
495
468
496
void MainWindow::slotProgReadBadBlocksCompleted (quint64 status)
@@ -702,6 +730,11 @@ void MainWindow::updateProgSettings()
702
730
prog->setHwEccEnabled (settings.value (SETTINGS_ENABLE_HW_ECC).toBool ());
703
731
if (settings.contains (SETTINGS_ENABLE_ALERT))
704
732
isAlertEnabled = settings.value (SETTINGS_ENABLE_ALERT).toBool ();
733
+
734
+ if (ui->chipSelectComboBox ->currentIndex () > 0 )
735
+ {
736
+ setUiStateSelected (true );
737
+ }
705
738
}
706
739
707
740
void MainWindow::slotSettingsParallelChipDb ()
0 commit comments