diff --git a/developHw.pro b/developHw.pro index fd00498..fa1dbc7 100644 --- a/developHw.pro +++ b/developHw.pro @@ -29,7 +29,11 @@ HEADERS += \ api.h \ $$files(include/*.h, true) -INCLUDEPATH += "$$PWD/include" +INCLUDEPATH += \ + "$$PWD/include" \ + "/usr/lib/x86_64-linux-gnu/hdf5/serial/include" \ + "/usr/include/hdf5/serial" + FORMS += \ mainwindow.ui @@ -40,3 +44,6 @@ else: unix:!android: target.path = /opt/$${TARGET}/bin !isEmpty(target.path): INSTALLS += target unix|win32: LIBS += -lSonoPcieDevice +unix|win32: LIBS += -L "/usr/lib/x86_64-linux-gnu/hdf5/serial" -lhdf5 +unix|win32: LIBS += -L "/usr/lib/x86_64-linux-gnu/hdf5/serial" -lhdf5_cpp + diff --git a/developHw.pro.user b/developHw.pro.user index 9420378..7951c83 100644 --- a/developHw.pro.user +++ b/developHw.pro.user @@ -1,6 +1,6 @@ - + EnvironmentId diff --git a/include/model/hardware/core/TrxBoard.h b/include/model/hardware/core/TrxBoard.h index d29c164..c383b30 100644 --- a/include/model/hardware/core/TrxBoard.h +++ b/include/model/hardware/core/TrxBoard.h @@ -40,6 +40,9 @@ #define EEPROM_INFO_BYTE_NUMBER 19U +template +T byteArray2UintLittleEndian(QByteArray& byte); + class TrxBoard : public QObject { Q_OBJECT @@ -129,6 +132,7 @@ private: void setScenario(ScenGenHardwareOutput* scenParams); + void sram_clear (void); void setSwapVector(void); void setFpgaOffset(void); void setAfeModuleOffset(void); @@ -208,6 +212,7 @@ public: //////////////////////////////// Miscellaneous API ///////////////////////////////// void getTrxStatus(StatusVec* status) const; void getFpgasCodeVersion(FpgaCodeVersion* version) const; + void sramParityClear(); /////////////////////////////// DMA Data Packet //////////////////////////////////// void readData(); diff --git a/include/model/hardware/core/register/fpgaProgram/registerDefinition/SlaveFpgaNumber.h b/include/model/hardware/core/register/fpgaProgram/registerDefinition/SlaveFpgaNumber.h index fe2ab22..b8b7792 100644 --- a/include/model/hardware/core/register/fpgaProgram/registerDefinition/SlaveFpgaNumber.h +++ b/include/model/hardware/core/register/fpgaProgram/registerDefinition/SlaveFpgaNumber.h @@ -6,7 +6,7 @@ #undef BAR -#define NUMBER_MASK 0x00000003 +#define NUMBER_MASK 0x00000007 #define BAR 0U #define OFFSET 0x408 diff --git a/include/model/hardware/device/SonoDeviceConstant.h b/include/model/hardware/device/SonoDeviceConstant.h index 4639216..0ae2b83 100644 --- a/include/model/hardware/device/SonoDeviceConstant.h +++ b/include/model/hardware/device/SonoDeviceConstant.h @@ -8,6 +8,7 @@ #define SW_BUFFER_NUM 100 #define HW_BUFFER_NUM 16 #define BUFFER_SIZE 4 * 1024 * 1024 +#define SRAM_SIZE 16777216U #define COUNTER_REG 0x00002020 #define RAM_OFFSET_REG 0x00002024 diff --git a/mainwindow.cpp b/mainwindow.cpp index 31b2808..958a810 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -3,6 +3,8 @@ QThread* MainWindow::_uiThread; +//using namespace H5; + MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , ui(new Ui::MainWindow) @@ -3130,9 +3132,32 @@ void MainWindow::setAfeConfig() _afeConfig.pgaClampLevel = minus2dbfs; _afeConfig.activeTermIndRes = actTermIndRes0; _afeConfig.activeTermIndResEn = actTermIndResDisable; + _afeConfig.inputClampLevel = inputClampLvlAuto; } /*************************************************************************************************/ void MainWindow::on_btn_afeConfig_clicked() { _trx.setAfeConfig(_afeConfig); + + int32_t temp[192]; + +// char filePath[] = "/home/hasis/Desktop/Develop_HardwareTest/h5_scenario/scenario.h5"; +// hid_t H5_hid = H5Fcreate (filePath, H5F_ACC_RDONLY, H5P_DEFAULT, H5P_DEFAULT); +// hid_t H5_open = H5Dopen1(H5_hid, "sramParameters/focusTypeNo"); +// status = H5Dread(H5_open, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, temp); + +// const H5std_string filePath("/home/hasis/Desktop/Develop_HardwareTest/h5_scenario/scenario.h5"); +// H5File file(filePath, H5F_ACC_RDONLY); + +// //const H5std_string dataset_type("sramParameters/focusTypeNo"); +// const H5std_string dataset_type("/registerParameters/elementXPositionsQ"); +// DataSet H5_focus = file.openDataSet(dataset_type); + +// H5_focus.read(temp, PredType::NATIVE_INT, H5S_ALL, H5S_ALL); + +// for(auto var: temp) +// { +// qDebug() << var; +// } + } diff --git a/mainwindow.h b/mainwindow.h index e7bd479..b6dab91 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -14,10 +14,14 @@ #include #include #include +#include #include "qcustomplot.h" #include "include/model/hardware/core/TrxBoard.h" #include "api.h" +//#include "H5Cpp.h" +//#include "hdf5.h" +//#include "H5File.h" #define MESSAGE_BOX(M) \ emit showMessage(M) diff --git a/mainwindow.ui b/mainwindow.ui index d852bb6..cadca56 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -27,7 +27,7 @@ - 2 + 1 @@ -764,12 +764,12 @@ 380 30 - 90 + 94 23 - Pwrdn Enable + Pwrdn Disable diff --git a/src/model/hardware/core/TrxBoard.cpp b/src/model/hardware/core/TrxBoard.cpp index 07ddb47..2347981 100644 --- a/src/model/hardware/core/TrxBoard.cpp +++ b/src/model/hardware/core/TrxBoard.cpp @@ -1,5 +1,16 @@ #include "model/hardware/core/TrxBoard.h" +template +T byteArray2UintLittleEndian(QByteArray& byte) +{ + T data; + QDataStream in (byte); + in.setByteOrder(QDataStream::LittleEndian); + in >> data; + + return data; +} + void TrxBoard::readData() { _swCounter = 0; @@ -36,6 +47,16 @@ void TrxBoard::readData() } } +void TrxBoard::sram_clear() +{ + quint32 num(0); + while (num < SRAM_SIZE) + { + this->_device.device.writeLong(BAR_SRAM, static_cast(num), 0); + num += sizeof (quint64); + } +} + void TrxBoard::scenParamsFilling(TrxBoard::eScenParams cmd) { static quint8 scenParams = 0; @@ -183,6 +204,7 @@ void TrxBoard::init() { this->_device.init(); this->_bCtrlMngt->prbCtrlInit(); + sram_clear(); } void TrxBoard::setScenario(ScenGenHardwareOutput_t scenGenHw) @@ -449,7 +471,7 @@ void TrxBoard::setScenario (ScenGenHardwareOutput* scenParams) { throw SonoException( "The scenario end index must be greater than or equal to the scenario start index"); - } + } } void TrxBoard::setLineFilterCoefficient(QVector& lineFilterLut) @@ -483,7 +505,7 @@ void TrxBoard::setMetaData(const QByteArray metaData) const temp.append(metaData[j+num]); } - data.push_back(byteArray2UintBigEndian (temp)); + data.push_back(byteArray2UintLittleEndian (temp)); temp.clear(); num += sizeof (quint64); } @@ -519,6 +541,7 @@ QList TrxBoard::getAfeReg(eSlaveSelect sel, quint32 afeRegAddr) offset = (_fpgaOffset.at(slave0) + _afeModuleOffset.at(i) + afeRegAddr) * 4; afeRegValue.push_back(this->_device.device.readWord(BAR_REG, offset)); } + this->_afeSlave0->setReadRegEnable(false); break; case slave1 : @@ -528,6 +551,7 @@ QList TrxBoard::getAfeReg(eSlaveSelect sel, quint32 afeRegAddr) offset = (_fpgaOffset.at(slave1) + _afeModuleOffset.at(i) + afeRegAddr) * 4; afeRegValue.push_back(this->_device.device.readWord(BAR_REG, offset)); } + this->_afeSlave1->setReadRegEnable(false); break; case slave2 : @@ -537,13 +561,10 @@ QList TrxBoard::getAfeReg(eSlaveSelect sel, quint32 afeRegAddr) offset = (_fpgaOffset.at(slave2) + _afeModuleOffset.at(i) + afeRegAddr) * 4; afeRegValue.push_back(this->_device.device.readWord(BAR_REG, offset)); } + this->_afeSlave2->setReadRegEnable(false); break; } - this->_afeSlave0->setReadRegEnable(false); - this->_afeSlave1->setReadRegEnable(false); - this->_afeSlave2->setReadRegEnable(false); - return afeRegValue; } @@ -667,7 +688,7 @@ void TrxBoard::fillRam(QString path) temp.append(sramData[j+num]); } - this->_device.device.writeLong(BAR_SRAM, static_cast(num), byteArray2UintBigEndian (temp)); + this->_device.device.writeLong(BAR_SRAM, static_cast(num), byteArray2UintLittleEndian (temp)); temp.clear(); num += sizeof (quint64); } @@ -958,5 +979,10 @@ void TrxBoard::getTrxStatus(StatusVec* status) const void TrxBoard::getFpgasCodeVersion(FpgaCodeVersion* version) const { - this->_misc->getFpgaVersion(version); + this->_misc->getFpgaVersion(version); +} + +void TrxBoard::sramParityClear() +{ + this->_device.device.writeLong(BAR_SRAM, 0, 0); } diff --git a/src/model/hardware/core/register/fpgaProgram/FpgaProgram.cpp b/src/model/hardware/core/register/fpgaProgram/FpgaProgram.cpp index 6e59410..aac17c6 100644 --- a/src/model/hardware/core/register/fpgaProgram/FpgaProgram.cpp +++ b/src/model/hardware/core/register/fpgaProgram/FpgaProgram.cpp @@ -28,6 +28,8 @@ void FpgaProgram::program(QByteArray& bitFileData, quint8 number) quint32 progData(0); QByteArray temp; + setSlaveFpgaNumber(number); + // QProgressDialog progress; // progress.setMinimumSize(300,100); // progress.setLabelText("Please wait..."); @@ -35,8 +37,6 @@ void FpgaProgram::program(QByteArray& bitFileData, quint8 number) // progress.setRange(0,bitFileData.size()); // progress.setModal(true); - setSlaveFpgaNumber(number); - while(progByte < bitFileData.size()) { for(quint8 i(0); i < sizeof(quint32); i++)