diff --git a/devices/limesdr/devicelimesdr.cpp b/devices/limesdr/devicelimesdr.cpp index 2a36d82ac..1806072c1 100644 --- a/devices/limesdr/devicelimesdr.cpp +++ b/devices/limesdr/devicelimesdr.cpp @@ -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; } } diff --git a/devices/limesdr/devicelimesdr.h b/devices/limesdr/devicelimesdr.h index 7f85f9ba8..8a50ceb94 100644 --- a/devices/limesdr/devicelimesdr.h +++ b/devices/limesdr/devicelimesdr.h @@ -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_ */ diff --git a/plugins/samplesink/limesdroutput/limesdroutput.cpp b/plugins/samplesink/limesdroutput/limesdroutput.cpp index e6ac04107..2da78f360 100644 --- a/plugins/samplesink/limesdroutput/limesdroutput.cpp +++ b/plugins/samplesink/limesdroutput/limesdroutput.cpp @@ -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; diff --git a/plugins/samplesink/limesdroutput/limesdroutputgui.cpp b/plugins/samplesink/limesdroutput/limesdroutputgui.cpp index def425a94..a7e2fe0b0 100644 --- a/plugins/samplesink/limesdroutput/limesdroutputgui.cpp +++ b/plugins/samplesink/limesdroutput/limesdroutputgui.cpp @@ -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(); +} diff --git a/plugins/samplesink/limesdroutput/limesdroutputgui.h b/plugins/samplesink/limesdroutput/limesdroutputgui.h index f47893579..c3052e065 100644 --- a/plugins/samplesink/limesdroutput/limesdroutputgui.h +++ b/plugins/samplesink/limesdroutput/limesdroutputgui.h @@ -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(); diff --git a/plugins/samplesink/limesdroutput/limesdroutputgui.ui b/plugins/samplesink/limesdroutput/limesdroutputgui.ui index e4c11cb53..c9bc67345 100644 --- a/plugins/samplesink/limesdroutput/limesdroutputgui.ui +++ b/plugins/samplesink/limesdroutput/limesdroutputgui.ui @@ -612,6 +612,50 @@ + + + + + + + :/antenna.png + + + + + + + + 50 + 0 + + + + + 50 + 16777215 + + + + Antenna select: No: none, Lo: 30M:1.9G, Hi: 2:2.6G + + + + No + + + + + Lo + + + + + Hi + + + + diff --git a/plugins/samplesink/limesdroutput/limesdroutputsettings.cpp b/plugins/samplesink/limesdroutput/limesdroutputsettings.cpp index 93c585849..fdc840cf1 100644 --- a/plugins/samplesink/limesdroutput/limesdroutputsettings.cpp +++ b/plugins/samplesink/limesdroutput/limesdroutputsettings.cpp @@ -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; } diff --git a/plugins/samplesink/limesdroutput/limesdroutputsettings.h b/plugins/samplesink/limesdroutput/limesdroutputsettings.h index 7793e3d1d..cf84863e0 100644 --- a/plugins/samplesink/limesdroutput/limesdroutputsettings.h +++ b/plugins/samplesink/limesdroutput/limesdroutputsettings.h @@ -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();