Browse Source

Add variable reg field support

master
h-4nd-h 4 years ago
parent
commit
8105462729
  1. 78
      mainwindow.cpp
  2. 43
      mainwindow.ui

78
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();

43
mainwindow.ui

@ -341,6 +341,49 @@
</item>
</layout>
</widget>
<widget class="QLabel" name="label_6">
<property name="geometry">
<rect>
<x>460</x>
<y>50</y>
<width>121</width>
<height>17</height>
</rect>
</property>
<property name="text">
<string>Transaction width:</string>
</property>
</widget>
<widget class="QComboBox" name="cb_regWidth">
<property name="geometry">
<rect>
<x>480</x>
<y>70</y>
<width>86</width>
<height>25</height>
</rect>
</property>
<item>
<property name="text">
<string>8</string>
</property>
</item>
<item>
<property name="text">
<string>16</string>
</property>
</item>
<item>
<property name="text">
<string>32</string>
</property>
</item>
<item>
<property name="text">
<string>64</string>
</property>
</item>
</widget>
</widget>
</item>
<item>

Loading…
Cancel
Save