Browse Source

mergeMehrabi

heydari
nasicurious 3 years ago
parent
commit
8cd10da063
  1. 3
      Plx/Plx.pro
  2. 11
      Plx/include/LowLevel/HonaLowLevelAPI.h
  3. 50
      Plx/include/LowLevel/Setting/Setting.h
  4. 31
      Plx/include/LowLevel/Utils/Utils.h
  5. 42
      Plx/src/LowLevel/HonaLowLevelAPI.cpp
  6. 140
      Plx/src/Wrapper/PlxWrapper.cpp

3
Plx/Plx.pro

@ -17,7 +17,8 @@ DEFINES += QT_DEPRECATED_WARNINGS
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES += \
$$files(*.cpp, true) \
$$files(*.cpp, true) \ \
src/Wrapper/PlxWrapper.cpp
HEADERS += \

11
Plx/include/LowLevel/HonaLowLevelAPI.h

@ -2,6 +2,9 @@
#define HONALOWLEVELAPI_H
#include <QObject>
#include "include/LowLevel/Setting/Setting.h"
#include "include/LowLevel/HonaPacket.h"
#include "LowLevel/Setting/Setting.h"
#include "HonaPacket.h"
@ -14,6 +17,7 @@ class HonaLowLevelAPI : public QObject
Q_OBJECT
private:
bool _hsruIsStarted;
bool _hiruIsStarted;
HonaSetting _honaSetting;
@ -22,6 +26,8 @@ private:
int _threadSforValue = 0;
bool _isReaderThreadFree = false;
bool _isUpdateThreadFree = false;
quint32 honaRegisterBuffer[8];
public:
@ -29,11 +35,13 @@ public:
bool isHsruStarted();
bool isHiruStarted();
void deviceReset();
void setConfig(HonaSetting* honaSetting);
HonaSetting getConfig();
QString getSwVersion();
QString getDeviceId();
void hsruStart();
void hiruStart();
void init();
@ -44,7 +52,7 @@ public:
void setHiruIsStarted(bool hiruIsStarted);
private:
void writeSettingToRegisters(HonaSetting& honaSetting);
void writeSettingToRegisters(honaSettings& settings);
void setConfig();
void hsruMainThread();
void hsruReadThread();
@ -52,6 +60,7 @@ private:
int hiruGetDOA();
signals:
void signalToTop(QList<HonaPacket*> honaPacketList, int i, int j);
//uncrustify off

50
Plx/include/LowLevel/Setting/Setting.h

@ -2,37 +2,41 @@
#define SETTINGS_H
#include <QtGlobal>
#include <QList>
#include "include/LowLevel/Utils/Utils.h"
#include <QtGlobal>
#include <QList>
#include "include/LowLevel/Utils/Utils.h"
/***********************************************************************************************/
typedef struct _HIRUSETTINGS
struct hiruSettings_t
{
recorderStart recordStard;
recorderMode recordMode;
quint32 recordChannel;
quint32 threshold = 0;
quint32 timeout = 1000;
quint32 count = 5;
}hiruSettings;
recorderStart recordStard;
recorderMode recordMode;
quint32 recordChannel;
quint32 threshold = 0;
quint32 timeout = 1000;
quint32 count = 5;
};
/***********************************************************************************************/
typedef struct _HSRUSETTINGS
struct hsruSettings_t
{
bool isReal = true;
quint32 honaInt123CTHR = 128;
quint32 honaRes123CTHR = 128;
quint32 honaIntSTHR = 20;
quint32 honaResSTHR = 20;
quint32 honaSPTHR = 20; //mode4
quint32 intM4_THR = 20; //mode4
quint32 resM4_THR = 20; //mode4
}hsruSettings;
bool isReal = true;
quint32 honaInt123CTHR = 128;
quint32 honaRes123CTHR = 128;
quint32 honaIntSTHR = 20;
quint32 honaResSTHR = 20;
quint32 honaSPTHR = 20; //mode4
quint32 intM4_THR = 20; //mode4
quint32 resM4_THR = 20; //mode4
};
/***********************************************************************************************/
struct HonaSetting
struct honaSettings
{
quint32 hsruSettings;
quint32 hiruSettings;
};
hiruSettings_t hiruSettings;
hsruSettings_t hsruSettings;
};
/***********************************************************************************************/
#endif //SETTING_H

31
Plx/include/LowLevel/Utils/Utils.h

@ -1,9 +1,9 @@
#ifndef UTILS_H
#define UTILS_H
#include <QtCore>
/*************************************************************************************************/
enum ApiResult
enum apiResult : quint8
{
success,
alreadyStarted,
@ -11,14 +11,14 @@
error
};
/*************************************************************************************************/
typedef enum _DRXDEVICEIFCHANNEL
enum drxDeviceIfChannel : quint8
{
ifChannel11,
ifChannel12
}drxDeviceIfChannel;
};
/*************************************************************************************************/
typedef enum _HONARECEIVERS
enum honaReceivers : quint8
{
int123C,
intS,
@ -26,24 +26,22 @@ typedef enum _HONARECEIVERS
int4, //Mode 4
res4, //Mode 4
signalPulse //Mode 4
}honaReceivers;
};
/*************************************************************************************************/
typedef enum _RECORDERMODE
enum recorderMode : quint8
{
signalChannel,
dualChannel
}recorderMode;
};
/*************************************************************************************************/
typedef enum _RECORDSTART
enum recorderStart : quint8
{
selfTestCounter,
freeRunRecording
}recorderStart;
selfTestCounter= 1,
freeRunRecording = 2
};
/*************************************************************************************************/
typedef enum _HONAPACKETTYPE
enum honaPacketType : quint8
{
interrogationMode123C,
interrogationModeS56,
@ -57,12 +55,11 @@ typedef enum _HONAPACKETTYPE
responseMode4,
signalPulseMode4
}honaPacketType;
};
/*************************************************************************************************/
#endif // UTILS_H

42
Plx/src/LowLevel/HonaLowLevelAPI.cpp

@ -1,9 +1,13 @@
#include "../../include/LowLevel/HonaLowLevelAPI.h"
<<<<<<< HEAD
#include <include/LowLevel/Utils/Utils.h>
#include "include/LowLevel/HonaLowLevelAPI.h"
#include "include/Wrapper/PlxWrapper.h"
#include "qdebug.h"
#include "QTime"
#include "QtConcurrent/QtConcurrent"
PlxWrapper plx;
bool HonaLowLevelAPI::getHsruIsStarted() const
{
@ -101,20 +105,24 @@ QString HonaLowLevelAPI::getSwVersion()
/*************************************************************************************************/
QString HonaLowLevelAPI::getDeviceId()
{
}
/*************************************************************************************************/
void HonaLowLevelAPI::hsruStart()
{
}
/*************************************************************************************************/
void HonaLowLevelAPI::hiruStart()
{
if (isHiruStarted())
//exceptiom
QtConcurrent::run(this,&HonaLowLevelAPI::hsruMainThread);
}
/*************************************************************************************************/
@ -123,8 +131,35 @@ void HonaLowLevelAPI::init()
}
/*************************************************************************************************/
void HonaLowLevelAPI::writeSettingToRegisters(HonaSetting& honaSetting)
void HonaLowLevelAPI::writeSettingToRegisters(honaSettings& settings)
{
honaRegisterBuffer[0] = 0x00000000;
/************************************************************************/
if(settings.hiruSettings.recordStard == recorderStart::selfTestCounter)
honaRegisterBuffer[0] = 0x80000000;
else
honaRegisterBuffer[0] = 0x7FFFFFFF;
/************************************************************************/
if(settings.hiruSettings.recordChannel == drxDeviceIfChannel::ifChannel12)
honaRegisterBuffer[0] = 0x20000000;
else
honaRegisterBuffer[0] = 0xDFFFFFFF;
/************************************************************************/
if(settings.hiruSettings.recordMode == recorderMode::dualChannel)
honaRegisterBuffer[0] = 0x10000000;
else
honaRegisterBuffer[0] = 0xEFFFFFFF;
/************************************************************************/
honaRegisterBuffer[0] += (settings.hiruSettings.threshold & 0x00000FFF);
honaRegisterBuffer[1] = settings.hsruSettings.honaInt123CTHR;
honaRegisterBuffer[2] = settings.hsruSettings.honaRes123CTHR;
honaRegisterBuffer[3] = settings.hsruSettings.honaIntSTHR;
honaRegisterBuffer[4] = settings.hsruSettings.honaResSTHR;
honaRegisterBuffer[5] = settings.hsruSettings.honaSPTHR;
honaRegisterBuffer[6] = settings.hsruSettings.intM4_THR;
honaRegisterBuffer[7] = settings.hsruSettings.resM4_THR;
}
@ -159,14 +194,12 @@ void HonaLowLevelAPI::hsruReadThread()
HsruReadDone.wakeAll();
HsruUpdateAck.wait(&_mutex);
_mutex.unlock();
}
}
/*************************************************************************************************/
void HonaLowLevelAPI::hsruUpdateThread()
{
while (true)
{
_mutex.lock();
@ -178,6 +211,7 @@ void HonaLowLevelAPI::hsruUpdateThread()
HsruUpdateAck.wakeAll();
}
}
/*************************************************************************************************/

140
Plx/src/Wrapper/PlxWrapper.cpp

@ -0,0 +1,140 @@
#include <QDebug>
#include <QVector>
#include "include/Wrapper/PlxWrapper.h"
PlxWrapper::PlxWrapper()
{
}
/*************************************************************************************************/
bool PlxWrapper::deviceInit(quint32 devicekey)
{
return PlxPci_9054_SelDevice(devicekey);
}
/*************************************************************************************************/
bool PlxWrapper::deviceOpen(void)
{
return PlxPci_9054_Open();
}
/*************************************************************************************************/
bool PlxWrapper::deviceClose(void)
{
return PlxPci_9054_Close();
}
/*************************************************************************************************/
bool PlxWrapper::deviceReset(void)
{
return PlxPci_9054_Reset();
}
/*************************************************************************************************/
bool PlxWrapper::deviceLoadE2pToFPGA(void)
{
return PlxPci_9054_LoadE2pToFPGA();
}
/*************************************************************************************************/
bool PlxWrapper::deviceReadEeprom(quint16 offset,quint32 length, QVector<quint32> &data)
{
bool ret = true;
data.clear();
for(auto i = 0U; i < (length-1)*4; i+=4)
{
quint32 temp;
ret &= PlxPci_9054_ReadEep(offset+i, &temp);
data.append(temp);
}
return ret;
}
/*************************************************************************************************/
bool PlxWrapper::deviceWriteEeprom(quint16 offset,quint32 data)
{
return PlxPci_9054_WriteEep(offset,data);
}
/*************************************************************************************************/
bool PlxWrapper::deviceReadRegister(quint32 address,QVector<quint32> &data,quint32 length)
{
bool ret = true;
data.clear();
quint32 temp[length];
ret &= PlxPci_9054_ReadBar(address,&temp,length * 4);
if(ret == true)
{
for(auto i = 0U; i <length; i++)
{
data.append(temp[i]);
qDebug()<<hex<<temp[i];
}
}
return ret;
}
/*************************************************************************************************/
bool PlxWrapper::deviceReadRegister(quint32 address,quint32 &data)
{
return PlxPci_9054_ReadBar(address,&data,4);
}
/*************************************************************************************************/
bool PlxWrapper::deviceWriteRegister(quint32 address,QVector<quint32> &data)
{
bool ret = true;
auto length = data.length();
quint32 temp[length];
for(auto i = 0U; i <length; i++)
temp[i] = data.at(i);
ret &= PlxPci_9054_WriteBar(address,&temp,length * 4);
return ret;
}
/*************************************************************************************************/
bool PlxWrapper::deviceWriteRegister(quint32 address,quint32 data)
{
return PlxPci_9054_WriteBar(address,&data,4);
}
/*************************************************************************************************/
bool PlxWrapper::deviceReadMemory(quint32 localAddress ,QVector<quint32> &data,quint32 length)
{
bool ret = true;
data.clear();
quint32 temp[length];
ret &= PlxPci_9054_DMATransfer(localAddress,&temp,(quint32)(length*4));
for(auto i = 0U; i <length; i++)
data.append(temp[i]);
return ret;
}
/*************************************************************************************************/
bool PlxWrapper::deviceOpenPCIChannel(void)
{
return PlxPci_9054_DMAChannelOpen();
}
/*************************************************************************************************/
bool PlxWrapper::deviceClosePCIChannel(void)
{
return PlxPci_9054_DMAChannelClose();
}
/*************************************************************************************************/
bool PlxWrapper::deviceEnableInterrupt(void)
{
return PlxPci_9054_EnableInterrupt();
}
/*************************************************************************************************/
bool PlxWrapper::deviceDisableInterrupt(void)
{
return PlxPci_9054_DisableInterrupt();
}
/*************************************************************************************************/
bool PlxWrapper::deviceWaitForInterrupt(quint32 timeout)
{
return PlxPci_9054_WaitForInterrupt(timeout);
}
/*************************************************************************************************/
bool PlxWrapper::deviceGetChipType(quint8 revision,quint16 chipType)
{
return PlxPci_9054_ChipTypeGet(revision,chipType);
}
Loading…
Cancel
Save