1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-12-23 01:55:48 -05:00

LimeSDR input: added antenna selection

This commit is contained in:
f4exb 2017-04-23 16:23:01 +02:00
parent 196172a1df
commit e0b7027756
10 changed files with 233 additions and 2 deletions

View File

@ -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;
}

View File

@ -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_ */

View File

@ -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;

View File

@ -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();
}

View File

@ -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();

View File

@ -647,6 +647,59 @@
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="antennaLabel">
<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>
<item>
<property name="text">
<string>Au</string>
</property>
</item>
<item>
<property name="text">
<string>Hi</string>
</property>
</item>
<item>
<property name="text">
<string>Lo</string>
</property>
</item>
<item>
<property name="text">
<string>Wi</string>
</property>
</item>
<item>
<property name="text">
<string>T1</string>
</property>
</item>
<item>
<property name="text">
<string>T2</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item>

View File

@ -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

View File

@ -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();

Binary file not shown.

After

Width:  |  Height:  |  Size: 511 B

View File

@ -77,5 +77,6 @@
<file>camera.png</file>
<file>filter_bandpass.png</file>
<file>stream.png</file>
<file>antenna.png</file>
</qresource>
</RCC>