You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

161 lines
4.4 KiB

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