Browse Source

qbyteArray2UintLittleEndian function is added

master
Arash Aletayeb 4 years ago
parent
commit
541548d595
  1. 9
      developHw.pro
  2. 2
      developHw.pro.user
  3. 5
      include/model/hardware/core/TrxBoard.h
  4. 2
      include/model/hardware/core/register/fpgaProgram/registerDefinition/SlaveFpgaNumber.h
  5. 1
      include/model/hardware/device/SonoDeviceConstant.h
  6. 25
      mainwindow.cpp
  7. 4
      mainwindow.h
  8. 6
      mainwindow.ui
  9. 38
      src/model/hardware/core/TrxBoard.cpp
  10. 4
      src/model/hardware/core/register/fpgaProgram/FpgaProgram.cpp

9
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

2
developHw.pro.user

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.10.0, 2021-05-29T16:09:18. -->
<!-- Written by QtCreator 4.10.0, 2021-05-31T15:52:50. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>

5
include/model/hardware/core/TrxBoard.h

@ -40,6 +40,9 @@
#define EEPROM_INFO_BYTE_NUMBER 19U
template<class T>
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();

2
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

1
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

25
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;
// }
}

4
mainwindow.h

@ -14,10 +14,14 @@
#include <QFileDialog>
#include <QColormap>
#include <QProgressDialog>
#include <iostream>
#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)

6
mainwindow.ui

@ -27,7 +27,7 @@
<string/>
</property>
<property name="currentIndex">
<number>2</number>
<number>1</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="title">
@ -764,12 +764,12 @@
<rect>
<x>380</x>
<y>30</y>
<width>90</width>
<width>94</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>Pwrdn Enable</string>
<string>Pwrdn Disable</string>
</property>
</widget>
<widget class="QPushButton" name="btn_afeConfig">

38
src/model/hardware/core/TrxBoard.cpp

@ -1,5 +1,16 @@
#include "model/hardware/core/TrxBoard.h"
template<class T>
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<quint32>(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)
@ -483,7 +505,7 @@ void TrxBoard::setMetaData(const QByteArray metaData) const
temp.append(metaData[j+num]);
}
data.push_back(byteArray2UintBigEndian <quint64>(temp));
data.push_back(byteArray2UintLittleEndian <quint64>(temp));
temp.clear();
num += sizeof (quint64);
}
@ -519,6 +541,7 @@ QList<quint32> 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<quint32> 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<quint32> 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<quint32>(num), byteArray2UintBigEndian <quint64>(temp));
this->_device.device.writeLong(BAR_SRAM, static_cast<quint32>(num), byteArray2UintLittleEndian <quint64>(temp));
temp.clear();
num += sizeof (quint64);
}
@ -960,3 +981,8 @@ void TrxBoard::getFpgasCodeVersion(FpgaCodeVersion* version) const
{
this->_misc->getFpgaVersion(version);
}
void TrxBoard::sramParityClear()
{
this->_device.device.writeLong(BAR_SRAM, 0, 0);
}

4
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++)

Loading…
Cancel
Save