aboutsummaryrefslogtreecommitdiffstats
path: root/Transceiver52M/device
diff options
context:
space:
mode:
authorJoachim Steiger <jsteiger@sysmocom.de>2019-04-16 16:35:53 +0200
committerHarald Welte <laforge@gnumonks.org>2019-04-17 18:24:11 +0000
commit4ce4555d0e28d461bc5b1f21b62e78d07ab9a2ac (patch)
treecd1cd0c20ca8c62f60b5580a271b6d099a08f149 /Transceiver52M/device
parent2d130fb15db2162ac20f5db0cc863d462b29e125 (diff)
lms: move LMS_GetLPFBWRange and LMS_Calibrate calls from open to start
bandwidth, freqency, gain stages need to be set before calibration can be successful Change-Id: I1090effdf0f43e5183a402e4c1a1ffe5abdefd37
Diffstat (limited to 'Transceiver52M/device')
-rw-r--r--Transceiver52M/device/lms/LMSDevice.cpp75
-rw-r--r--Transceiver52M/device/lms/LMSDevice.h2
2 files changed, 50 insertions, 27 deletions
diff --git a/Transceiver52M/device/lms/LMSDevice.cpp b/Transceiver52M/device/lms/LMSDevice.cpp
index 45427cf..083b88e 100644
--- a/Transceiver52M/device/lms/LMSDevice.cpp
+++ b/Transceiver52M/device/lms/LMSDevice.cpp
@@ -153,8 +153,8 @@ int LMSDevice::open(const std::string &args, int ref, bool swap_channels)
{
//lms_info_str_t dev_str;
lms_info_str_t* info_list;
- lms_range_t range_lpfbw_rx, range_lpfbw_tx, range_sr;
- float_type sr_host, sr_rf, lpfbw_rx, lpfbw_tx;
+ lms_range_t range_sr;
+ float_type sr_host, sr_rf;
uint16_t dac_val;
unsigned int i, n;
int rc, dev_id;
@@ -244,36 +244,11 @@ int LMSDevice::open(const std::string &args, int ref, bool swap_channels)
goto out_close;
}
- if (LMS_GetLPFBWRange(m_lms_dev, LMS_CH_RX, &range_lpfbw_rx))
- goto out_close;
- print_range("LPFBWRange Rx", &range_lpfbw_rx);
- if (LMS_GetLPFBWRange(m_lms_dev, LMS_CH_RX, &range_lpfbw_tx))
- goto out_close;
- print_range("LPFBWRange Tx", &range_lpfbw_tx);
- lpfbw_rx = OSMO_MIN(OSMO_MAX(1.4001e6, range_lpfbw_rx.min), range_lpfbw_rx.max);
- lpfbw_tx = OSMO_MIN(OSMO_MAX(5.2e6, range_lpfbw_tx.min), range_lpfbw_tx.max);
-
- LOGC(DDEV, INFO) << "LPFBW: Rx=" << lpfbw_rx << " Tx=" << lpfbw_tx;
-
if (!set_antennas()) {
LOGC(DDEV, ALERT) << "LMS antenna setting failed";
return -1;
}
- /* Perform Rx and Tx calibration */
- for (i=0; i<chans; i++) {
- LOGC(DDEV, INFO) << "Setting LPFBW chan " << i;
- if (LMS_SetLPFBW(m_lms_dev, LMS_CH_RX, i, lpfbw_rx) < 0)
- goto out_close;
- if (LMS_SetLPFBW(m_lms_dev, LMS_CH_TX, i, lpfbw_tx) < 0)
- goto out_close;
- LOGC(DDEV, INFO) << "Calibrating chan " << i;
- if (LMS_Calibrate(m_lms_dev, LMS_CH_RX, i, LMS_CALIBRATE_BW_HZ, 0) < 0)
- goto out_close;
- if (LMS_Calibrate(m_lms_dev, LMS_CH_TX, i, LMS_CALIBRATE_BW_HZ, 0) < 0)
- goto out_close;
- }
-
samplesRead = 0;
samplesWritten = 0;
started = false;
@@ -304,6 +279,13 @@ bool LMSDevice::start()
setTxGain((minTxGain() + maxTxGain()) / 2, i);
setRxGain((minRxGain() + maxRxGain()) / 2, i);
+ /* set up Rx and Tx filters */
+ if (!do_filters(i))
+ return false;
+ /* Perform Rx and Tx calibration */
+ if (!do_calib(i))
+ return false;
+
m_lms_stream_rx[i] = {};
m_lms_stream_rx[i].isTx = false;
m_lms_stream_rx[i].channel = i;
@@ -362,6 +344,45 @@ bool LMSDevice::stop()
return true;
}
+/* do rx/tx calibration - depends on gain, freq and bw */
+bool LMSDevice::do_calib(size_t chan)
+{
+ LOGC(DDEV, INFO) << "Calibrating chan " << chan;
+ if (LMS_Calibrate(m_lms_dev, LMS_CH_RX, chan, LMS_CALIBRATE_BW_HZ, 0) < 0)
+ return false;
+ if (LMS_Calibrate(m_lms_dev, LMS_CH_TX, chan, LMS_CALIBRATE_BW_HZ, 0) < 0)
+ return false;
+ return true;
+}
+
+/* do rx/tx filter config - depends on bw only? */
+bool LMSDevice::do_filters(size_t chan)
+{
+ lms_range_t range_lpfbw_rx, range_lpfbw_tx;
+ float_type lpfbw_rx, lpfbw_tx;
+
+ LOGC(DDEV, INFO) << "Setting filters on chan " << chan;
+ if (LMS_GetLPFBWRange(m_lms_dev, LMS_CH_RX, &range_lpfbw_rx))
+ return false;
+ print_range("LPFBWRange Rx", &range_lpfbw_rx);
+ if (LMS_GetLPFBWRange(m_lms_dev, LMS_CH_RX, &range_lpfbw_tx))
+ return false;
+ print_range("LPFBWRange Tx", &range_lpfbw_tx);
+
+ lpfbw_rx = OSMO_MIN(OSMO_MAX(1.4001e6, range_lpfbw_rx.min), range_lpfbw_rx.max);
+ lpfbw_tx = OSMO_MIN(OSMO_MAX(5.2e6, range_lpfbw_tx.min), range_lpfbw_tx.max);
+
+ LOGC(DDEV, INFO) << "LPFBW: Rx=" << lpfbw_rx << " Tx=" << lpfbw_tx;
+
+ LOGC(DDEV, INFO) << "Setting LPFBW chan " << chan;
+ if (LMS_SetLPFBW(m_lms_dev, LMS_CH_RX, chan, lpfbw_rx) < 0)
+ return false;
+ if (LMS_SetLPFBW(m_lms_dev, LMS_CH_TX, chan, lpfbw_tx) < 0)
+ return false;
+ return true;
+}
+
+
double LMSDevice::maxTxGain()
{
return 73.0;
diff --git a/Transceiver52M/device/lms/LMSDevice.h b/Transceiver52M/device/lms/LMSDevice.h
index fde2408..67f4691 100644
--- a/Transceiver52M/device/lms/LMSDevice.h
+++ b/Transceiver52M/device/lms/LMSDevice.h
@@ -65,6 +65,8 @@ private:
double rxGain;
+ bool do_calib(size_t chan);
+ bool do_filters(size_t chan);
int get_ant_idx(const std::string & name, bool dir_tx, size_t chan);
bool flush_recv(size_t num_pkts);
void update_stream_stats(size_t chan, bool * underrun, bool * overrun);