From c9ea6e3e8c33286d91a8a045264e1741067ced26 Mon Sep 17 00:00:00 2001 From: Pau Espin Pedrol Date: Tue, 29 May 2018 19:00:30 +0200 Subject: lms: Check LPBFW to set is within supported range As of LimeSuite 618fbb9c3188b36d75ad5785a97b8887dcc468f6, it seems 5e6 is within the returned range, but LMS_SetLPFBW fails anyway. See for more information: https://github.com/myriadrf/LimeSuite/issues/184 Change-Id: I967e7da7c0e3e8138b76733ee4a0e6311d20b62e --- Transceiver52M/device/lms/LMSDevice.cpp | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/Transceiver52M/device/lms/LMSDevice.cpp b/Transceiver52M/device/lms/LMSDevice.cpp index fb1b794..d9b5ba6 100644 --- a/Transceiver52M/device/lms/LMSDevice.cpp +++ b/Transceiver52M/device/lms/LMSDevice.cpp @@ -77,10 +77,18 @@ static void thread_enable_cancel(bool cancel) pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL); } +static void print_range(const char* name, lms_range_t *range) +{ + LOG(DEBUG) << name << ": Min=" << range->min << " Max=" << range->max + << " Step=" << range->step; +} + 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; uint16_t dac_val; unsigned int i, n; int rc; @@ -118,18 +126,18 @@ int LMSDevice::open(const std::string &args, int ref, bool swap_channels) return -1; } - lms_range_t range; - if (LMS_GetSampleRateRange(m_lms_dev, LMS_CH_RX, &range)) + if (LMS_GetSampleRateRange(m_lms_dev, LMS_CH_RX, &range_sr)) goto out_close; - LOG(DEBUG) << "Sample Rate: Min=" << range.min << " Max=" << range.max << " Step=" << range.step; + print_range("Sample Rate", &range_sr); LOG(DEBUG) << "Setting sample rate to " << GSMRATE*sps << " " << sps; if (LMS_SetSampleRate(m_lms_dev, GSMRATE*sps, 32) < 0) goto out_close; - float_type sr_host, sr_rf; + if (LMS_GetSampleRate(m_lms_dev, LMS_CH_RX, 0, &sr_host, &sr_rf)) goto out_close; LOG(DEBUG) << "Sample Rate: Host=" << sr_host << " RF=" << sr_rf; + /* FIXME: make this device/model dependent, like UHDDevice:dev_param_map! */ //ts_offset = static_cast(8.9e-5 * GSMRATE); ts_offset = 0; @@ -155,11 +163,23 @@ 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); + + LOG(DEBUG) << "LPFBW: Rx=" << lpfbw_rx << " Tx=" << lpfbw_tx; + /* Perform Rx and Tx calibration */ for (i=0; i