commit
						ab1dd41525
					
				 6 changed files with 996 additions and 0 deletions
			
			
		| @ -0,0 +1,2 @@ | |||||
|  | *.user | ||||
|  | 
 | ||||
| @ -0,0 +1,35 @@ | |||||
|  | QT       += core gui | ||||
|  | 
 | ||||
|  | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets | ||||
|  | 
 | ||||
|  | CONFIG += c++11 | ||||
|  | 
 | ||||
|  | # The following define makes your compiler emit warnings if you use | ||||
|  | # any Qt feature that has been marked deprecated (the exact warnings | ||||
|  | # depend on your compiler). Please consult the documentation of the | ||||
|  | # deprecated API in order to know how to port your code away from it. | ||||
|  | DEFINES += QT_DEPRECATED_WARNINGS | ||||
|  | 
 | ||||
|  | # You can also make your code fail to compile if it uses deprecated APIs. | ||||
|  | # In order to do so, uncomment the following line. | ||||
|  | # You can also select to disable deprecated APIs only up to a certain version of Qt. | ||||
|  | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0 | ||||
|  | 
 | ||||
|  | SOURCES += \ | ||||
|  |     main.cpp \ | ||||
|  |     mainwindow.cpp  \ | ||||
|  |     /home/hasis/Desktop/pcie/pcie_driver/api/api.cpp | ||||
|  | 
 | ||||
|  | HEADERS += \ | ||||
|  |     mainwindow.h    \ | ||||
|  |     /home/hasis/Desktop/pcie/pcie_driver/api/api.h | ||||
|  | 
 | ||||
|  | FORMS += \ | ||||
|  |     mainwindow.ui | ||||
|  | 
 | ||||
|  | INCLUDEPATH += /home/hasis/Desktop/pcie/pcie_driver/api/ | ||||
|  | 
 | ||||
|  | # Default rules for deployment. | ||||
|  | qnx: target.path = /tmp/$${TARGET}/bin | ||||
|  | else: unix:!android: target.path = /opt/$${TARGET}/bin | ||||
|  | !isEmpty(target.path): INSTALLS += target | ||||
| @ -0,0 +1,11 @@ | |||||
|  | #include "mainwindow.h" | ||||
|  | 
 | ||||
|  | #include <QApplication> | ||||
|  | 
 | ||||
|  | int main(int argc, char *argv[]) | ||||
|  | { | ||||
|  |     QApplication a(argc, argv); | ||||
|  |     MainWindow w; | ||||
|  |     w.show(); | ||||
|  |     return a.exec(); | ||||
|  | } | ||||
| @ -0,0 +1,437 @@ | |||||
|  | #include "mainwindow.h" | ||||
|  | #include "ui_mainwindow.h" | ||||
|  | 
 | ||||
|  | #include <QDebug> | ||||
|  | #include <QFileDialog> | ||||
|  | #include <QtConcurrent/QtConcurrent> | ||||
|  | #include <QMessageBox> | ||||
|  | 
 | ||||
|  | #define MESSAGE_BOX(M)  \ | ||||
|  |     emit showMessage(M) | ||||
|  | 
 | ||||
|  | 
 | ||||
|  | MainWindow::MainWindow(QWidget *parent) | ||||
|  |     : QMainWindow(parent) | ||||
|  |     , ui(new Ui::MainWindow) | ||||
|  | { | ||||
|  |     ui->setupUi(this); | ||||
|  | 
 | ||||
|  |     _settings = new QSettings("Hasis", "HwTester"); | ||||
|  | 
 | ||||
|  |     _usd = new UltraSoundDevice(); | ||||
|  | 
 | ||||
|  |     this->setFixedSize(this->width(),this->height()); | ||||
|  | 
 | ||||
|  |     ui->prg_binUpload->setVisible(false); | ||||
|  |     ui->prg_fpgaProgram->setVisible(false); | ||||
|  | 
 | ||||
|  |     ui->tb_binFile->setReadOnly(true); | ||||
|  |     ui->tb_fpgaBit->setReadOnly(true); | ||||
|  | 
 | ||||
|  |     ui->tb_binFile->setText(_settings->value(BIN_FILE_PATH).value<QString>()); | ||||
|  |     ui->tb_binOffset->setText(_settings->value(BIN_OFFSET).value<QString>()); | ||||
|  |     ui->cb_binBarNum->setCurrentIndex(_settings->value(BIN_BAR_INDEX).value<int>()); | ||||
|  |     ui->rbtn_reg->setChecked(_settings->value(REG_ACCESS_SEL).value<bool>()); | ||||
|  |     ui->rbtn_offset->setChecked(!_settings->value(REG_ACCESS_SEL).value<bool>()); | ||||
|  |     ui->tb_fpgaBit->setText(_settings->value(FPGA_FILE_PATH).value<QString>()); | ||||
|  | 
 | ||||
|  |     connect(this, &MainWindow::updateBlockProgressValue, this, &MainWindow::newBlockProgressValue); | ||||
|  |     connect(this, &MainWindow::updateFpgaProgressValue, this, &MainWindow::newFpgaProgressValue); | ||||
|  |     connect(this, &MainWindow::updateBlockProgressVisibility, this, &MainWindow::newBlockProgressVisibility); | ||||
|  |     connect(this, &MainWindow::updateFpgaProgressVisibility, this, &MainWindow::newFpgaProgressVisibility); | ||||
|  |     connect(this, &MainWindow::showMessage, this, &MainWindow::newMessage); | ||||
|  | } | ||||
|  | 
 | ||||
|  | /*************************************************************************************************/ | ||||
|  | MainWindow::~MainWindow() | ||||
|  | { | ||||
|  |     delete ui; | ||||
|  | 
 | ||||
|  |     delete _settings; | ||||
|  | 
 | ||||
|  |     delete _usd; | ||||
|  | } | ||||
|  | 
 | ||||
|  | /*************************************************************************************************/ | ||||
|  | void MainWindow::on_btn_browse_clicked() | ||||
|  | { | ||||
|  |     QFileDialog fileDialog; | ||||
|  |     fileDialog.setNameFilters({"SRAM binary file (*.bin)"}); | ||||
|  |     auto result = fileDialog.exec(); | ||||
|  | 
 | ||||
|  |     if(result) | ||||
|  |     { | ||||
|  |         auto selectedPath = fileDialog.selectedFiles()[0]; | ||||
|  |         ui->tb_binFile->setText(selectedPath); | ||||
|  |         _settings->setValue(BIN_FILE_PATH, selectedPath); | ||||
|  |     } | ||||
|  | } | ||||
|  | 
 | ||||
|  | /*************************************************************************************************/ | ||||
|  | void MainWindow::on_btn_binUpload_clicked() | ||||
|  | { | ||||
|  |     auto bar = ui->cb_binBarNum->currentText().toUInt(); | ||||
|  | 
 | ||||
|  |     auto offset = ui->tb_binOffset->text().toUInt(Q_NULLPTR, 16); | ||||
|  |     if(offset == 0 && ui->tb_binOffset->text() != "0") | ||||
|  |     { | ||||
|  |         MESSAGE_BOX("Invalid input format for offset"); | ||||
|  |         return; | ||||
|  |     } | ||||
|  |     _settings->setValue(BIN_OFFSET, offset); | ||||
|  |     _settings->setValue(BIN_BAR_INDEX, ui->cb_binBarNum->currentIndex()); | ||||
|  | 
 | ||||
|  |     auto path = ui->tb_binFile->text(); | ||||
|  | 
 | ||||
|  |     QtConcurrent::run(this, &MainWindow::binaryFileUploader, bar, offset, path); | ||||
|  | } | ||||
|  | 
 | ||||
|  | /*************************************************************************************************/ | ||||
|  | void MainWindow::on_btn_binVerify_clicked() | ||||
|  | { | ||||
|  |     auto bar = ui->cb_binBarNum->currentText().toUInt(); | ||||
|  | 
 | ||||
|  |     auto offset = ui->tb_binOffset->text().toUInt(Q_NULLPTR, 16); | ||||
|  |     if(offset == 0 && ui->tb_binOffset->text() != "0") | ||||
|  |     { | ||||
|  |         MESSAGE_BOX("Invalid input format for offset"); | ||||
|  |         return; | ||||
|  |     } | ||||
|  |     _settings->setValue(BIN_OFFSET, offset); | ||||
|  |     _settings->setValue(BIN_BAR_INDEX, ui->cb_binBarNum->currentIndex()); | ||||
|  | 
 | ||||
|  |     auto path = ui->tb_binFile->text(); | ||||
|  | 
 | ||||
|  |     QtConcurrent::run(this, &MainWindow::binaryFileVerifier, bar, offset, path); | ||||
|  | } | ||||
|  | 
 | ||||
|  | /*************************************************************************************************/ | ||||
|  | void MainWindow::binaryFileUploader(quint32 bar, quint32 offset, QString path) | ||||
|  | { | ||||
|  |     QFile file(path); | ||||
|  | 
 | ||||
|  |     if (!file.open(QFile::ReadOnly)) | ||||
|  |     { | ||||
|  |         MESSAGE_BOX("Could not open binary file, aborting operation"); | ||||
|  |         return; | ||||
|  |     } | ||||
|  | 
 | ||||
|  |     emit updateBlockProgressVisibility(true); | ||||
|  |     emit updateBlockProgressValue(0); | ||||
|  | 
 | ||||
|  |     const auto actualSize = file.size(); | ||||
|  |     auto readSize = 0; | ||||
|  |     while(readSize < actualSize) | ||||
|  |     { | ||||
|  |         QByteArray chunk = file.read(4); | ||||
|  |         auto value = byteArrayTo32LittleEndian(chunk); | ||||
|  |         try | ||||
|  |         { | ||||
|  |             _usd->writeWord(offset + readSize, bar, value); | ||||
|  |         } catch (myexception e) | ||||
|  |         { | ||||
|  |             MESSAGE_BOX(e.what()); | ||||
|  | 
 | ||||
|  |             emit updateBlockProgressVisibility(false); | ||||
|  | 
 | ||||
|  |             file.close(); | ||||
|  | 
 | ||||
|  |             return; | ||||
|  |         } | ||||
|  |         readSize += 4; | ||||
|  | 
 | ||||
|  |         auto percentage = (readSize * 100 / actualSize); | ||||
|  |         emit updateBlockProgressValue(percentage); | ||||
|  |     } | ||||
|  | 
 | ||||
|  |     MESSAGE_BOX("Binary file upload finished with success"); | ||||
|  | 
 | ||||
|  |     emit updateBlockProgressVisibility(false); | ||||
|  | 
 | ||||
|  |     file.close(); | ||||
|  | } | ||||
|  | 
 | ||||
|  | /*************************************************************************************************/ | ||||
|  | void MainWindow::binaryFileVerifier(quint32 bar, quint32 offset, QString path) | ||||
|  | { | ||||
|  |     QFile file(path); | ||||
|  | 
 | ||||
|  |     if (!file.open(QFile::ReadOnly)) | ||||
|  |     { | ||||
|  |         MESSAGE_BOX("Could not open binary file, aborting operation"); | ||||
|  |         return; | ||||
|  |     } | ||||
|  | 
 | ||||
|  |     emit updateBlockProgressVisibility(true); | ||||
|  |     emit updateBlockProgressValue(0); | ||||
|  | 
 | ||||
|  |     const auto actualSize = file.size(); | ||||
|  |     auto readSize = 0; | ||||
|  |     while(readSize < actualSize) | ||||
|  |     { | ||||
|  |         QByteArray chunk = file.read(4); | ||||
|  |         auto value = byteArrayTo32LittleEndian(chunk); | ||||
|  |         try | ||||
|  |         { | ||||
|  |             auto data = _usd->readWord(offset + readSize, bar); | ||||
|  |             if(data != value) | ||||
|  |             { | ||||
|  |                 auto message = QString("Error in data @ offset 0x%1, expected 0x%2 saw 0x%3") | ||||
|  |                         .arg(QString::number(offset + readSize)) | ||||
|  |                         .arg(QString::number(value, 16)) | ||||
|  |                         .arg(QString::number(data, 16)); | ||||
|  |                 MESSAGE_BOX(message); | ||||
|  | 
 | ||||
|  |                 emit updateBlockProgressVisibility(false); | ||||
|  | 
 | ||||
|  |                 file.close(); | ||||
|  | 
 | ||||
|  |                 return; | ||||
|  |             } | ||||
|  |         } | ||||
|  |         catch (myexception e) | ||||
|  |         { | ||||
|  |             MESSAGE_BOX(e.what()); | ||||
|  | 
 | ||||
|  |             emit updateBlockProgressVisibility(false); | ||||
|  | 
 | ||||
|  |             file.close(); | ||||
|  | 
 | ||||
|  |             return; | ||||
|  |         } | ||||
|  |         readSize += 4; | ||||
|  | 
 | ||||
|  |         auto percentage = (readSize * 100 / actualSize); | ||||
|  |         emit updateBlockProgressValue(percentage); | ||||
|  |     } | ||||
|  | 
 | ||||
|  |     MESSAGE_BOX("Binary verified with success"); | ||||
|  | 
 | ||||
|  |     emit updateBlockProgressVisibility(false); | ||||
|  | 
 | ||||
|  |     file.close(); | ||||
|  | } | ||||
|  | 
 | ||||
|  | /*************************************************************************************************/ | ||||
|  | void MainWindow::fpgaProgrammer(quint32 bar, quint32 offset, QString path) | ||||
|  | { | ||||
|  |     QFile file(path); | ||||
|  | 
 | ||||
|  |     if (!file.open(QFile::ReadOnly)) | ||||
|  |     { | ||||
|  |         MESSAGE_BOX("Could not open bit file, aborting operation"); | ||||
|  |         return; | ||||
|  |     } | ||||
|  | 
 | ||||
|  |     emit updateFpgaProgressValue(0); | ||||
|  |     emit updateFpgaProgressVisibility(true); | ||||
|  | 
 | ||||
|  |     const auto actualSize = file.size(); | ||||
|  |     auto readSize = 0; | ||||
|  |     while(readSize < actualSize) | ||||
|  |     { | ||||
|  |         QByteArray chunk = file.read(4); | ||||
|  |         auto value = byteArrayTo32BigEndian(chunk); | ||||
|  |         try | ||||
|  |         { | ||||
|  |             _usd->writeWord(offset, bar, value); | ||||
|  |             auto temp = _usd->readWord(offset + 4, bar); | ||||
|  |             while ((temp & 0x01) == 0x01) | ||||
|  |             { | ||||
|  |                 temp = _usd->readWord(offset + 4, bar); | ||||
|  |             } | ||||
|  | 
 | ||||
|  |             if((temp & 0x08) == 0x08) | ||||
|  |             { | ||||
|  |                 throw(myexception("init_fail flag raised")); | ||||
|  |             } | ||||
|  | 
 | ||||
|  |             if((temp & 0x10) == 0x10) | ||||
|  |             { | ||||
|  |                 throw(myexception("time_out flag raised")); | ||||
|  |             } | ||||
|  |         } | ||||
|  |         catch (myexception e) | ||||
|  |         { | ||||
|  |             MESSAGE_BOX(e.what()); | ||||
|  | 
 | ||||
|  |             emit updateFpgaProgressVisibility(false); | ||||
|  | 
 | ||||
|  |             file.close(); | ||||
|  | 
 | ||||
|  |             return; | ||||
|  |         } | ||||
|  |         readSize += 4; | ||||
|  | 
 | ||||
|  |         auto percentage = (readSize * 100 / actualSize); | ||||
|  |         emit updateFpgaProgressValue(percentage); | ||||
|  |     } | ||||
|  | 
 | ||||
|  |     auto temp = _usd->readWord(offset + 4, bar); | ||||
|  |     if((temp & 0x02) == 0x02) | ||||
|  |     { | ||||
|  |         MESSAGE_BOX("FPGA programming finished with success"); | ||||
|  |     } | ||||
|  |     else if((temp & 0x04) == 0x04) | ||||
|  |     { | ||||
|  |         MESSAGE_BOX("FPGA programming failed"); | ||||
|  |     } | ||||
|  | 
 | ||||
|  |     emit updateFpgaProgressVisibility(false); | ||||
|  | 
 | ||||
|  |     file.close(); | ||||
|  | } | ||||
|  | 
 | ||||
|  | /*************************************************************************************************/ | ||||
|  | quint32 MainWindow::byteArrayTo32LittleEndian(QByteArray data) | ||||
|  | { | ||||
|  |     quint32 temp = 0; | ||||
|  | 
 | ||||
|  |     temp = (data[0] & 0x000000FF) | | ||||
|  |             ((data[1] << 8) & 0x0000FF00) | | ||||
|  |             ((data[2] << 16) & 0x00FF0000) | | ||||
|  |             ((data[3] << 24) & 0xFF000000); | ||||
|  | 
 | ||||
|  |     return temp; | ||||
|  | } | ||||
|  | 
 | ||||
|  | /*************************************************************************************************/ | ||||
|  | quint32 MainWindow::byteArrayTo32BigEndian(QByteArray data) | ||||
|  | { | ||||
|  |     quint32 temp = 0; | ||||
|  | 
 | ||||
|  |     temp = (data[3] & 0x000000FF) | | ||||
|  |             ((data[2] << 8) & 0x0000FF00) | | ||||
|  |             ((data[1] << 16) & 0x00FF0000) | | ||||
|  |             ((data[0] << 24) & 0xFF000000); | ||||
|  | 
 | ||||
|  |     return temp; | ||||
|  | } | ||||
|  | 
 | ||||
|  | /*************************************************************************************************/ | ||||
|  | void MainWindow::on_rbtn_reg_toggled(bool checked) | ||||
|  | { | ||||
|  |     if(checked) | ||||
|  |     { | ||||
|  |         _settings->setValue(REG_ACCESS_SEL, true); | ||||
|  |         ui->l_regIndicator->setText("Register number: (Dec)"); | ||||
|  |     } | ||||
|  | } | ||||
|  | 
 | ||||
|  | /*************************************************************************************************/ | ||||
|  | void MainWindow::on_rbtn_offset_toggled(bool checked) | ||||
|  | { | ||||
|  |     if(checked) | ||||
|  |     { | ||||
|  |         _settings->setValue(REG_ACCESS_SEL, false); | ||||
|  |         ui->l_regIndicator->setText("Register offset: (Hex)"); | ||||
|  |     } | ||||
|  | } | ||||
|  | 
 | ||||
|  | /*************************************************************************************************/ | ||||
|  | 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); | ||||
|  | 
 | ||||
|  |     if(offset == 0 && ui->tb_regIndicator->text() != "0") | ||||
|  |     { | ||||
|  |         MESSAGE_BOX("Invalid input format for offset"); | ||||
|  |         return; | ||||
|  |     } | ||||
|  | 
 | ||||
|  |     auto value = _usd->readWord(offset, bar); | ||||
|  | 
 | ||||
|  |     ui->lcd_regvalue->setDigitCount(8); | ||||
|  |     ui->lcd_regvalue->display(QString::number(value, 16)); | ||||
|  | } | ||||
|  | 
 | ||||
|  | /*************************************************************************************************/ | ||||
|  | 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); | ||||
|  | 
 | ||||
|  |     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); | ||||
|  |     if(value == 0 && ui->tb_regValue->text() != "0") | ||||
|  |     { | ||||
|  |         MESSAGE_BOX("Invalid input format for write value"); | ||||
|  |         return; | ||||
|  |     } | ||||
|  | 
 | ||||
|  |     _usd->writeWord(offset, bar, value); | ||||
|  | } | ||||
|  | 
 | ||||
|  | /*************************************************************************************************/ | ||||
|  | void MainWindow::newBlockProgressValue(int percentage) | ||||
|  | { | ||||
|  |     ui->prg_binUpload->setValue(percentage); | ||||
|  | } | ||||
|  | 
 | ||||
|  | /*************************************************************************************************/ | ||||
|  | void MainWindow::newFpgaProgressValue(int percentage) | ||||
|  | { | ||||
|  |     ui->prg_fpgaProgram->setValue(percentage); | ||||
|  | } | ||||
|  | 
 | ||||
|  | /*************************************************************************************************/ | ||||
|  | void MainWindow::newBlockProgressVisibility(bool show) | ||||
|  | { | ||||
|  |     ui->prg_binUpload->setVisible(show); | ||||
|  | } | ||||
|  | 
 | ||||
|  | /*************************************************************************************************/ | ||||
|  | void MainWindow::newFpgaProgressVisibility(bool show) | ||||
|  | { | ||||
|  |     ui->prg_fpgaProgram->setVisible(show); | ||||
|  | } | ||||
|  | 
 | ||||
|  | /*************************************************************************************************/ | ||||
|  | void MainWindow::on_btn_fpgaBrowse_clicked() | ||||
|  | { | ||||
|  |     QFileDialog fileDialog; | ||||
|  |     fileDialog.setNameFilters({"FPGA program file (*.bit)"}); | ||||
|  |     auto result = fileDialog.exec(); | ||||
|  | 
 | ||||
|  |     if(result) | ||||
|  |     { | ||||
|  |         auto selectedPath = fileDialog.selectedFiles()[0]; | ||||
|  |         ui->tb_fpgaBit->setText(selectedPath); | ||||
|  |         _settings->setValue(FPGA_FILE_PATH, selectedPath); | ||||
|  |     } | ||||
|  | } | ||||
|  | 
 | ||||
|  | /*************************************************************************************************/ | ||||
|  | void MainWindow::on_btn_fpgaProgram_clicked() | ||||
|  | { | ||||
|  |     auto bar = 1; | ||||
|  |     auto offset = 1000; | ||||
|  | 
 | ||||
|  |     auto path = ui->tb_fpgaBit->text(); | ||||
|  | 
 | ||||
|  |     QtConcurrent::run(this, &MainWindow::fpgaProgrammer, bar, offset, path); | ||||
|  | } | ||||
|  | 
 | ||||
|  | /*************************************************************************************************/ | ||||
|  | void MainWindow::newMessage(QString message) | ||||
|  | { | ||||
|  |     QMessageBox msgBox; | ||||
|  |     msgBox.setText(message); | ||||
|  |     msgBox.exec(); | ||||
|  | } | ||||
| @ -0,0 +1,79 @@ | |||||
|  | #ifndef MAINWINDOW_H | ||||
|  | #define MAINWINDOW_H | ||||
|  | 
 | ||||
|  | #include <QMainWindow> | ||||
|  | #include <QSettings> | ||||
|  | 
 | ||||
|  | #include "api.h" | ||||
|  | 
 | ||||
|  | #define BIN_FILE_PATH "binFilePath" | ||||
|  | #define FPGA_FILE_PATH "fpgaFilePath" | ||||
|  | #define BIN_OFFSET    "binOffset" | ||||
|  | #define BIN_BAR_INDEX "binBarIndex" | ||||
|  | #define REG_ACCESS_SEL "regAccessType" | ||||
|  | 
 | ||||
|  | 
 | ||||
|  | QT_BEGIN_NAMESPACE | ||||
|  | namespace Ui { class MainWindow; } | ||||
|  | QT_END_NAMESPACE | ||||
|  | 
 | ||||
|  | class MainWindow : public QMainWindow | ||||
|  | { | ||||
|  |     Q_OBJECT | ||||
|  | 
 | ||||
|  | public: | ||||
|  |     MainWindow(QWidget *parent = nullptr); | ||||
|  |     ~MainWindow(); | ||||
|  | 
 | ||||
|  | private slots: | ||||
|  |     void on_btn_browse_clicked(); | ||||
|  | 
 | ||||
|  |     void on_btn_binUpload_clicked(); | ||||
|  | 
 | ||||
|  |     void on_btn_binVerify_clicked(); | ||||
|  | 
 | ||||
|  |     void on_rbtn_reg_toggled(bool checked); | ||||
|  | 
 | ||||
|  |     void on_rbtn_offset_toggled(bool checked); | ||||
|  | 
 | ||||
|  |     void on_btn_readReg_clicked(); | ||||
|  | 
 | ||||
|  |     void on_btn_writeReg_clicked(); | ||||
|  | 
 | ||||
|  |     void newBlockProgressValue(int percentage); | ||||
|  | 
 | ||||
|  |     void newFpgaProgressValue(int percentage); | ||||
|  | 
 | ||||
|  |     void newBlockProgressVisibility(bool show); | ||||
|  | 
 | ||||
|  |     void newFpgaProgressVisibility(bool show); | ||||
|  | 
 | ||||
|  |     void on_btn_fpgaBrowse_clicked(); | ||||
|  | 
 | ||||
|  |     void on_btn_fpgaProgram_clicked(); | ||||
|  | 
 | ||||
|  |     void newMessage(QString message); | ||||
|  | 
 | ||||
|  | 
 | ||||
|  | private: | ||||
|  |     Ui::MainWindow *ui; | ||||
|  | 
 | ||||
|  |     QSettings* _settings; | ||||
|  | 
 | ||||
|  |     UltraSoundDevice* _usd; | ||||
|  | 
 | ||||
|  |     void binaryFileUploader(quint32 bar, quint32 offset, QString path); | ||||
|  |     void binaryFileVerifier(quint32 bar, quint32 offset, QString path); | ||||
|  |     void fpgaProgrammer(quint32 bar, quint32 offset, QString path); | ||||
|  |     quint32 byteArrayTo32LittleEndian(QByteArray data); | ||||
|  |     quint32 byteArrayTo32BigEndian(QByteArray data); | ||||
|  | 
 | ||||
|  | signals: | ||||
|  |     void updateBlockProgressValue(int percentage); | ||||
|  |     void updateFpgaProgressValue(int percentage); | ||||
|  |     void updateBlockProgressVisibility(bool show); | ||||
|  |     void updateFpgaProgressVisibility(bool show); | ||||
|  |     void showMessage(QString message); | ||||
|  | 
 | ||||
|  | }; | ||||
|  | #endif // MAINWINDOW_H
 | ||||
| @ -0,0 +1,432 @@ | |||||
|  | <?xml version="1.0" encoding="UTF-8"?> | ||||
|  | <ui version="4.0"> | ||||
|  |  <class>MainWindow</class> | ||||
|  |  <widget class="QMainWindow" name="MainWindow"> | ||||
|  |   <property name="geometry"> | ||||
|  |    <rect> | ||||
|  |     <x>0</x> | ||||
|  |     <y>0</y> | ||||
|  |     <width>800</width> | ||||
|  |     <height>487</height> | ||||
|  |    </rect> | ||||
|  |   </property> | ||||
|  |   <property name="sizePolicy"> | ||||
|  |    <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> | ||||
|  |     <horstretch>0</horstretch> | ||||
|  |     <verstretch>0</verstretch> | ||||
|  |    </sizepolicy> | ||||
|  |   </property> | ||||
|  |   <property name="windowTitle"> | ||||
|  |    <string>HW TESTER</string> | ||||
|  |   </property> | ||||
|  |   <widget class="QWidget" name="centralwidget"> | ||||
|  |    <widget class="QWidget" name="layoutWidget"> | ||||
|  |     <property name="geometry"> | ||||
|  |      <rect> | ||||
|  |       <x>10</x> | ||||
|  |       <y>0</y> | ||||
|  |       <width>781</width> | ||||
|  |       <height>461</height> | ||||
|  |      </rect> | ||||
|  |     </property> | ||||
|  |     <layout class="QVBoxLayout" name="verticalLayout_4"> | ||||
|  |      <item> | ||||
|  |       <widget class="QGroupBox" name="groupBox"> | ||||
|  |        <property name="title"> | ||||
|  |         <string>Block operation</string> | ||||
|  |        </property> | ||||
|  |        <widget class="QWidget" name="layoutWidget_2"> | ||||
|  |         <property name="geometry"> | ||||
|  |          <rect> | ||||
|  |           <x>10</x> | ||||
|  |           <y>30</y> | ||||
|  |           <width>761</width> | ||||
|  |           <height>27</height> | ||||
|  |          </rect> | ||||
|  |         </property> | ||||
|  |         <layout class="QHBoxLayout" name="horizontalLayout"> | ||||
|  |          <item> | ||||
|  |           <widget class="QLabel" name="label"> | ||||
|  |            <property name="text"> | ||||
|  |             <string>File to Upload:</string> | ||||
|  |            </property> | ||||
|  |           </widget> | ||||
|  |          </item> | ||||
|  |          <item> | ||||
|  |           <widget class="QLineEdit" name="tb_binFile"/> | ||||
|  |          </item> | ||||
|  |          <item> | ||||
|  |           <widget class="QPushButton" name="btn_browse"> | ||||
|  |            <property name="text"> | ||||
|  |             <string>Browse...</string> | ||||
|  |            </property> | ||||
|  |           </widget> | ||||
|  |          </item> | ||||
|  |         </layout> | ||||
|  |        </widget> | ||||
|  |        <widget class="QLabel" name="tb_binBarNum"> | ||||
|  |         <property name="geometry"> | ||||
|  |          <rect> | ||||
|  |           <x>17</x> | ||||
|  |           <y>70</y> | ||||
|  |           <width>27</width> | ||||
|  |           <height>25</height> | ||||
|  |          </rect> | ||||
|  |         </property> | ||||
|  |         <property name="text"> | ||||
|  |          <string>Bar:</string> | ||||
|  |         </property> | ||||
|  |        </widget> | ||||
|  |        <widget class="QComboBox" name="cb_binBarNum"> | ||||
|  |         <property name="geometry"> | ||||
|  |          <rect> | ||||
|  |           <x>70</x> | ||||
|  |           <y>70</y> | ||||
|  |           <width>41</width> | ||||
|  |           <height>25</height> | ||||
|  |          </rect> | ||||
|  |         </property> | ||||
|  |         <item> | ||||
|  |          <property name="text"> | ||||
|  |           <string>0</string> | ||||
|  |          </property> | ||||
|  |         </item> | ||||
|  |         <item> | ||||
|  |          <property name="text"> | ||||
|  |           <string>1</string> | ||||
|  |          </property> | ||||
|  |         </item> | ||||
|  |         <item> | ||||
|  |          <property name="text"> | ||||
|  |           <string>2</string> | ||||
|  |          </property> | ||||
|  |         </item> | ||||
|  |        </widget> | ||||
|  |        <widget class="QLineEdit" name="tb_binOffset"> | ||||
|  |         <property name="geometry"> | ||||
|  |          <rect> | ||||
|  |           <x>90</x> | ||||
|  |           <y>100</y> | ||||
|  |           <width>91</width> | ||||
|  |           <height>25</height> | ||||
|  |          </rect> | ||||
|  |         </property> | ||||
|  |        </widget> | ||||
|  |        <widget class="QLabel" name="label_2"> | ||||
|  |         <property name="geometry"> | ||||
|  |          <rect> | ||||
|  |           <x>20</x> | ||||
|  |           <y>100</y> | ||||
|  |           <width>71</width> | ||||
|  |           <height>25</height> | ||||
|  |          </rect> | ||||
|  |         </property> | ||||
|  |         <property name="text"> | ||||
|  |          <string>Offset: 0x</string> | ||||
|  |         </property> | ||||
|  |        </widget> | ||||
|  |        <widget class="QProgressBar" name="prg_binUpload"> | ||||
|  |         <property name="geometry"> | ||||
|  |          <rect> | ||||
|  |           <x>250</x> | ||||
|  |           <y>100</y> | ||||
|  |           <width>361</width> | ||||
|  |           <height>25</height> | ||||
|  |          </rect> | ||||
|  |         </property> | ||||
|  |         <property name="sizePolicy"> | ||||
|  |          <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> | ||||
|  |           <horstretch>1</horstretch> | ||||
|  |           <verstretch>0</verstretch> | ||||
|  |          </sizepolicy> | ||||
|  |         </property> | ||||
|  |         <property name="value"> | ||||
|  |          <number>24</number> | ||||
|  |         </property> | ||||
|  |        </widget> | ||||
|  |        <widget class="QWidget" name="layoutWidget"> | ||||
|  |         <property name="geometry"> | ||||
|  |          <rect> | ||||
|  |           <x>690</x> | ||||
|  |           <y>70</y> | ||||
|  |           <width>82</width> | ||||
|  |           <height>58</height> | ||||
|  |          </rect> | ||||
|  |         </property> | ||||
|  |         <layout class="QVBoxLayout" name="verticalLayout"> | ||||
|  |          <item> | ||||
|  |           <widget class="QPushButton" name="btn_binVerify"> | ||||
|  |            <property name="text"> | ||||
|  |             <string>Verify</string> | ||||
|  |            </property> | ||||
|  |           </widget> | ||||
|  |          </item> | ||||
|  |          <item> | ||||
|  |           <widget class="QPushButton" name="btn_binUpload"> | ||||
|  |            <property name="text"> | ||||
|  |             <string>Upload</string> | ||||
|  |            </property> | ||||
|  |           </widget> | ||||
|  |          </item> | ||||
|  |         </layout> | ||||
|  |        </widget> | ||||
|  |       </widget> | ||||
|  |      </item> | ||||
|  |      <item> | ||||
|  |       <widget class="Line" name="line"> | ||||
|  |        <property name="orientation"> | ||||
|  |         <enum>Qt::Horizontal</enum> | ||||
|  |        </property> | ||||
|  |       </widget> | ||||
|  |      </item> | ||||
|  |      <item> | ||||
|  |       <widget class="QGroupBox" name="groupBox_2"> | ||||
|  |        <property name="title"> | ||||
|  |         <string>Register operation</string> | ||||
|  |        </property> | ||||
|  |        <widget class="QGroupBox" name="groupBox_3"> | ||||
|  |         <property name="geometry"> | ||||
|  |          <rect> | ||||
|  |           <x>610</x> | ||||
|  |           <y>30</y> | ||||
|  |           <width>161</width> | ||||
|  |           <height>80</height> | ||||
|  |          </rect> | ||||
|  |         </property> | ||||
|  |         <property name="title"> | ||||
|  |          <string>Access registers by:</string> | ||||
|  |         </property> | ||||
|  |         <widget class="QRadioButton" name="rbtn_offset"> | ||||
|  |          <property name="geometry"> | ||||
|  |           <rect> | ||||
|  |            <x>10</x> | ||||
|  |            <y>50</y> | ||||
|  |            <width>131</width> | ||||
|  |            <height>23</height> | ||||
|  |           </rect> | ||||
|  |          </property> | ||||
|  |          <property name="text"> | ||||
|  |           <string>Register offset</string> | ||||
|  |          </property> | ||||
|  |         </widget> | ||||
|  |         <widget class="QRadioButton" name="rbtn_reg"> | ||||
|  |          <property name="geometry"> | ||||
|  |           <rect> | ||||
|  |            <x>10</x> | ||||
|  |            <y>30</y> | ||||
|  |            <width>141</width> | ||||
|  |            <height>23</height> | ||||
|  |           </rect> | ||||
|  |          </property> | ||||
|  |          <property name="text"> | ||||
|  |           <string>Register number</string> | ||||
|  |          </property> | ||||
|  |         </widget> | ||||
|  |        </widget> | ||||
|  |        <widget class="QWidget" name="layoutWidget"> | ||||
|  |         <property name="geometry"> | ||||
|  |          <rect> | ||||
|  |           <x>12</x> | ||||
|  |           <y>32</y> | ||||
|  |           <width>181</width> | ||||
|  |           <height>91</height> | ||||
|  |          </rect> | ||||
|  |         </property> | ||||
|  |         <layout class="QVBoxLayout" name="verticalLayout_3"> | ||||
|  |          <item> | ||||
|  |           <widget class="QLabel" name="l_regIndicator"> | ||||
|  |            <property name="text"> | ||||
|  |             <string>:</string> | ||||
|  |            </property> | ||||
|  |           </widget> | ||||
|  |          </item> | ||||
|  |          <item> | ||||
|  |           <widget class="QLabel" name="label_4"> | ||||
|  |            <property name="text"> | ||||
|  |             <string>Value: (Hex)</string> | ||||
|  |            </property> | ||||
|  |           </widget> | ||||
|  |          </item> | ||||
|  |          <item> | ||||
|  |           <widget class="QLabel" name="label_3"> | ||||
|  |            <property name="sizePolicy"> | ||||
|  |             <sizepolicy hsizetype="Fixed" vsizetype="Preferred"> | ||||
|  |              <horstretch>0</horstretch> | ||||
|  |              <verstretch>0</verstretch> | ||||
|  |             </sizepolicy> | ||||
|  |            </property> | ||||
|  |            <property name="text"> | ||||
|  |             <string>Read result: (Hex)</string> | ||||
|  |            </property> | ||||
|  |           </widget> | ||||
|  |          </item> | ||||
|  |         </layout> | ||||
|  |        </widget> | ||||
|  |        <widget class="QWidget" name="layoutWidget"> | ||||
|  |         <property name="geometry"> | ||||
|  |          <rect> | ||||
|  |           <x>200</x> | ||||
|  |           <y>30</y> | ||||
|  |           <width>232</width> | ||||
|  |           <height>95</height> | ||||
|  |          </rect> | ||||
|  |         </property> | ||||
|  |         <layout class="QVBoxLayout" name="verticalLayout_2"> | ||||
|  |          <item> | ||||
|  |           <layout class="QHBoxLayout" name="horizontalLayout_4"> | ||||
|  |            <item> | ||||
|  |             <widget class="QLineEdit" name="tb_regIndicator"/> | ||||
|  |            </item> | ||||
|  |            <item> | ||||
|  |             <widget class="QLabel" name="tb_binBarNum_2"> | ||||
|  |              <property name="text"> | ||||
|  |               <string>Bar:</string> | ||||
|  |              </property> | ||||
|  |             </widget> | ||||
|  |            </item> | ||||
|  |            <item> | ||||
|  |             <widget class="QComboBox" name="cb_regBarNum"> | ||||
|  |              <item> | ||||
|  |               <property name="text"> | ||||
|  |                <string>0</string> | ||||
|  |               </property> | ||||
|  |              </item> | ||||
|  |              <item> | ||||
|  |               <property name="text"> | ||||
|  |                <string>1</string> | ||||
|  |               </property> | ||||
|  |              </item> | ||||
|  |              <item> | ||||
|  |               <property name="text"> | ||||
|  |                <string>2</string> | ||||
|  |               </property> | ||||
|  |              </item> | ||||
|  |             </widget> | ||||
|  |            </item> | ||||
|  |           </layout> | ||||
|  |          </item> | ||||
|  |          <item> | ||||
|  |           <layout class="QHBoxLayout" name="horizontalLayout_3"> | ||||
|  |            <item> | ||||
|  |             <widget class="QLineEdit" name="tb_regValue"/> | ||||
|  |            </item> | ||||
|  |            <item> | ||||
|  |             <widget class="QPushButton" name="btn_writeReg"> | ||||
|  |              <property name="text"> | ||||
|  |               <string>Write</string> | ||||
|  |              </property> | ||||
|  |             </widget> | ||||
|  |            </item> | ||||
|  |           </layout> | ||||
|  |          </item> | ||||
|  |          <item> | ||||
|  |           <layout class="QHBoxLayout" name="horizontalLayout_2"> | ||||
|  |            <item> | ||||
|  |             <widget class="QLCDNumber" name="lcd_regvalue"/> | ||||
|  |            </item> | ||||
|  |            <item> | ||||
|  |             <widget class="QPushButton" name="btn_readReg"> | ||||
|  |              <property name="sizePolicy"> | ||||
|  |               <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> | ||||
|  |                <horstretch>0</horstretch> | ||||
|  |                <verstretch>0</verstretch> | ||||
|  |               </sizepolicy> | ||||
|  |              </property> | ||||
|  |              <property name="text"> | ||||
|  |               <string>Read</string> | ||||
|  |              </property> | ||||
|  |             </widget> | ||||
|  |            </item> | ||||
|  |           </layout> | ||||
|  |          </item> | ||||
|  |         </layout> | ||||
|  |        </widget> | ||||
|  |       </widget> | ||||
|  |      </item> | ||||
|  |      <item> | ||||
|  |       <widget class="Line" name="line_2"> | ||||
|  |        <property name="orientation"> | ||||
|  |         <enum>Qt::Horizontal</enum> | ||||
|  |        </property> | ||||
|  |       </widget> | ||||
|  |      </item> | ||||
|  |      <item> | ||||
|  |       <widget class="QGroupBox" name="groupBox_4"> | ||||
|  |        <property name="title"> | ||||
|  |         <string>FPGA Program:</string> | ||||
|  |        </property> | ||||
|  |        <widget class="QWidget" name="layoutWidget"> | ||||
|  |         <property name="geometry"> | ||||
|  |          <rect> | ||||
|  |           <x>10</x> | ||||
|  |           <y>30</y> | ||||
|  |           <width>761</width> | ||||
|  |           <height>27</height> | ||||
|  |          </rect> | ||||
|  |         </property> | ||||
|  |         <layout class="QHBoxLayout" name="horizontalLayout_5"> | ||||
|  |          <item> | ||||
|  |           <widget class="QLabel" name="label_5"> | ||||
|  |            <property name="text"> | ||||
|  |             <string>Bit file:</string> | ||||
|  |            </property> | ||||
|  |           </widget> | ||||
|  |          </item> | ||||
|  |          <item> | ||||
|  |           <widget class="QLineEdit" name="tb_fpgaBit"/> | ||||
|  |          </item> | ||||
|  |          <item> | ||||
|  |           <widget class="QPushButton" name="btn_fpgaBrowse"> | ||||
|  |            <property name="text"> | ||||
|  |             <string>Browse...</string> | ||||
|  |            </property> | ||||
|  |           </widget> | ||||
|  |          </item> | ||||
|  |         </layout> | ||||
|  |        </widget> | ||||
|  |        <widget class="QPushButton" name="btn_fpgaProgram"> | ||||
|  |         <property name="geometry"> | ||||
|  |          <rect> | ||||
|  |           <x>690</x> | ||||
|  |           <y>71</y> | ||||
|  |           <width>80</width> | ||||
|  |           <height>25</height> | ||||
|  |          </rect> | ||||
|  |         </property> | ||||
|  |         <property name="text"> | ||||
|  |          <string>Program</string> | ||||
|  |         </property> | ||||
|  |        </widget> | ||||
|  |        <widget class="QProgressBar" name="prg_fpgaProgram"> | ||||
|  |         <property name="geometry"> | ||||
|  |          <rect> | ||||
|  |           <x>11</x> | ||||
|  |           <y>71</y> | ||||
|  |           <width>671</width> | ||||
|  |           <height>25</height> | ||||
|  |          </rect> | ||||
|  |         </property> | ||||
|  |         <property name="value"> | ||||
|  |          <number>24</number> | ||||
|  |         </property> | ||||
|  |        </widget> | ||||
|  |       </widget> | ||||
|  |      </item> | ||||
|  |     </layout> | ||||
|  |    </widget> | ||||
|  |   </widget> | ||||
|  |   <widget class="QMenuBar" name="menubar"> | ||||
|  |    <property name="geometry"> | ||||
|  |     <rect> | ||||
|  |      <x>0</x> | ||||
|  |      <y>0</y> | ||||
|  |      <width>800</width> | ||||
|  |      <height>22</height> | ||||
|  |     </rect> | ||||
|  |    </property> | ||||
|  |   </widget> | ||||
|  |   <widget class="QStatusBar" name="statusbar"/> | ||||
|  |  </widget> | ||||
|  |  <resources/> | ||||
|  |  <connections/> | ||||
|  | </ui> | ||||
					Loading…
					
					
				
		Reference in new issue