1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-16 05:11:49 -05:00

LimeSDR support (12)

This commit is contained in:
f4exb 2017-04-16 19:30:46 +02:00
parent 7c1ff7c5ad
commit 92e7bb8eba
4 changed files with 169 additions and 36 deletions

View File

@ -15,12 +15,14 @@
///////////////////////////////////////////////////////////////////////////////////
#include <QMutexLocker>
#include <QDebug>
#include <cstddef>
#include <string.h>
#include "lime/LimeSuite.h"
#include "device/devicesourceapi.h"
#include "device/devicesinkapi.h"
#include "dsp/dspcommands.h"
#include "limesdrinput.h"
#include "limesdrinputthread.h"
#include "limesdr/devicelimesdrparam.h"
@ -243,3 +245,165 @@ uint32_t LimeSDRInput::getHWLog2Decim() const
return m_deviceShared.m_deviceParams->m_log2OvSRRx;
}
bool LimeSDRInput::handleMessage(const Message& message)
{
if (MsgConfigureLimeSDR::match(message))
{
MsgConfigureLimeSDR& conf = (MsgConfigureLimeSDR&) message;
qDebug() << "LimeSDRInput::handleMessage: MsgConfigureLimeSDR";
if (!applySettings(conf.getSettings(), false))
{
qDebug("LimeSDRInput::handleMessage config error");
}
return true;
}
else
{
return false;
}
}
bool LimeSDRInput::applySettings(const LimeSDRInputSettings& settings, bool force)
{
bool forwardChangeOwnDSP = false;
bool forwardChangeRxDSP = false;
bool forwardChangeAllDSP = false;
// QMutexLocker mutexLocker(&m_mutex);
qDebug() << "LimeSDRInput::applySettings";
if (m_settings.m_dcBlock != settings.m_dcBlock)
{
m_settings.m_dcBlock = settings.m_dcBlock;
m_deviceAPI->configureCorrections(m_settings.m_dcBlock, m_settings.m_iqCorrection);
}
if (m_settings.m_iqCorrection != settings.m_iqCorrection)
{
m_settings.m_iqCorrection = settings.m_iqCorrection;
m_deviceAPI->configureCorrections(m_settings.m_dcBlock, m_settings.m_iqCorrection);
}
if ((m_settings.m_gain != settings.m_gain) || force)
{
m_settings.m_gain = settings.m_gain;
if (m_deviceShared.m_deviceParams->getDevice() != 0)
{
if (LMS_SetGaindB(m_deviceShared.m_deviceParams->getDevice(),
LMS_CH_RX,
m_deviceShared.m_channel,
m_settings.m_gain) < 0)
{
qDebug("LimeSDRInput::applySettings: LMS_SetGaindB() failed");
}
else
{
qDebug() << "LimeSDRInput::applySettings: Gain set to " << m_settings.m_gain;
}
}
}
if ((m_settings.m_devSampleRate != settings.m_devSampleRate)
|| (m_settings.m_log2HardDecim != settings.m_log2HardDecim) || force)
{
forwardChangeRxDSP = m_settings.m_log2HardDecim != settings.m_log2HardDecim;
forwardChangeAllDSP = m_settings.m_devSampleRate != settings.m_devSampleRate;
m_settings.m_devSampleRate = settings.m_devSampleRate;
m_settings.m_log2HardDecim = settings.m_log2HardDecim;
if (m_deviceShared.m_deviceParams->getDevice() != 0)
{
if (LMS_SetSampleRateDir(m_deviceShared.m_deviceParams->getDevice(),
LMS_CH_RX,
m_settings.m_devSampleRate,
1<<m_settings.m_log2HardDecim) < 0)
{
qCritical("LimeSDRInput::applySettings: could not set sample rate to %d with oversampling of %d",
m_settings.m_devSampleRate,
1<<m_settings.m_log2HardDecim);
}
else
{
m_deviceShared.m_deviceParams->m_log2OvSRRx = m_settings.m_log2HardDecim;
m_deviceShared.m_deviceParams->m_sampleRate = m_settings.m_devSampleRate;
qDebug("LimeSDRInput::applySettings: set sample rate set to %d with oversampling of %d",
m_settings.m_devSampleRate,
1<<m_settings.m_log2HardDecim);
}
}
}
if ((m_settings.m_lpfBW != settings.m_lpfBW) || force)
{
m_settings.m_lpfBW = settings.m_lpfBW;
if (m_deviceShared.m_deviceParams->getDevice() != 0)
{
if (LMS_SetLPF(m_deviceShared.m_deviceParams->getDevice(),
LMS_CH_RX,
m_deviceShared.m_channel,
m_settings.m_lpfBW))
{
qCritical("LimeSDRInput::applySettings: could not set LPF to %f Hz", m_settings.m_lpfBW);
}
else
{
qDebug("LimeSDRInput::applySettings: LPF set to %f Hz", m_settings.m_lpfBW);
}
}
}
if ((m_settings.m_log2SoftDecim != settings.m_log2SoftDecim) || force)
{
m_settings.m_log2SoftDecim = settings.m_log2SoftDecim;
forwardChangeOwnDSP = true;
if (m_limeSDRInputThread != 0)
{
m_limeSDRInputThread->setLog2Decimation(m_settings.m_log2SoftDecim);
qDebug() << "LimeSDRInput::applySettings: set soft decimation to " << (1<<m_settings.m_log2SoftDecim);
}
}
if (m_settings.m_centerFrequency != settings.m_centerFrequency)
{
forwardChangeRxDSP = true;
if (m_deviceShared.m_deviceParams->getDevice() != NULL)
{
if (LMS_SetLOFrequency(m_deviceShared.m_deviceParams->getDevice(),
LMS_CH_RX,
m_deviceShared.m_channel, // same for both channels anyway but switches antenna port automatically
m_settings.m_centerFrequency ) != 0)
{
qDebug("LimeSDRInput::applySettings: LMS_SetLOFrequency(%lu) failed", m_settings.m_centerFrequency);
}
}
}
if (forwardChangeAllDSP)
{
}
else if (forwardChangeRxDSP)
{
}
else if (forwardChangeOwnDSP)
{
int sampleRate = m_settings.m_devSampleRate/(1<<(m_settings.m_log2HardDecim + m_settings.m_log2SoftDecim));
DSPSignalNotification *notif = new DSPSignalNotification(sampleRate, m_settings.m_centerFrequency);
m_deviceAPI->getDeviceInputMessageQueue()->push(notif);
}
qDebug() << "LimeSDRInput::applySettings: center freq: " << m_settings.m_centerFrequency << " Hz"
<< " device sample rate: " << m_settings.m_devSampleRate << "S/s"
<< " Actual sample rate: " << m_settings.m_devSampleRate/(1<<m_settings.m_log2SoftDecim) << "S/s";
return true;
}

View File

@ -72,7 +72,7 @@ LimeSDRInputGUI::LimeSDRInputGUI(DeviceSourceAPI *deviceAPI, QWidget* parent) :
m_fileSink = new FileRecord(std::string(recFileNameCStr));
m_deviceAPI->addSink(m_fileSink);
connect(m_deviceAPI->getDeviceOutputMessageQueue(), SIGNAL(messageEnqueued()), this, SLOT(handleMessagesToUI()), Qt::QueuedConnection);
connect(m_deviceAPI->getDeviceOutputMessageQueue(), SIGNAL(messageEnqueued()), this, SLOT(handleMessagesToGUI()), Qt::QueuedConnection);
}
LimeSDRInputGUI::~LimeSDRInputGUI()
@ -134,13 +134,13 @@ bool LimeSDRInputGUI::deserialize(const QByteArray& data)
}
}
void LimeSDRInputGUI::handleMessagesToUI()
void LimeSDRInputGUI::handleMessagesToGUI()
{
Message* message;
while ((message = m_deviceAPI->getDeviceOutputMessageQueue()->pop()) != 0)
{
qDebug("LimeSDRInputGUI::handleDSPMessages: message: %s", message->getIdentifier());
qDebug("LimeSDRInputGUI::handleMessagesToGUI: message: %s", message->getIdentifier());
if (DSPSignalNotification::match(*message))
{
@ -173,7 +173,6 @@ void LimeSDRInputGUI::displaySettings()
ui->hwDecim->setCurrentIndex(m_settings.m_log2HardDecim);
ui->swDecim->setCurrentIndex(m_settings.m_log2SoftDecim);
ui->fcPos->setCurrentIndex((int) m_settings.m_fcPos);
ui->lpf->setValue(m_limeSDRInput->getLPIndex(m_settings.m_lpfFIRBW));
ui->lpfText->setText(tr("%1k").arg(QString::number(m_settings.m_lpfFIRBW / 1000.0f, 'f', 0)));
@ -194,7 +193,7 @@ void LimeSDRInputGUI::sendSettings()
void LimeSDRInputGUI::updateHardware()
{
qDebug() << "BladerfGui::updateHardware";
LimeSDRInput::MsgConfigureLimeSDR* message = LimeSDRInput::MsgConfigureLimeSDR::create( m_settings);
LimeSDRInput::MsgConfigureLimeSDR* message = LimeSDRInput::MsgConfigureLimeSDR::create(m_settings);
m_sampleSource->getInputMessageQueue()->push(message);
m_updateTimer.stop();
}

View File

@ -66,7 +66,7 @@ private:
void updateSampleRateAndFrequency();
private slots:
void handleMessagesToUI();
void handleMessagesToGUI();
void on_startStop_toggled(bool checked);
void on_record_toggled(bool checked);
@ -76,7 +76,6 @@ private slots:
void on_sampleRate_changed(quint64 value);
void on_hwDecim_currentIndexChanged(int index);
void on_swDecim_currentIndexChanged(int index);
void on_fcPos_currentIndexChanged(int index);
void on_lpf_valueChanged(int value);
void on_lpFIREnable_toggled(bool checked);
void on_lpFIR_changed(quint64 value);

View File

@ -401,35 +401,6 @@
</item>
</widget>
</item>
<item>
<widget class="QLabel" name="label_fcPos">
<property name="text">
<string>Fp</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="fcPos">
<property name="toolTip">
<string>Relative position of device center frequency</string>
</property>
<item>
<property name="text">
<string>Inf</string>
</property>
</item>
<item>
<property name="text">
<string>Sup</string>
</property>
</item>
<item>
<property name="text">
<string>Cen</string>
</property>
</item>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_5">
<property name="orientation">