diff options
Diffstat (limited to 'host/lib/usrp/dboard/db_xcvr2450.cpp')
-rw-r--r-- | host/lib/usrp/dboard/db_xcvr2450.cpp | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/host/lib/usrp/dboard/db_xcvr2450.cpp b/host/lib/usrp/dboard/db_xcvr2450.cpp index 26c0d5950..b6b8858e7 100644 --- a/host/lib/usrp/dboard/db_xcvr2450.cpp +++ b/host/lib/usrp/dboard/db_xcvr2450.cpp @@ -50,10 +50,11 @@ #include <uhd/utils/log.hpp> #include <uhd/utils/safe_call.hpp> #include <uhd/utils/static.hpp> +#include <uhdlib/utils/narrow.hpp> #include <boost/assign/list_of.hpp> #include <boost/format.hpp> -#include <boost/math/special_functions/round.hpp> #include <chrono> +#include <cmath> #include <functional> #include <thread> #include <utility> @@ -410,7 +411,7 @@ double xcvr2450::set_lo_freq_core(double target_freq) for (R = 1; R <= 7; R++) { double N = (target_freq * scaler * R * _ad9515div) / ref_freq; intdiv = int(std::floor(N)); - fracdiv = boost::math::iround((N - intdiv) * double(1 << 16)); + fracdiv = uhd::narrow_cast<int>(std::lround((N - intdiv)) * double(1 << 16)); // actual minimum is 128, but most chips seems to require higher to lock if (intdiv < 131 or intdiv > 255) continue; @@ -504,7 +505,7 @@ void xcvr2450::set_rx_ant(const std::string& ant) static int gain_to_tx_vga_reg(double& gain) { // calculate the register value - int reg = uhd::clip(boost::math::iround(gain * 60 / 30.0) + 3, 0, 63); + int reg = uhd::clip(uhd::narrow_cast<int>(std::lround(gain * 60 / 30.0) + 3), 0, 63); // calculate the actual gain value if (reg < 4) @@ -526,7 +527,7 @@ static int gain_to_tx_vga_reg(double& gain) */ static max2829_regs_t::tx_baseband_gain_t gain_to_tx_bb_reg(double& gain) { - int reg = uhd::clip(boost::math::iround(gain * 3 / 5.0), 0, 3); + int reg = uhd::clip(uhd::narrow_cast<int>(std::lround<int>(gain * 3 / 5.0)), 0, 3); switch (reg) { case 0: gain = 0; @@ -552,7 +553,7 @@ static max2829_regs_t::tx_baseband_gain_t gain_to_tx_bb_reg(double& gain) */ static int gain_to_rx_vga_reg(double& gain) { - int reg = uhd::clip(boost::math::iround(gain / 2.0), 0, 31); + int reg = uhd::clip(uhd::narrow_cast<int>(std::lround(gain / 2.0)), 0, 31); gain = double(reg * 2); return reg; } @@ -565,7 +566,7 @@ static int gain_to_rx_vga_reg(double& gain) */ static int gain_to_rx_lna_reg(double& gain) { - int reg = uhd::clip(boost::math::iround(gain * 2 / 30.5) + 1, 0, 3); + int reg = uhd::clip(uhd::narrow_cast<int>(std::lround(gain * 2 / 30.5)) + 1, 0, 3); switch (reg) { case 0: case 1: @@ -620,7 +621,7 @@ double xcvr2450::set_rx_gain(double gain, const std::string& name) static max2829_regs_t::tx_lpf_coarse_adj_t bandwidth_to_tx_lpf_coarse_reg( double& bandwidth) { - int reg = uhd::clip(boost::math::iround((bandwidth - 6.0e6) / 6.0e6), 1, 3); + int reg = uhd::clip(uhd::narrow_cast<int>(std::lround((bandwidth - 6.0e6)) / 6.0e6), 1, 3); switch (reg) { case 1: // bandwidth < 15MHz @@ -639,8 +640,10 @@ static max2829_regs_t::tx_lpf_coarse_adj_t bandwidth_to_tx_lpf_coarse_reg( static max2829_regs_t::rx_lpf_fine_adj_t bandwidth_to_rx_lpf_fine_reg( double& bandwidth, double requested_bandwidth) { - int reg = - uhd::clip(boost::math::iround((requested_bandwidth / bandwidth) / 0.05), 18, 22); + int reg = uhd::clip( + uhd::narrow_cast<int>(std::lround((requested_bandwidth / bandwidth)) / 0.05), + 18, + 22); switch (reg) { case 18: // requested_bandwidth < 92.5% @@ -665,7 +668,8 @@ static max2829_regs_t::rx_lpf_fine_adj_t bandwidth_to_rx_lpf_fine_reg( static max2829_regs_t::rx_lpf_coarse_adj_t bandwidth_to_rx_lpf_coarse_reg( double& bandwidth) { - int reg = uhd::clip(boost::math::iround((bandwidth - 7.0e6) / 1.0e6), 0, 11); + int reg = + uhd::clip(uhd::narrow_cast<int>(std::lround((bandwidth - 7.0e6)) / 1.0e6), 0, 11); switch (reg) { case 0: // bandwidth < 7.5MHz |