diff --git a/mainwindow.cpp b/mainwindow.cpp index c7a813d..f42eb38 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -83,7 +83,7 @@ void MainWindow::on_btn_binUpload_clicked() MESSAGE_BOX("Invalid input format for offset"); return; } - _settings->setValue(BIN_OFFSET, offset); + _settings->setValue(BIN_OFFSET, ui->tb_binOffset->text()); _settings->setValue(BIN_BAR_INDEX, ui->cb_binBarNum->currentIndex()); auto path = ui->tb_binFile->text(); @@ -107,7 +107,7 @@ void MainWindow::on_btn_binVerify_clicked() MESSAGE_BOX("Invalid input format for offset"); return; } - _settings->setValue(BIN_OFFSET, offset); + _settings->setValue(BIN_OFFSET, ui->tb_binOffset->text()); _settings->setValue(BIN_BAR_INDEX, ui->cb_binBarNum->currentIndex()); auto path = ui->tb_binFile->text(); @@ -329,7 +329,7 @@ void MainWindow::on_rbtn_reg_toggled(bool checked) if(checked) { _settings->setValue(REG_ACCESS_SEL, true); - ui->l_regIndicator->setText("Register number: (Dec)"); + ui->l_regIndicator->setText("Register number: (Hex)"); } } @@ -348,21 +348,41 @@ void MainWindow::on_btn_readReg_clicked() { auto bar = ui->cb_regBarNum->currentText().toUInt(); - quint32 offset = 0; - if(ui->rbtn_reg->isChecked()) - offset = ui->tb_regIndicator->text().toUInt(Q_NULLPTR, 10) * 4; - else - offset = ui->tb_regIndicator->text().toUInt(Q_NULLPTR, 16); - + auto offset = ui->tb_regIndicator->text().toUInt(Q_NULLPTR, 16); if(offset == 0 && ui->tb_regIndicator->text() != "0") { MESSAGE_BOX("Invalid input format for offset"); return; } - auto value = _usd->readWord(offset, bar); + quint64 value = 0; + auto width = ui->cb_regWidth->currentIndex(); + switch(width) + { + case 0: + value = _usd->readByte(offset, bar); + ui->lcd_regvalue->setDigitCount(2); + break; + case 1: + if(ui->rbtn_reg->isChecked()) + offset *= 2; + value = _usd->readShort(offset, bar); + ui->lcd_regvalue->setDigitCount(4); + break; + case 2: + if(ui->rbtn_reg->isChecked()) + offset *= 4; + value = _usd->readWord(offset, bar); + ui->lcd_regvalue->setDigitCount(8); + break; + case 3: + if(ui->rbtn_reg->isChecked()) + offset *= 8; + value = _usd->readLong(offset, bar); + ui->lcd_regvalue->setDigitCount(16); + break; + } - ui->lcd_regvalue->setDigitCount(8); ui->lcd_regvalue->display(QString::number(value, 16)); } @@ -371,26 +391,42 @@ void MainWindow::on_btn_writeReg_clicked() { auto bar = ui->cb_regBarNum->currentText().toUInt(); - quint32 offset = 0; - if(ui->rbtn_reg->isChecked()) - offset = ui->tb_regIndicator->text().toUInt(Q_NULLPTR, 10) * 4; - else - offset = ui->tb_regIndicator->text().toUInt(Q_NULLPTR, 16); - + auto offset = ui->tb_regIndicator->text().toUInt(Q_NULLPTR, 16); if(offset == 0 && ui->tb_regIndicator->text() != "0") { MESSAGE_BOX("Invalid input format for offset"); return; } - auto value = ui->tb_regValue->text().toUInt(Q_NULLPTR, 16); + auto value = ui->tb_regValue->text().toULong(Q_NULLPTR, 16); if(value == 0 && ui->tb_regValue->text() != "0") { MESSAGE_BOX("Invalid input format for write value"); return; } - _usd->writeWord(offset, bar, value); + auto width = ui->cb_regWidth->currentIndex(); + switch(width) + { + case 0: + _usd->writeByte(offset, bar, value); + break; + case 1: + if(ui->rbtn_reg->isChecked()) + offset *= 2; + _usd->writeShort(offset, bar, value); + break; + case 2: + if(ui->rbtn_reg->isChecked()) + offset *= 4; + _usd->writeWord(offset, bar, value); + break; + case 3: + if(ui->rbtn_reg->isChecked()) + offset *= 8; + _usd->writeLong(offset, bar, value); + break; + } } /*************************************************************************************************/ @@ -435,8 +471,8 @@ void MainWindow::on_btn_fpgaBrowse_clicked() /*************************************************************************************************/ void MainWindow::on_btn_fpgaProgram_clicked() { - auto bar = 1; - auto offset = 1000; + auto bar = 0; + auto offset = 0x4; auto path = ui->tb_fpgaBit->text(); diff --git a/mainwindow.ui b/mainwindow.ui index fbd116b..2727381 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -341,6 +341,49 @@ + + + + 460 + 50 + 121 + 17 + + + + Transaction width: + + + + + + 480 + 70 + 86 + 25 + + + + + 8 + + + + + 16 + + + + + 32 + + + + + 64 + + +