aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/usrp/usrp1/codec_ctrl.cpp
diff options
context:
space:
mode:
authorMartin Braun <martin.braun@ettus.com>2021-06-19 00:06:52 +0200
committerAaron Rossetto <aaron.rossetto@ni.com>2021-06-24 12:00:49 -0500
commit188fbb17cfd18c87f60ec56f62476f97ef2779bb (patch)
treee88b9fb8436aa42f3ecbdc0403751a3e68bbbac8 /host/lib/usrp/usrp1/codec_ctrl.cpp
parent78ec29b6becd53f79a0ae282ae22c38bedb887d1 (diff)
downloaduhd-188fbb17cfd18c87f60ec56f62476f97ef2779bb.tar.gz
uhd-188fbb17cfd18c87f60ec56f62476f97ef2779bb.tar.bz2
uhd-188fbb17cfd18c87f60ec56f62476f97ef2779bb.zip
uhd: Remove all occurences of boost::math::*round()
Its behaviour is almost identical to std::lround, which we use instead. The only downside of std::lround is that it always returns a long, which we don't always need. We thus add some casts for those cases to make the compiler happy.
Diffstat (limited to 'host/lib/usrp/usrp1/codec_ctrl.cpp')
-rw-r--r--host/lib/usrp/usrp1/codec_ctrl.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/host/lib/usrp/usrp1/codec_ctrl.cpp b/host/lib/usrp/usrp1/codec_ctrl.cpp
index ca5503132..413caaf67 100644
--- a/host/lib/usrp/usrp1/codec_ctrl.cpp
+++ b/host/lib/usrp/usrp1/codec_ctrl.cpp
@@ -13,11 +13,12 @@
#include <uhd/utils/byteswap.hpp>
#include <uhd/utils/log.hpp>
#include <uhd/utils/safe_call.hpp>
-#include <stdint.h>
+#include <uhdlib/utils/narrow.hpp>
+#include <cstdint>
#include <boost/assign/list_of.hpp>
#include <boost/format.hpp>
-#include <boost/math/special_functions/round.hpp>
#include <boost/math/special_functions/sign.hpp>
+#include <cmath>
#include <iomanip>
#include <tuple>
@@ -257,7 +258,8 @@ void usrp1_codec_ctrl_impl::write_aux_dac(aux_dac_t which, double volts)
{
// special case for aux dac d (aka sigma delta word)
if (which == AUX_DAC_D) {
- uint16_t dac_word = uhd::clip(boost::math::iround(volts * 0xfff / 3.3), 0, 0xfff);
+ uint16_t dac_word = uhd::clip(
+ uhd::narrow_cast<int>(std::lround(volts * 0xfff / 3.3)), 0, 0xfff);
_ad9862_regs.sig_delt_11_4 = uint8_t(dac_word >> 4);
_ad9862_regs.sig_delt_3_0 = uint8_t(dac_word & 0xf);
this->send_reg(42);
@@ -266,7 +268,8 @@ void usrp1_codec_ctrl_impl::write_aux_dac(aux_dac_t which, double volts)
}
// calculate the dac word for aux dac a, b, c
- uint8_t dac_word = uhd::clip(boost::math::iround(volts * 0xff / 3.3), 0, 0xff);
+ uint8_t dac_word =
+ uhd::clip(uhd::narrow_cast<int>(std::lround(volts * 0xff / 3.3)), 0, 0xff);
// setup a lookup table for the aux dac params (reg ref, reg addr)
typedef std::tuple<uint8_t*, uint8_t> dac_params_t;
@@ -356,7 +359,7 @@ double usrp1_codec_ctrl_impl::fine_tune(double codec_rate, double target_freq)
static const double scale_factor = std::pow(2.0, 24);
uint32_t freq_word =
- uint32_t(boost::math::round(std::abs((target_freq / codec_rate) * scale_factor)));
+ uint32_t(std::lround(std::abs((target_freq / codec_rate) * scale_factor)));
double actual_freq = freq_word * codec_rate / scale_factor;