1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-21 23:55:13 -05:00

LimeSDR output: implemented antenna select

This commit is contained in:
f4exb 2017-05-07 03:05:29 +02:00
parent df9e1d5900
commit 5c8b7fd606
8 changed files with 135 additions and 9 deletions

View File

@ -250,43 +250,73 @@ bool DeviceLimeSDR::setRxAntennaPath(lms_device_t *device, std::size_t chan, int
case PATH_RFE_LNAH:
if (LMS_SetAntenna(device, LMS_CH_RX, chan, 1) < 0)
{
fprintf(stderr, "DeviceLimeSDR::setAntennaPath: cannot set to LNAH\n");
fprintf(stderr, "DeviceLimeSDR::setRxAntennaPath: cannot set to LNAH\n");
return false;
}
break;
case PATH_RFE_LNAL:
if (LMS_SetAntenna(device, LMS_CH_RX, chan, 2) < 0)
{
fprintf(stderr, "DeviceLimeSDR::setAntennaPath: cannot set to LNAL\n");
fprintf(stderr, "DeviceLimeSDR::setRxAntennaPath: cannot set to LNAL\n");
return false;
}
break;
case PATH_RFE_LNAW:
if (LMS_SetAntenna(device, LMS_CH_RX, chan, 3) < 0)
{
fprintf(stderr, "DeviceLimeSDR::setAntennaPath: cannot set to LNAW\n");
fprintf(stderr, "DeviceLimeSDR::setRxAntennaPath: cannot set to LNAW\n");
return false;
}
break;
case PATH_RFE_LB1:
if (LMS_SetAntenna(device, LMS_CH_TX, chan, 1) < 0)
{
fprintf(stderr, "DeviceLimeSDR::setAntennaPath: cannot set to Loopback TX1\n");
fprintf(stderr, "DeviceLimeSDR::setRxAntennaPath: cannot set to Loopback TX1\n");
return false;
}
break;
case PATH_RFE_LB2:
if (LMS_SetAntenna(device, LMS_CH_TX, chan, 2) < 0)
{
fprintf(stderr, "DeviceLimeSDR::setAntennaPath: cannot set to Loopback TX2\n");
fprintf(stderr, "DeviceLimeSDR::setRxAntennaPath: cannot set to Loopback TX2\n");
return false;
}
break;
case PATH_RFE_NONE:
case PATH_RFE_RX_NONE:
default:
if (LMS_SetAntenna(device, LMS_CH_RX, chan, 0) < 0)
{
fprintf(stderr, "DeviceLimeSDR::setAntennaPath: cannot set to none\n");
fprintf(stderr, "DeviceLimeSDR::setRxAntennaPath: cannot set to none\n");
return false;
}
}
return true;
}
bool DeviceLimeSDR::setTxAntennaPath(lms_device_t *device, std::size_t chan, int path)
{
switch ((PathTxRFE) path)
{
case PATH_RFE_TXRF1:
if (LMS_SetAntenna(device, LMS_CH_TX, chan, 1) < 0)
{
fprintf(stderr, "DeviceLimeSDR::setTxAntennaPath: cannot set to TXRF1\n");
return false;
}
break;
case PATH_RFE_TXRF2:
if (LMS_SetAntenna(device, LMS_CH_TX, chan, 2) < 0)
{
fprintf(stderr, "DeviceLimeSDR::setTxAntennaPath: cannot set to TXRF2\n");
return false;
}
break;
case PATH_RFE_TX_NONE:
default:
if (LMS_SetAntenna(device, LMS_CH_TX, chan, 0) < 0)
{
fprintf(stderr, "DeviceLimeSDR::setTxAntennaPath: cannot set to none\n");
return false;
}
}

View File

@ -24,7 +24,7 @@ class DeviceLimeSDR
public:
enum PathRxRFE
{
PATH_RFE_NONE = 0,
PATH_RFE_RX_NONE = 0,
PATH_RFE_LNAH,
PATH_RFE_LNAL,
PATH_RFE_LNAW,
@ -32,6 +32,13 @@ public:
PATH_RFE_LB2
};
enum PathTxRFE
{
PATH_RFE_TX_NONE = 0,
PATH_RFE_TXRF1,
PATH_RFE_TXRF2,
};
/** set NCO frequency with positive or negative frequency (deals with up/down convert). Enables or disables NCO */
static bool setNCOFrequency(lms_device_t *device, bool dir_tx, std::size_t chan, bool enable, float frequency);
/** set LNA gain Range: [1-30] (dB) **/
@ -40,8 +47,10 @@ public:
static bool SetRFETIA_dB(lms_device_t *device, std::size_t chan, int value);
/** set PGA gain Range: [0-32] (dB) **/
static bool SetRBBPGA_dB(lms_device_t *device, std::size_t chan, float value);
/** Set antenna path **/
/** Set Rx antenna path **/
static bool setRxAntennaPath(lms_device_t *device, std::size_t chan, int path);
/** Set Tx antenna path **/
static bool setTxAntennaPath(lms_device_t *device, std::size_t chan, int path);
};
#endif /* DEVICES_LIMESDR_DEVICELIMESDR_H_ */

View File

@ -688,6 +688,28 @@ bool LimeSDROutput::applySettings(const LimeSDROutputSettings& settings, bool fo
}
}
if ((m_settings.m_antennaPath != settings.m_antennaPath) || force)
{
m_settings.m_antennaPath = settings.m_antennaPath;
if (m_deviceShared.m_deviceParams->getDevice() != 0)
{
if (DeviceLimeSDR::setTxAntennaPath(m_deviceShared.m_deviceParams->getDevice(),
m_deviceShared.m_channel,
m_settings.m_antennaPath))
{
doCalibration = true;
qDebug("LimeSDRInput::applySettings: set antenna path to %d",
(int) m_settings.m_antennaPath);
}
else
{
qCritical("LimeSDRInput::applySettings: could not set antenna path to %d",
(int) m_settings.m_antennaPath);
}
}
}
if ((m_settings.m_centerFrequency != settings.m_centerFrequency) || force)
{
m_settings.m_centerFrequency = settings.m_centerFrequency;

View File

@ -258,6 +258,8 @@ void LimeSDROutputGUI::displaySettings()
ui->gain->setValue(m_settings.m_gain);
ui->gainText->setText(tr("%1dB").arg(m_settings.m_gain));
ui->antenna->setCurrentIndex((int) m_settings.m_antennaPath);
setNCODisplay();
}
@ -426,3 +428,9 @@ void LimeSDROutputGUI::on_gain_valueChanged(int value)
ui->gainText->setText(tr("%1dB").arg(m_settings.m_gain));
sendSettings();
}
void LimeSDROutputGUI::on_antenna_currentIndexChanged(int index)
{
m_settings.m_antennaPath = (LimeSDROutputSettings::PathRFE) index;
sendSettings();
}

View File

@ -85,6 +85,7 @@ private slots:
void on_lpFIREnable_toggled(bool checked);
void on_lpFIR_changed(quint64 value);
void on_gain_valueChanged(int value);
void on_antenna_currentIndexChanged(int index);
void updateHardware();
void updateStatus();

View File

@ -612,6 +612,50 @@
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="antennaLabel">
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="../../../sdrbase/resources/res.qrc">:/antenna.png</pixmap>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="antenna">
<property name="minimumSize">
<size>
<width>50</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>50</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>Antenna select: No: none, Lo: 30M:1.9G, Hi: 2:2.6G</string>
</property>
<item>
<property name="text">
<string>No</string>
</property>
</item>
<item>
<property name="text">
<string>Lo</string>
</property>
</item>
<item>
<property name="text">
<string>Hi</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item>

View File

@ -35,6 +35,7 @@ void LimeSDROutputSettings::resetToDefaults()
m_gain = 30;
m_ncoEnable = false;
m_ncoFrequency = 0;
m_antennaPath = PATH_RFE_NONE;
}
QByteArray LimeSDROutputSettings::serialize() const
@ -50,6 +51,7 @@ QByteArray LimeSDROutputSettings::serialize() const
s.writeU32(10, m_gain);
s.writeBool(11, m_ncoEnable);
s.writeS32(12, m_ncoFrequency);
s.writeS32(13, (int) m_antennaPath);
return s.final();
}
@ -77,6 +79,8 @@ bool LimeSDROutputSettings::deserialize(const QByteArray& data)
d.readU32(10, &m_gain, 0);
d.readBool(11, &m_ncoEnable, false);
d.readS32(12, &m_ncoFrequency, 0);
d.readS32(13, &intval, 0);
m_antennaPath = (PathRFE) intval;
return true;
}

View File

@ -32,6 +32,13 @@ struct LimeSDROutputSettings
FC_POS_CENTER
} fcPos_t;
enum PathRFE
{
PATH_RFE_NONE = 0,
PATH_RFE_TXRF1,
PATH_RFE_TXEF2
};
// global settings to be saved
uint64_t m_centerFrequency;
int m_devSampleRate;
@ -44,6 +51,7 @@ struct LimeSDROutputSettings
uint32_t m_gain; //!< Optimally distributed gain (dB)
bool m_ncoEnable; //!< Enable TSP NCO and mixing
int m_ncoFrequency; //!< Actual NCO frequency (the resulting frequency with mixing is displayed)
PathRFE m_antennaPath;
LimeSDROutputSettings();
void resetToDefaults();