aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/usrp/dboard
diff options
context:
space:
mode:
authorTrung Tran <trung.tran@ettus.com>2018-09-12 12:49:51 -0700
committerBrent Stapleton <bstapleton@g.hmc.edu>2018-09-14 16:34:51 -0700
commit786560decef09cff6e5db1c98fdb3de30cf10898 (patch)
treea525ef7a72ed88c2cd04135643538de441a216fb /host/lib/usrp/dboard
parent5fadcfacd825ccc0f0e583d1f196d5e70cc52ed8 (diff)
downloaduhd-786560decef09cff6e5db1c98fdb3de30cf10898.tar.gz
uhd-786560decef09cff6e5db1c98fdb3de30cf10898.tar.bz2
uhd-786560decef09cff6e5db1c98fdb3de30cf10898.zip
mg: clipping frequency
Clipping requested frequency to acceptable ranges in Magnesium TX/RX set frequency functions.
Diffstat (limited to 'host/lib/usrp/dboard')
-rw-r--r--host/lib/usrp/dboard/magnesium/magnesium_constants.hpp3
-rw-r--r--host/lib/usrp/dboard/magnesium/magnesium_radio_ctrl_impl.cpp8
2 files changed, 7 insertions, 4 deletions
diff --git a/host/lib/usrp/dboard/magnesium/magnesium_constants.hpp b/host/lib/usrp/dboard/magnesium/magnesium_constants.hpp
index 2e9debaae..e19603b94 100644
--- a/host/lib/usrp/dboard/magnesium/magnesium_constants.hpp
+++ b/host/lib/usrp/dboard/magnesium/magnesium_constants.hpp
@@ -10,6 +10,7 @@
#include <vector>
#include <string>
#include <cstddef>
+#include <uhd/types/ranges.hpp>
static constexpr size_t FPGPIO_MASTER_RADIO = 0;
static constexpr size_t TOTAL_RADIO_PORTS = 4;
@@ -51,6 +52,8 @@ static constexpr double ALL_TX_MIN_GAIN = 0.0;
static constexpr double ALL_TX_MAX_GAIN = 65.0;
static constexpr double ALL_TX_GAIN_STEP = 0.5;
+static const uhd::freq_range_t MAGNESIUM_FREQ_RANGE(MAGNESIUM_MIN_FREQ, MAGNESIUM_MAX_FREQ);
+
static const std::vector<std::string> MAGNESIUM_RX_ANTENNAS = {
"TX/RX", "RX2", "CAL", "LOCAL"
};
diff --git a/host/lib/usrp/dboard/magnesium/magnesium_radio_ctrl_impl.cpp b/host/lib/usrp/dboard/magnesium/magnesium_radio_ctrl_impl.cpp
index 3fd32bda9..d27531a2b 100644
--- a/host/lib/usrp/dboard/magnesium/magnesium_radio_ctrl_impl.cpp
+++ b/host/lib/usrp/dboard/magnesium/magnesium_radio_ctrl_impl.cpp
@@ -206,10 +206,10 @@ void magnesium_radio_ctrl_impl::set_rx_antenna(
}
double magnesium_radio_ctrl_impl::set_tx_frequency(
- const double freq,
+ const double req_freq,
const size_t chan
) {
- // FIXME bounds checking + clipping!!!
+ const double freq = MAGNESIUM_FREQ_RANGE.clip(req_freq);
UHD_LOG_TRACE(unique_id(),
"set_tx_frequency(f=" << freq << ", chan=" << chan << ")");
_desired_rf_freq[TX_DIRECTION]=freq;
@@ -289,10 +289,10 @@ void magnesium_radio_ctrl_impl::_update_freq(
}
double magnesium_radio_ctrl_impl::set_rx_frequency(
- const double freq,
+ const double req_freq,
const size_t chan
) {
- // FIXME bounds checking + clipping!!!
+ const double freq = MAGNESIUM_FREQ_RANGE.clip(req_freq);
UHD_LOG_TRACE(unique_id(),
"set_rx_frequency(f=" << freq << ", chan=" << chan << ")");
_desired_rf_freq[RX_DIRECTION]=freq;