From 58519b292b561cbec5eb41c85f85c8c6bd4a06fe Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Sun, 15 Aug 2010 21:34:16 -0700 Subject: usrp: moved usrp utils into public include space --- host/include/uhd/usrp/CMakeLists.txt | 2 + host/include/uhd/usrp/dsp_utils.hpp | 99 ++++++++++++++++++++++++++++++++++++ host/include/uhd/usrp/misc_utils.hpp | 54 ++++++++++++++++++++ 3 files changed, 155 insertions(+) create mode 100644 host/include/uhd/usrp/dsp_utils.hpp create mode 100644 host/include/uhd/usrp/misc_utils.hpp (limited to 'host/include') diff --git a/host/include/uhd/usrp/CMakeLists.txt b/host/include/uhd/usrp/CMakeLists.txt index 76ee24e5f..130956f8a 100644 --- a/host/include/uhd/usrp/CMakeLists.txt +++ b/host/include/uhd/usrp/CMakeLists.txt @@ -33,6 +33,8 @@ INSTALL(FILES dboard_manager.hpp ### utilities ### + dsp_utils.hpp + misc_utils.hpp subdev_spec.hpp tune_helper.hpp diff --git a/host/include/uhd/usrp/dsp_utils.hpp b/host/include/uhd/usrp/dsp_utils.hpp new file mode 100644 index 000000000..8ec04dd2f --- /dev/null +++ b/host/include/uhd/usrp/dsp_utils.hpp @@ -0,0 +1,99 @@ +// +// Copyright 2010 Ettus Research LLC +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// + +#ifndef INCLUDED_UHD_USRP_DSP_UTILS_HPP +#define INCLUDED_UHD_USRP_DSP_UTILS_HPP + +#include +#include +#include +#include + +namespace uhd{ namespace usrp{ + +namespace dsp_type1{ + + /*! + * Calculate the rx mux word from properties. + * \param subdev_conn the subdev connection type + * \return the 32-bit rx mux control word + */ + UHD_API boost::uint32_t calc_rx_mux_word(subdev_conn_t subdev_conn); + + /*! + * Calculate the tx mux word from properties. + * \param subdev_conn the subdev connection type + * \return the 32-bit tx mux control word + */ + UHD_API boost::uint32_t calc_tx_mux_word(subdev_conn_t subdev_conn); + + /*! + * Calculate the cordic word from the frequency and clock rate. + * The frequency will be set to the actual (possible) frequency. + * + * \param freq the requested frequency in Hz + * \param codec_rate the dsp codec rate in Hz + * \return the 32-bit cordic control word + */ + UHD_API boost::uint32_t calc_cordic_word_and_update( + double &freq, double codec_rate + ); + + /*! + * Calculate the CIC filter word from the rate. + * Check if requested decim/interp rate is: + * multiple of 4, enable two halfband filters + * multiple of 2, enable one halfband filter + * handle remainder in CIC + * + * \param rate the requested rate in Sps + * \return the 32-bit cic filter control word + */ + UHD_API boost::uint32_t calc_cic_filter_word(unsigned rate); + + /*! + * Calculate the IQ scale factor word from I and Q components. + * \param i the I component of the scalar + * \param q the Q component of the scalar + * \return the 32-bit scale factor control word + */ + UHD_API boost::uint32_t calc_iq_scale_word( + boost::int16_t i, boost::int16_t q + ); + + /*! + * Calculate the IQ scale factor word from the rate. + * \param rate the requested rate in Sps + * \return the 32-bit scale factor control word + */ + UHD_API boost::uint32_t calc_iq_scale_word(unsigned rate); + + /*! + * Calculate the stream command word from the stream command struct. + * \param stream_cmd the requested stream command with mode, flags, timestamp + * \param num_samps_continuous number of samples to request in continuous mode + * \return the 32-bit stream command word + */ + UHD_API boost::uint32_t calc_stream_cmd_word( + const stream_cmd_t &stream_cmd, size_t num_samps_continuous + ); + +} //namespace dsp_type1 + +}} //namespace + +#endif /* INCLUDED_UHD_USRP_DSP_UTILS_HPP */ diff --git a/host/include/uhd/usrp/misc_utils.hpp b/host/include/uhd/usrp/misc_utils.hpp new file mode 100644 index 000000000..14db80162 --- /dev/null +++ b/host/include/uhd/usrp/misc_utils.hpp @@ -0,0 +1,54 @@ +// +// Copyright 2010 Ettus Research LLC +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// + +#ifndef INCLUDED_UHD_USRP_MISC_UTILS_HPP +#define INCLUDED_UHD_USRP_MISC_UTILS_HPP + +#include +#include +#include +#include + +namespace uhd{ namespace usrp{ + + /*! + * Create a gain group that represents the subdevice and its codec. + */ + UHD_API gain_group::sptr make_gain_group(wax::obj subdev, wax::obj codec); + + /*! + * Verify the rx subdevice specification. + * If the subdev spec if empty, automatically fill it. + * \param subdev_spec the subdev spec to verify/fill + * \param mboard the motherboard properties object + * \throw exception when the subdev spec is invalid + */ + UHD_API void verify_rx_subdev_spec(subdev_spec_t &subdev_spec, wax::obj mboard); + + /*! + * Verify the tx subdevice specification. + * If the subdev spec if empty, automatically fill it. + * \param subdev_spec the subdev spec to verify/fill + * \param mboard the motherboard properties object + * \throw exception when the subdev spec is invalid + */ + UHD_API void verify_tx_subdev_spec(subdev_spec_t &subdev_spec, wax::obj mboard); + +}} //namespace + +#endif /* INCLUDED_UHD_USRP_MISC_UTILS_HPP */ + -- cgit v1.2.3 From a80a62dfe6ebfe5a814c71880b83b64a6bee0d0a Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Sun, 15 Aug 2010 22:23:04 -0700 Subject: usrp: use different priority policies for gain group (rx vs tx) --- host/include/uhd/usrp/misc_utils.hpp | 16 +++++++++++++++- host/lib/usrp/misc_utils.cpp | 13 +++++++++---- host/lib/usrp/usrp2/dboard_impl.cpp | 8 ++++++-- 3 files changed, 30 insertions(+), 7 deletions(-) (limited to 'host/include') diff --git a/host/include/uhd/usrp/misc_utils.hpp b/host/include/uhd/usrp/misc_utils.hpp index 14db80162..2af9f5b40 100644 --- a/host/include/uhd/usrp/misc_utils.hpp +++ b/host/include/uhd/usrp/misc_utils.hpp @@ -25,10 +25,24 @@ namespace uhd{ namespace usrp{ + /*! + * Different policies for gain group prioritization. + */ + enum gain_group_policy_t{ + GAIN_GROUP_POLICY_RX = 'R', + GAIN_GROUP_POLICY_TX = 'T' + }; + /*! * Create a gain group that represents the subdevice and its codec. + * \param subdev the object with subdevice properties + * \param codec the object with codec properties + * \param gain_group_policy the policy to use */ - UHD_API gain_group::sptr make_gain_group(wax::obj subdev, wax::obj codec); + UHD_API gain_group::sptr make_gain_group( + wax::obj subdev, wax::obj codec, + gain_group_policy_t gain_group_policy + ); /*! * Verify the rx subdevice specification. diff --git a/host/lib/usrp/misc_utils.cpp b/host/lib/usrp/misc_utils.cpp index 41239b144..46094ba32 100644 --- a/host/lib/usrp/misc_utils.cpp +++ b/host/lib/usrp/misc_utils.cpp @@ -29,9 +29,6 @@ using namespace uhd; using namespace uhd::usrp; -static const size_t subdev_gain_priority = 1; //higher, closer to the antenna -static const size_t codec_gain_priority = 0; - /*********************************************************************** * codec gain group helper functions: * do this so we dont have to bind a templated function @@ -80,7 +77,15 @@ static void set_subdev_gain(wax::obj subdev, const std::string &name, float gain /*********************************************************************** * gain group factory function for usrp **********************************************************************/ -gain_group::sptr usrp::make_gain_group(wax::obj subdev, wax::obj codec){ +gain_group::sptr usrp::make_gain_group( + wax::obj subdev, wax::obj codec, + gain_group_policy_t gain_group_policy +){ + const size_t subdev_gain_priority = 1; + const size_t codec_gain_priority = (gain_group_policy == GAIN_GROUP_POLICY_RX)? + (subdev_gain_priority - 1): //RX policy, codec gains fill last (lower priority) + (subdev_gain_priority + 1); //TX policy, codec gains fill first (higher priority) + gain_group::sptr gg = gain_group::make(); gain_fcns_t fcns; //add all the subdev gains first (antenna to dsp order) diff --git a/host/lib/usrp/usrp2/dboard_impl.cpp b/host/lib/usrp/usrp2/dboard_impl.cpp index 99599f11a..a462b93c2 100644 --- a/host/lib/usrp/usrp2/dboard_impl.cpp +++ b/host/lib/usrp/usrp2/dboard_impl.cpp @@ -89,7 +89,9 @@ void usrp2_mboard_impl::rx_dboard_get(const wax::obj &key_, wax::obj &val){ case DBOARD_PROP_GAIN_GROUP: val = make_gain_group( - _dboard_manager->get_rx_subdev(key.name), _rx_codec_proxy->get_link() + _dboard_manager->get_rx_subdev(key.name), + _rx_codec_proxy->get_link(), + GAIN_GROUP_POLICY_RX ); return; @@ -143,7 +145,9 @@ void usrp2_mboard_impl::tx_dboard_get(const wax::obj &key_, wax::obj &val){ case DBOARD_PROP_GAIN_GROUP: val = make_gain_group( - _dboard_manager->get_tx_subdev(key.name), _tx_codec_proxy->get_link() + _dboard_manager->get_tx_subdev(key.name), + _tx_codec_proxy->get_link(), + GAIN_GROUP_POLICY_TX ); return; -- cgit v1.2.3