diff --git a/devices/limesdr/devicelimesdr.cpp b/devices/limesdr/devicelimesdr.cpp
index f3508aeaa..a82702b89 100644
--- a/devices/limesdr/devicelimesdr.cpp
+++ b/devices/limesdr/devicelimesdr.cpp
@@ -178,3 +178,118 @@ bool DeviceLimeSDR::SetRBBPGA_dB(lms_device_t *device, std::size_t chan, float v
return true;
}
+
+bool DeviceLimeSDR::setAntennaPath(lms_device_t *device, std::size_t chan, int path)
+{
+// if (LMS_WriteParam(device, LMS7param(MAC), chan+1) < 0)
+// {
+// fprintf(stderr, "DeviceLimeSDR::setAntennaPath: cannot set channel to #%lu\n", chan);
+// return false;
+// }
+//
+// int sel_path_rfe = 0;
+// switch ((PathRFE) path)
+// {
+// case PATH_RFE_NONE: sel_path_rfe = 0; break;
+// case PATH_RFE_LNAH: sel_path_rfe = 1; break;
+// case PATH_RFE_LNAL: sel_path_rfe = 2; break;
+// case PATH_RFE_LNAW: sel_path_rfe = 3; break;
+// case PATH_RFE_LB1: sel_path_rfe = 3; break;
+// case PATH_RFE_LB2: sel_path_rfe = 2; break;
+// }
+//
+// int pd_lna_rfe = 1;
+// switch ((PathRFE) path)
+// {
+// case PATH_RFE_LNAH:
+// case PATH_RFE_LNAL:
+// case PATH_RFE_LNAW: pd_lna_rfe = 0; break;
+// default: break;
+// }
+//
+// int pd_rloopb_1_rfe = (path == (int) PATH_RFE_LB1) ? 0 : 1;
+// int pd_rloopb_2_rfe = (path == (int) PATH_RFE_LB2) ? 0 : 1;
+// int en_inshsw_l_rfe = (path == (int) PATH_RFE_LNAL ) ? 0 : 1;
+// int en_inshsw_w_rfe = (path == (int) PATH_RFE_LNAW) ? 0 : 1;
+// int en_inshsw_lb1_rfe = (path == (int) PATH_RFE_LB1) ? 0 : 1;
+// int en_inshsw_lb2_rfe = (path == (int) PATH_RFE_LB2) ? 0 : 1;
+//
+// int ret = 0;
+//
+// ret += LMS_WriteParam(device, LMS7param(PD_LNA_RFE), pd_lna_rfe);
+// ret += LMS_WriteParam(device, LMS7param(PD_RLOOPB_1_RFE), pd_rloopb_1_rfe);
+// ret += LMS_WriteParam(device, LMS7param(PD_RLOOPB_2_RFE), pd_rloopb_2_rfe);
+// ret += LMS_WriteParam(device, LMS7param(EN_INSHSW_LB1_RFE), en_inshsw_lb1_rfe);
+// ret += LMS_WriteParam(device, LMS7param(EN_INSHSW_LB2_RFE), en_inshsw_lb2_rfe);
+// ret += LMS_WriteParam(device, LMS7param(EN_INSHSW_L_RFE), en_inshsw_l_rfe);
+// ret += LMS_WriteParam(device, LMS7param(EN_INSHSW_W_RFE), en_inshsw_w_rfe);
+// ret += LMS_WriteParam(device, LMS7param(SEL_PATH_RFE), sel_path_rfe);
+//
+// if (ret < 0)
+// {
+// fprintf(stderr, "DeviceLimeSDR::setAntennaPath: cannot set channel #%lu to %d\n", chan, path);
+// return false;
+// }
+//
+// //enable/disable the loopback path
+// const bool loopback = (path == (int) PATH_RFE_LB1) or (path == (int) PATH_RFE_LB2);
+//
+// if (LMS_WriteParam(device, LMS7param(EN_LOOPB_TXPAD_TRF), loopback ? 1 : 0) < 0)
+// {
+// fprintf(stderr, "DeviceLimeSDR::setAntennaPath: cannot %sset loopback on channel #%lu\n", loopback ? "" : "re", chan);
+// return false;
+// }
+//
+// //update external band-selection to match
+// //this->UpdateExternalBandSelect();
+//
+// return true;
+
+ switch ((PathRFE) path)
+ {
+ case PATH_RFE_LNAH:
+ if (LMS_SetAntenna(device, LMS_CH_RX, chan, 1) < 0)
+ {
+ fprintf(stderr, "DeviceLimeSDR::setAntennaPath: 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");
+ return false;
+ }
+ break;
+ case PATH_RFE_LNAW:
+ if (LMS_SetAntenna(device, LMS_CH_RX, chan, 2) < 0)
+ {
+ fprintf(stderr, "DeviceLimeSDR::setAntennaPath: 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");
+ 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");
+ return false;
+ }
+ break;
+ case PATH_RFE_NONE:
+ default:
+ if (LMS_SetAntenna(device, LMS_CH_RX, chan, 0) < 0)
+ {
+ fprintf(stderr, "DeviceLimeSDR::setAntennaPath: cannot set to none\n");
+ return false;
+ }
+ }
+
+ return true;
+}
diff --git a/devices/limesdr/devicelimesdr.h b/devices/limesdr/devicelimesdr.h
index 7422d41e4..a3624b72f 100644
--- a/devices/limesdr/devicelimesdr.h
+++ b/devices/limesdr/devicelimesdr.h
@@ -22,6 +22,16 @@
class DeviceLimeSDR
{
public:
+ enum PathRFE
+ {
+ PATH_RFE_NONE = 0,
+ PATH_RFE_LNAH,
+ PATH_RFE_LNAL,
+ PATH_RFE_LNAW,
+ PATH_RFE_LB1,
+ PATH_RFE_LB2
+ };
+
/** 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) **/
@@ -30,6 +40,8 @@ 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 **/
+ static bool setAntennaPath(lms_device_t *device, std::size_t chan, int path);
};
#endif /* DEVICES_LIMESDR_DEVICELIMESDR_H_ */
diff --git a/plugins/samplesource/limesdrinput/limesdrinput.cpp b/plugins/samplesource/limesdrinput/limesdrinput.cpp
index 37ca06e0a..bda8df300 100644
--- a/plugins/samplesource/limesdrinput/limesdrinput.cpp
+++ b/plugins/samplesource/limesdrinput/limesdrinput.cpp
@@ -453,6 +453,7 @@ bool LimeSDRInput::applySettings(const LimeSDRInputSettings& settings, bool forc
bool suspendRxThread = false;
bool suspendAllThread = false;
bool doCalibration = false;
+ bool setAntennaAuto = false;
// QMutexLocker mutexLocker(&m_mutex);
// determine if buddies threads or own thread need to be suspended
@@ -468,12 +469,19 @@ bool LimeSDRInput::applySettings(const LimeSDRInputSettings& settings, bool forc
suspendRxThread = true;
}
+ if ((m_settings.m_antennaPath != settings.m_antennaPath) &&
+ (m_settings.m_antennaPath == 0))
+ {
+ suspendRxThread = true;
+ }
+
if ((m_settings.m_gain != settings.m_gain) ||
(m_settings.m_lpfBW != settings.m_lpfBW) ||
(m_settings.m_lpfFIRBW != settings.m_lpfFIRBW) ||
(m_settings.m_lpfFIREnable != settings.m_lpfFIREnable) ||
(m_settings.m_ncoEnable != settings.m_ncoEnable) ||
- (m_settings.m_ncoFrequency != settings.m_ncoFrequency) || force)
+ (m_settings.m_ncoFrequency != settings.m_ncoFrequency) ||
+ (m_settings.m_antennaPath != settings.m_antennaPath) || force)
{
suspendOwnThread = true;
}
@@ -694,7 +702,30 @@ bool LimeSDRInput::applySettings(const LimeSDRInputSettings& settings, bool forc
}
}
- if ((m_settings.m_centerFrequency != settings.m_centerFrequency) || force)
+ 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::setAntennaPath(m_deviceShared.m_deviceParams->getDevice(),
+ m_deviceShared.m_channel,
+ m_settings.m_antennaPath))
+ {
+ doCalibration = true;
+ setAntennaAuto = (m_settings.m_antennaPath == 0);
+ 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) || setAntennaAuto || force)
{
m_settings.m_centerFrequency = settings.m_centerFrequency;
forwardChangeRxDSP = true;
diff --git a/plugins/samplesource/limesdrinput/limesdrinputgui.cpp b/plugins/samplesource/limesdrinput/limesdrinputgui.cpp
index ed9e4faff..274104104 100644
--- a/plugins/samplesource/limesdrinput/limesdrinputgui.cpp
+++ b/plugins/samplesource/limesdrinput/limesdrinputgui.cpp
@@ -458,3 +458,9 @@ void LimeSDRInputGUI::on_gain_valueChanged(int value)
ui->gainText->setText(tr("%1dB").arg(m_settings.m_gain));
sendSettings();
}
+
+void LimeSDRInputGUI::on_antenna_currentIndexChanged(int index)
+{
+ m_settings.m_antennaPath = (LimeSDRInputSettings::PathRFE) index;
+ sendSettings();
+}
diff --git a/plugins/samplesource/limesdrinput/limesdrinputgui.h b/plugins/samplesource/limesdrinput/limesdrinputgui.h
index 03dbe02b6..dee2fc795 100644
--- a/plugins/samplesource/limesdrinput/limesdrinputgui.h
+++ b/plugins/samplesource/limesdrinput/limesdrinputgui.h
@@ -87,6 +87,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();
diff --git a/plugins/samplesource/limesdrinput/limesdrinputgui.ui b/plugins/samplesource/limesdrinput/limesdrinputgui.ui
index 4afc0564a..d206c98b3 100644
--- a/plugins/samplesource/limesdrinput/limesdrinputgui.ui
+++ b/plugins/samplesource/limesdrinput/limesdrinputgui.ui
@@ -647,6 +647,59 @@
+ -
+
+
+ :/antenna.png
+
+
+
+ -
+
+
+
+ 50
+ 0
+
+
+
+
+ 50
+ 16777215
+
+
+
-
+
+ Au
+
+
+ -
+
+ Hi
+
+
+ -
+
+ Lo
+
+
+ -
+
+ Wi
+
+
+ -
+
+ T1
+
+
+ -
+
+ T2
+
+
+
+
-
diff --git a/plugins/samplesource/limesdrinput/limesdrinputsettings.cpp b/plugins/samplesource/limesdrinput/limesdrinputsettings.cpp
index d3d314f21..3af15c60e 100644
--- a/plugins/samplesource/limesdrinput/limesdrinputsettings.cpp
+++ b/plugins/samplesource/limesdrinput/limesdrinputsettings.cpp
@@ -36,6 +36,7 @@ void LimeSDRInputSettings::resetToDefaults()
m_gain = 30;
m_ncoEnable = false;
m_ncoFrequency = 0;
+ m_antennaPath = PATH_RFE_NONE;
}
QByteArray LimeSDRInputSettings::serialize() const
diff --git a/plugins/samplesource/limesdrinput/limesdrinputsettings.h b/plugins/samplesource/limesdrinput/limesdrinputsettings.h
index 7b51dffe9..09d685f1e 100644
--- a/plugins/samplesource/limesdrinput/limesdrinputsettings.h
+++ b/plugins/samplesource/limesdrinput/limesdrinputsettings.h
@@ -32,6 +32,16 @@ struct LimeSDRInputSettings
FC_POS_CENTER
} fcPos_t;
+ enum PathRFE
+ {
+ PATH_RFE_NONE = 0,
+ PATH_RFE_LNAH,
+ PATH_RFE_LNAL,
+ PATH_RFE_LNAW,
+ PATH_RFE_LB1,
+ PATH_RFE_LB2
+ };
+
// global settings to be saved
uint64_t m_centerFrequency;
int m_devSampleRate;
@@ -46,6 +56,7 @@ struct LimeSDRInputSettings
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;
LimeSDRInputSettings();
void resetToDefaults();
diff --git a/sdrbase/resources/antenna.png b/sdrbase/resources/antenna.png
new file mode 100644
index 000000000..fbca9801f
Binary files /dev/null and b/sdrbase/resources/antenna.png differ
diff --git a/sdrbase/resources/res.qrc b/sdrbase/resources/res.qrc
index 0385793de..c3b1d4cd6 100644
--- a/sdrbase/resources/res.qrc
+++ b/sdrbase/resources/res.qrc
@@ -77,5 +77,6 @@
camera.png
filter_bandpass.png
stream.png
+ antenna.png