From 4d5ae0cc69424ecc9a7fcc0943d22832e5f37b8d Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Thu, 30 May 2019 13:46:24 -0700 Subject: lib: utils: Add new signature to get_freq_and_freq_word() The new signature uses tuple as the return value, instead of passing in output variables as references (C-style). --- host/lib/include/uhdlib/usrp/cores/dsp_core_utils.hpp | 8 +++++++- host/lib/usrp/cores/dsp_core_utils.cpp | 8 ++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/host/lib/include/uhdlib/usrp/cores/dsp_core_utils.hpp b/host/lib/include/uhdlib/usrp/cores/dsp_core_utils.hpp index 739b973cb..2632f4a1f 100644 --- a/host/lib/include/uhdlib/usrp/cores/dsp_core_utils.hpp +++ b/host/lib/include/uhdlib/usrp/cores/dsp_core_utils.hpp @@ -8,7 +8,7 @@ #ifndef INCLUDED_LIBUHD_DSP_CORE_UTILS_HPP #define INCLUDED_LIBUHD_DSP_CORE_UTILS_HPP -#include +#include /*! For a requested frequency and sampling rate, return the * correct frequency word (to set the CORDIC) and the actual frequency. @@ -20,4 +20,10 @@ void get_freq_and_freq_word( int32_t &freq_word ); +/*! For a requested frequency and sampling rate, return the + * correct frequency word (to set the CORDIC) and the actual frequency. + */ +std::tuple get_freq_and_freq_word( + const double requested_freq, const double tick_rate); + #endif /* INCLUDED_LIBUHD_DSP_CORE_UTILS_HPP */ diff --git a/host/lib/usrp/cores/dsp_core_utils.cpp b/host/lib/usrp/cores/dsp_core_utils.cpp index 282073597..44885bc6f 100644 --- a/host/lib/usrp/cores/dsp_core_utils.cpp +++ b/host/lib/usrp/cores/dsp_core_utils.cpp @@ -54,3 +54,11 @@ void get_freq_and_freq_word( actual_freq = (double(freq_word) / scale_factor) * tick_rate; } +std::tuple get_freq_and_freq_word(const double requested_freq, const double tick_rate) +{ + double actual_freq; + int32_t freq_word; + get_freq_and_freq_word(requested_freq, tick_rate, actual_freq, freq_word); + return std::make_tuple(actual_freq, freq_word); +} + -- cgit v1.2.3