Skip to content

Commit 7da667c

Browse files
committed
qt: send page size bytes without ACK on write
1 parent b91cd83 commit 7da667c

File tree

5 files changed

+678
-7
lines changed

5 files changed

+678
-7
lines changed

qt/main_window.cpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,14 +224,28 @@ void MainWindow::writeChipCb(int status)
224224

225225
void MainWindow::slotProgWrite()
226226
{
227+
uint32_t pageSize;
228+
227229
if (!bufferSize)
228230
{
229231
qInfo() << "Write buffer is empty";
230232
return;
231233
}
232234

235+
if (chipId == CHIP_ID_NONE)
236+
{
237+
qInfo() << "Chip is not selected";
238+
return;
239+
}
240+
241+
if (!(pageSize = getChipPageSize(chipId)))
242+
{
243+
qInfo() << "Chip page size is unknown";
244+
return;
245+
}
246+
233247
prog->writeChip(std::bind(&MainWindow::writeChipCb, this,
234-
std::placeholders::_1), buffer, START_ADDRESS, bufferSize);
248+
std::placeholders::_1), buffer, START_ADDRESS, bufferSize, pageSize);
235249
}
236250

237251
void MainWindow::selectChipCb()
@@ -241,6 +255,7 @@ void MainWindow::selectChipCb()
241255

242256
void MainWindow::slotSelectChip(int selectedChipNum)
243257
{
258+
chipId = selectedChipNum;
244259
prog->selectChip(std::bind(&MainWindow::selectChipCb, this),
245260
selectedChipNum);
246261
}

qt/main_window.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class MainWindow : public QMainWindow
2828
uint8_t *buffer;
2929
uint32_t bufferSize;
3030
BufferTableModel bufferTableModel;
31+
uint32_t chipId;
3132

3233
void initBufTable();
3334
void resetBufTable();

qt/programmer.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
#define READ_TIMEOUT_MS 100
1414
#define ERASE_TIMEOUT_MS 10000
1515
#define WRITE_TIMEOUT_MS 30000
16-
#define WRITE_BYTES_PENDING_ACK_LIM 1984
1716

1817
Programmer::Programmer(QObject *parent) : QObject(parent)
1918
{
@@ -389,7 +388,7 @@ void Programmer::sendWriteCmdCb(int status)
389388
return;
390389
}
391390

392-
if (writeSentBytes < writeAckBytes + WRITE_BYTES_PENDING_ACK_LIM)
391+
if (writeSentBytes < writeAckBytes + writeAckBytesLim)
393392
sendWriteCmd();
394393
}
395394

@@ -410,7 +409,7 @@ void Programmer::sendWriteCmd()
410409

411410
sendDataLen = writeRemainingBytes < txBufDataLen ?
412411
writeRemainingBytes : txBufDataLen;
413-
ackLim = writeAckBytes + WRITE_BYTES_PENDING_ACK_LIM;
412+
ackLim = writeAckBytes + writeAckBytesLim;
414413
if (writeSentBytes + sendDataLen > ackLim)
415414
sendDataLen = ackLim - writeSentBytes;
416415

@@ -468,7 +467,7 @@ int Programmer::handleWriteAck(QByteArray *data)
468467
this, std::placeholders::_1), data, WRITE_TIMEOUT_MS,
469468
sizeof(RespHeader));
470469

471-
if (writeSentBytes < writeAckBytes + WRITE_BYTES_PENDING_ACK_LIM)
470+
if (writeSentBytes < writeAckBytes + writeAckBytesLim)
472471
sendWriteCmd();
473472

474473
return 0;
@@ -582,7 +581,7 @@ void Programmer::sendWriteStartCmdCb(int status)
582581
}
583582

584583
void Programmer::writeChip(std::function<void(int)> callback, uint8_t *buf,
585-
uint32_t addr, uint32_t len)
584+
uint32_t addr, uint32_t len, uint32_t pageSize)
586585
{
587586
WriteStartCmd writeStartCmd;
588587

@@ -602,6 +601,7 @@ void Programmer::writeChip(std::function<void(int)> callback, uint8_t *buf,
602601
writeLen = len;
603602
writeChipCb = callback;
604603
writeAckBytes = 0;
604+
writeAckBytesLim = pageSize;
605605
writeData.clear();
606606
writeData.append((const char *)&writeStartCmd, sizeof(writeStartCmd));
607607

0 commit comments

Comments
 (0)