From 786560decef09cff6e5db1c98fdb3de30cf10898 Mon Sep 17 00:00:00 2001 From: Trung Tran Date: Wed, 12 Sep 2018 12:49:51 -0700 Subject: mg: clipping frequency Clipping requested frequency to acceptable ranges in Magnesium TX/RX set frequency functions. --- host/lib/usrp/dboard/magnesium/magnesium_constants.hpp | 3 +++ host/lib/usrp/dboard/magnesium/magnesium_radio_ctrl_impl.cpp | 8 ++++---- 2 files changed, 7 insertions(+), 4 deletions(-) (limited to 'host') 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 #include #include +#include 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 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; -- cgit v1.2.3