diff options
author | Josh Blum <josh@joshknows.com> | 2010-09-20 18:17:52 -0700 |
---|---|---|
committer | Josh Blum <josh@joshknows.com> | 2010-09-20 18:17:52 -0700 |
commit | d68922ed306cd73eb761165369619cdbac2ca637 (patch) | |
tree | b5e0e50faee9cb906d4b316270c1d1a72a61d682 /host | |
parent | 1625bcb4139a317189ff2a4c71b96473944aba50 (diff) | |
download | uhd-d68922ed306cd73eb761165369619cdbac2ca637.tar.gz uhd-d68922ed306cd73eb761165369619cdbac2ca637.tar.bz2 uhd-d68922ed306cd73eb761165369619cdbac2ca637.zip |
usrp1: implemented multi-channel dsp control of shift freq
usrp: simple usrp calls into single usrp and prints deprecation warning
usrp: tune helper now supports multi-channel dsps
Diffstat (limited to 'host')
-rw-r--r-- | host/include/uhd/usrp/dsp_props.hpp | 11 | ||||
-rw-r--r-- | host/include/uhd/usrp/simple_usrp.hpp | 3 | ||||
-rw-r--r-- | host/include/uhd/usrp/tune_helper.hpp | 18 | ||||
-rw-r--r-- | host/lib/usrp/mimo_usrp.cpp | 12 | ||||
-rw-r--r-- | host/lib/usrp/simple_usrp.cpp | 163 | ||||
-rw-r--r-- | host/lib/usrp/single_usrp.cpp | 14 | ||||
-rw-r--r-- | host/lib/usrp/tune_helper.cpp | 38 | ||||
-rw-r--r-- | host/lib/usrp/usrp1/dsp_impl.cpp | 77 | ||||
-rw-r--r-- | host/lib/usrp/usrp1/mboard_impl.cpp | 34 | ||||
-rw-r--r-- | host/lib/usrp/usrp1/usrp1_impl.hpp | 6 | ||||
-rw-r--r-- | host/test/tune_helper_test.cpp | 22 |
11 files changed, 191 insertions, 207 deletions
diff --git a/host/include/uhd/usrp/dsp_props.hpp b/host/include/uhd/usrp/dsp_props.hpp index 75d8c0a60..54ea5666b 100644 --- a/host/include/uhd/usrp/dsp_props.hpp +++ b/host/include/uhd/usrp/dsp_props.hpp @@ -37,11 +37,12 @@ namespace uhd{ namespace usrp{ * Set the shift property and read it back to get actual shift. */ enum dsp_prop_t{ - DSP_PROP_NAME = 'n', //ro, std::string - DSP_PROP_OTHERS = 'o', //ro, prop_names_t - DSP_PROP_FREQ_SHIFT = 'f', //rw, double Hz - DSP_PROP_CODEC_RATE = 'c', //ro, double Sps - DSP_PROP_HOST_RATE = 'h' //rw, double Sps + DSP_PROP_NAME = 'n', //ro, std::string + DSP_PROP_OTHERS = 'o', //ro, prop_names_t + DSP_PROP_FREQ_SHIFT = 'f', //rw, double Hz + DSP_PROP_FREQ_SHIFT_NAMES = 'F', //ro, prop_names_t + DSP_PROP_CODEC_RATE = 'c', //ro, double Sps + DSP_PROP_HOST_RATE = 'h' //rw, double Sps }; }} //namespace diff --git a/host/include/uhd/usrp/simple_usrp.hpp b/host/include/uhd/usrp/simple_usrp.hpp index 169411f19..6149f739c 100644 --- a/host/include/uhd/usrp/simple_usrp.hpp +++ b/host/include/uhd/usrp/simple_usrp.hpp @@ -33,7 +33,8 @@ namespace uhd{ namespace usrp{ /*! - * The simple USRP device class: + * The simple USRP device class (DEPRECATED): + * This interface has been deprecated in favor of the single USRP interface. * A simple usrp facilitates ease-of-use for most use-case scenarios. * The wrapper provides convenience functions to tune the devices * as well as to set the dboard gains, antennas, and other properties. diff --git a/host/include/uhd/usrp/tune_helper.hpp b/host/include/uhd/usrp/tune_helper.hpp index df3907b3e..ec133fa08 100644 --- a/host/include/uhd/usrp/tune_helper.hpp +++ b/host/include/uhd/usrp/tune_helper.hpp @@ -31,12 +31,13 @@ namespace uhd{ namespace usrp{ * The ddc cordic is setup to bring the IF down to baseband. * \param subdev the dboard subdevice object with properties * \param ddc the mboard dsp object with properties + * \param chan the channel of the dsp to tune * \param target_freq the desired center frequency * \param lo_offset an offset for the subdevice IF from center * \return a tune result struct */ UHD_API tune_result_t tune_rx_subdev_and_dsp( - wax::obj subdev, wax::obj ddc, + wax::obj subdev, wax::obj ddc, size_t chan, double target_freq, double lo_offset ); @@ -46,17 +47,19 @@ namespace uhd{ namespace usrp{ * is calculated based on the subdevice and BW. */ UHD_API tune_result_t tune_rx_subdev_and_dsp( - wax::obj subdev, wax::obj ddc, double target_freq + wax::obj subdev, wax::obj ddc, + size_t chan, double target_freq ); /*! * Calculate the overall frequency from the combination of dboard IF and DDC shift. * \param subdev the dboard subdevice object with properties * \param ddc the mboard dsp object with properties + * \param chan the channel of the dsp to tune * \return the overall tune frequency of the system in Hz */ UHD_API double derive_freq_from_rx_subdev_and_dsp( - wax::obj subdev, wax::obj ddc + wax::obj subdev, wax::obj ddc, size_t chan ); /*! @@ -66,12 +69,13 @@ namespace uhd{ namespace usrp{ * The duc cordic is setup to bring the baseband up to IF. * \param subdev the dboard subdevice object with properties * \param duc the mboard dsp object with properties + * \param chan the channel of the dsp to tune * \param target_freq the desired center frequency * \param lo_offset an offset for the subdevice IF from center * \return a tune result struct */ UHD_API tune_result_t tune_tx_subdev_and_dsp( - wax::obj subdev, wax::obj duc, + wax::obj subdev, wax::obj duc, size_t chan, double target_freq, double lo_offset ); @@ -81,17 +85,19 @@ namespace uhd{ namespace usrp{ * is calculated based on the subdevice and BW. */ UHD_API tune_result_t tune_tx_subdev_and_dsp( - wax::obj subdev, wax::obj duc, double target_freq + wax::obj subdev, wax::obj duc, + size_t chan, double target_freq ); /*! * Calculate the overall frequency from the combination of dboard IF and DUC shift. * \param subdev the dboard subdevice object with properties * \param duc the mboard dsp object with properties + * \param chan the channel of the dsp to tune * \return the overall tune frequency of the system in Hz */ UHD_API double derive_freq_from_tx_subdev_and_dsp( - wax::obj subdev, wax::obj duc + wax::obj subdev, wax::obj duc, size_t chan ); }} diff --git a/host/lib/usrp/mimo_usrp.cpp b/host/lib/usrp/mimo_usrp.cpp index e78d38fc0..9331c7fbb 100644 --- a/host/lib/usrp/mimo_usrp.cpp +++ b/host/lib/usrp/mimo_usrp.cpp @@ -179,15 +179,15 @@ public: } tune_result_t set_rx_freq(size_t chan, double target_freq){ - return tune_rx_subdev_and_dsp(_rx_subdev(chan), _rx_dsp(chan), target_freq); + return tune_rx_subdev_and_dsp(_rx_subdev(chan), _rx_dsp(chan), 0, target_freq); } tune_result_t set_rx_freq(size_t chan, double target_freq, double lo_off){ - return tune_rx_subdev_and_dsp(_rx_subdev(chan), _rx_dsp(chan), target_freq, lo_off); + return tune_rx_subdev_and_dsp(_rx_subdev(chan), _rx_dsp(chan), 0, target_freq, lo_off); } double get_rx_freq(size_t chan){ - return derive_freq_from_rx_subdev_and_dsp(_rx_subdev(chan), _rx_dsp(chan)); + return derive_freq_from_rx_subdev_and_dsp(_rx_subdev(chan), _rx_dsp(chan), 0); } freq_range_t get_rx_freq_range(size_t chan){ @@ -255,15 +255,15 @@ public: } tune_result_t set_tx_freq(size_t chan, double target_freq){ - return tune_tx_subdev_and_dsp(_tx_subdev(chan), _tx_dsp(chan), target_freq); + return tune_tx_subdev_and_dsp(_tx_subdev(chan), _tx_dsp(chan), 0, target_freq); } tune_result_t set_tx_freq(size_t chan, double target_freq, double lo_off){ - return tune_tx_subdev_and_dsp(_tx_subdev(chan), _tx_dsp(chan), target_freq, lo_off); + return tune_tx_subdev_and_dsp(_tx_subdev(chan), _tx_dsp(chan), 0, target_freq, lo_off); } double get_tx_freq(size_t chan){ - return derive_freq_from_tx_subdev_and_dsp(_tx_subdev(chan), _tx_dsp(chan)); + return derive_freq_from_tx_subdev_and_dsp(_tx_subdev(chan), _tx_dsp(chan), 0); } freq_range_t get_tx_freq_range(size_t chan){ diff --git a/host/lib/usrp/simple_usrp.cpp b/host/lib/usrp/simple_usrp.cpp index e573d0fc0..d29952955 100644 --- a/host/lib/usrp/simple_usrp.cpp +++ b/host/lib/usrp/simple_usrp.cpp @@ -15,35 +15,20 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // +#include <uhd/usrp/single_usrp.hpp> #include <uhd/usrp/simple_usrp.hpp> -#include <uhd/usrp/tune_helper.hpp> -#include <uhd/utils/assert.hpp> -#include <uhd/utils/gain_group.hpp> -#include <uhd/usrp/subdev_props.hpp> -#include <uhd/usrp/mboard_props.hpp> -#include <uhd/usrp/device_props.hpp> -#include <uhd/usrp/dboard_props.hpp> -#include <uhd/usrp/dsp_props.hpp> -#include <boost/foreach.hpp> -#include <boost/format.hpp> -#include <stdexcept> -#include <iostream> +#include <uhd/utils/warning.hpp> using namespace uhd; using namespace uhd::usrp; -static inline freq_range_t add_dsp_shift(const freq_range_t &range, wax::obj dsp){ - double codec_rate = dsp[DSP_PROP_CODEC_RATE].as<double>(); - return freq_range_t(range.min - codec_rate/2.0, range.max + codec_rate/2.0); -} - /*********************************************************************** * Simple USRP Implementation **********************************************************************/ class simple_usrp_impl : public simple_usrp{ public: simple_usrp_impl(const device_addr_t &addr){ - _dev = device::make(addr); + _sdev = single_usrp::make(addr); } ~simple_usrp_impl(void){ @@ -51,235 +36,187 @@ public: } device::sptr get_device(void){ - return _dev; + return _sdev->get_device(); } std::string get_pp_string(void){ - return str(boost::format( - "Simple USRP:\n" - " Device: %s\n" - " Mboard: %s\n" - " RX DSP: %s\n" - " RX Dboard: %s\n" - " RX Subdev: %s\n" - " TX DSP: %s\n" - " TX Dboard: %s\n" - " TX Subdev: %s\n" - ) - % (*_dev)[DEVICE_PROP_NAME].as<std::string>() - % _mboard()[MBOARD_PROP_NAME].as<std::string>() - % _rx_dsp()[DSP_PROP_NAME].as<std::string>() - % _rx_dboard()[DBOARD_PROP_NAME].as<std::string>() - % _rx_subdev()[SUBDEV_PROP_NAME].as<std::string>() - % _tx_dsp()[DSP_PROP_NAME].as<std::string>() - % _tx_dboard()[DBOARD_PROP_NAME].as<std::string>() - % _tx_subdev()[SUBDEV_PROP_NAME].as<std::string>() - ); + return _sdev->get_pp_string(); } /******************************************************************* * Misc ******************************************************************/ time_spec_t get_time_now(void){ - return _mboard()[MBOARD_PROP_TIME_NOW].as<time_spec_t>(); + return _sdev->get_time_now(); } void set_time_now(const time_spec_t &time_spec){ - _mboard()[MBOARD_PROP_TIME_NOW] = time_spec; + return _sdev->set_time_now(time_spec); } void set_time_next_pps(const time_spec_t &time_spec){ - _mboard()[MBOARD_PROP_TIME_NEXT_PPS] = time_spec; + return _sdev->set_time_next_pps(time_spec); } void issue_stream_cmd(const stream_cmd_t &stream_cmd){ - _mboard()[MBOARD_PROP_STREAM_CMD] = stream_cmd; + return _sdev->issue_stream_cmd(stream_cmd); } void set_clock_config(const clock_config_t &clock_config){ - _mboard()[MBOARD_PROP_CLOCK_CONFIG] = clock_config; + return _sdev->set_clock_config(clock_config); } /******************************************************************* * RX methods ******************************************************************/ void set_rx_subdev_spec(const subdev_spec_t &spec){ - _mboard()[MBOARD_PROP_RX_SUBDEV_SPEC] = spec; - std::cout << "RX " << _mboard()[MBOARD_PROP_RX_SUBDEV_SPEC].as<subdev_spec_t>().to_pp_string() << std::endl; + return _sdev->set_rx_subdev_spec(spec); } subdev_spec_t get_rx_subdev_spec(void){ - return _mboard()[MBOARD_PROP_RX_SUBDEV_SPEC].as<subdev_spec_t>(); + return _sdev->get_rx_subdev_spec(); } void set_rx_rate(double rate){ - _rx_dsp()[DSP_PROP_HOST_RATE] = rate; + return _sdev->set_rx_rate(rate); } double get_rx_rate(void){ - return _rx_dsp()[DSP_PROP_HOST_RATE].as<double>(); + return _sdev->get_rx_rate(); } tune_result_t set_rx_freq(double target_freq){ - return tune_rx_subdev_and_dsp(_rx_subdev(), _rx_dsp(), target_freq); + return _sdev->set_rx_freq(target_freq); } tune_result_t set_rx_freq(double target_freq, double lo_off){ - return tune_rx_subdev_and_dsp(_rx_subdev(), _rx_dsp(), target_freq, lo_off); + return _sdev->set_rx_freq(target_freq, lo_off); } double get_rx_freq(void){ - return derive_freq_from_rx_subdev_and_dsp(_rx_subdev(), _rx_dsp()); + return _sdev->get_rx_freq(); } freq_range_t get_rx_freq_range(void){ - return add_dsp_shift(_rx_subdev()[SUBDEV_PROP_FREQ_RANGE].as<freq_range_t>(), _rx_dsp()); + return _sdev->get_rx_freq_range(); } void set_rx_gain(float gain){ - return _rx_gain_group()->set_value(gain); + return _sdev->set_rx_gain(gain); } float get_rx_gain(void){ - return _rx_gain_group()->get_value(); + return _sdev->get_rx_gain(); } gain_range_t get_rx_gain_range(void){ - return _rx_gain_group()->get_range(); + return _sdev->get_rx_gain_range(); } void set_rx_antenna(const std::string &ant){ - _rx_subdev()[SUBDEV_PROP_ANTENNA] = ant; + return _sdev->set_rx_antenna(ant); } std::string get_rx_antenna(void){ - return _rx_subdev()[SUBDEV_PROP_ANTENNA].as<std::string>(); + return _sdev->get_rx_antenna(); } std::vector<std::string> get_rx_antennas(void){ - return _rx_subdev()[SUBDEV_PROP_ANTENNA_NAMES].as<prop_names_t>(); + return _sdev->get_rx_antennas(); } bool get_rx_lo_locked(void){ - return _rx_subdev()[SUBDEV_PROP_LO_LOCKED].as<bool>(); + return _sdev->get_rx_lo_locked(); } float read_rssi(void){ - return _rx_subdev()[SUBDEV_PROP_RSSI].as<float>(); + return _sdev->read_rssi(); } dboard_iface::sptr get_rx_dboard_iface(void){ - return _rx_dboard()[DBOARD_PROP_DBOARD_IFACE].as<dboard_iface::sptr>(); + return _sdev->get_rx_dboard_iface(); } /******************************************************************* * TX methods ******************************************************************/ void set_tx_subdev_spec(const subdev_spec_t &spec){ - _mboard()[MBOARD_PROP_TX_SUBDEV_SPEC] = spec; - std::cout << "TX " << _mboard()[MBOARD_PROP_TX_SUBDEV_SPEC].as<subdev_spec_t>().to_pp_string() << std::endl; + return _sdev->set_tx_subdev_spec(spec); } subdev_spec_t get_tx_subdev_spec(void){ - return _mboard()[MBOARD_PROP_TX_SUBDEV_SPEC].as<subdev_spec_t>(); + return _sdev->get_tx_subdev_spec(); } void set_tx_rate(double rate){ - _tx_dsp()[DSP_PROP_HOST_RATE] = rate; + return _sdev->set_tx_rate(rate); } double get_tx_rate(void){ - return _tx_dsp()[DSP_PROP_HOST_RATE].as<double>(); + return _sdev->get_tx_rate(); } tune_result_t set_tx_freq(double target_freq){ - return tune_tx_subdev_and_dsp(_tx_subdev(), _tx_dsp(), target_freq); + return _sdev->set_tx_freq(target_freq); } tune_result_t set_tx_freq(double target_freq, double lo_off){ - return tune_tx_subdev_and_dsp(_tx_subdev(), _tx_dsp(), target_freq, lo_off); + return _sdev->set_tx_freq(target_freq, lo_off); } double get_tx_freq(void){ - return derive_freq_from_tx_subdev_and_dsp(_tx_subdev(), _tx_dsp()); + return _sdev->get_tx_freq(); } freq_range_t get_tx_freq_range(void){ - return add_dsp_shift(_tx_subdev()[SUBDEV_PROP_FREQ_RANGE].as<freq_range_t>(), _tx_dsp()); + return _sdev->get_tx_freq_range(); } void set_tx_gain(float gain){ - return _tx_gain_group()->set_value(gain); + return _sdev->set_tx_gain(gain); } float get_tx_gain(void){ - return _tx_gain_group()->get_value(); + return _sdev->get_tx_gain(); } gain_range_t get_tx_gain_range(void){ - return _tx_gain_group()->get_range(); + return _sdev->get_tx_gain_range(); } void set_tx_antenna(const std::string &ant){ - _tx_subdev()[SUBDEV_PROP_ANTENNA] = ant; + return _sdev->set_tx_antenna(ant); } std::string get_tx_antenna(void){ - return _tx_subdev()[SUBDEV_PROP_ANTENNA].as<std::string>(); + return _sdev->get_tx_antenna(); } std::vector<std::string> get_tx_antennas(void){ - return _tx_subdev()[SUBDEV_PROP_ANTENNA_NAMES].as<prop_names_t>(); + return _sdev->get_tx_antennas(); } bool get_tx_lo_locked(void){ - return _tx_subdev()[SUBDEV_PROP_LO_LOCKED].as<bool>(); + return _sdev->get_tx_lo_locked(); } dboard_iface::sptr get_tx_dboard_iface(void){ - return _tx_dboard()[DBOARD_PROP_DBOARD_IFACE].as<dboard_iface::sptr>(); + return _sdev->get_tx_dboard_iface(); } private: - device::sptr _dev; - wax::obj _mboard(void){ - return (*_dev)[DEVICE_PROP_MBOARD]; - } - wax::obj _rx_dsp(void){ - return _mboard()[MBOARD_PROP_RX_DSP]; - } - wax::obj _tx_dsp(void){ - return _mboard()[MBOARD_PROP_TX_DSP]; - } - wax::obj _rx_dboard(void){ - std::string db_name = _mboard()[MBOARD_PROP_RX_SUBDEV_SPEC].as<subdev_spec_t>().front().db_name; - return _mboard()[named_prop_t(MBOARD_PROP_RX_DBOARD, db_name)]; - } - wax::obj _tx_dboard(void){ - std::string db_name = _mboard()[MBOARD_PROP_TX_SUBDEV_SPEC].as<subdev_spec_t>().front().db_name; - return _mboard()[named_prop_t(MBOARD_PROP_TX_DBOARD, db_name)]; - } - wax::obj _rx_subdev(void){ - std::string sd_name = _mboard()[MBOARD_PROP_RX_SUBDEV_SPEC].as<subdev_spec_t>().front().sd_name; - return _rx_dboard()[named_prop_t(DBOARD_PROP_SUBDEV, sd_name)]; - } - wax::obj _tx_subdev(void){ - std::string sd_name = _mboard()[MBOARD_PROP_TX_SUBDEV_SPEC].as<subdev_spec_t>().front().sd_name; - return _tx_dboard()[named_prop_t(DBOARD_PROP_SUBDEV, sd_name)]; - } - gain_group::sptr _rx_gain_group(void){ - std::string sd_name = _mboard()[MBOARD_PROP_RX_SUBDEV_SPEC].as<subdev_spec_t>().front().sd_name; - return _rx_dboard()[named_prop_t(DBOARD_PROP_GAIN_GROUP, sd_name)].as<gain_group::sptr>(); - } - gain_group::sptr _tx_gain_group(void){ - std::string sd_name = _mboard()[MBOARD_PROP_TX_SUBDEV_SPEC].as<subdev_spec_t>().front().sd_name; - return _tx_dboard()[named_prop_t(DBOARD_PROP_GAIN_GROUP, sd_name)].as<gain_group::sptr>(); - } + single_usrp::sptr _sdev; }; /*********************************************************************** * The Make Function **********************************************************************/ simple_usrp::sptr simple_usrp::make(const device_addr_t &dev_addr){ + uhd::print_warning( + "The simple USRP interface has been deprecated.\n" + "Please switch to the single USRP interface.\n" + "#include <uhd/usrp/single_usrp.hpp>\n" + "simple_usrp::sptr sdev = simple_usrp::make(args);\n" + ); return sptr(new simple_usrp_impl(dev_addr)); } diff --git a/host/lib/usrp/single_usrp.cpp b/host/lib/usrp/single_usrp.cpp index 77e705c71..bb4af44b8 100644 --- a/host/lib/usrp/single_usrp.cpp +++ b/host/lib/usrp/single_usrp.cpp @@ -129,7 +129,6 @@ public: ******************************************************************/ void set_rx_subdev_spec(const subdev_spec_t &spec){ _mboard()[MBOARD_PROP_RX_SUBDEV_SPEC] = spec; - std::cout << "RX " << this->get_rx_subdev_spec().to_pp_string() << std::endl; } subdev_spec_t get_rx_subdev_spec(void){ @@ -145,15 +144,15 @@ public: } tune_result_t set_rx_freq(double target_freq, size_t chan){ - return tune_rx_subdev_and_dsp(_rx_subdev(chan), _rx_dsp(/*TODO*/), target_freq); + return tune_rx_subdev_and_dsp(_rx_subdev(chan), _rx_dsp(), chan, target_freq); } tune_result_t set_rx_freq(double target_freq, double lo_off, size_t chan){ - return tune_rx_subdev_and_dsp(_rx_subdev(chan), _rx_dsp(/*TODO*/), target_freq, lo_off); + return tune_rx_subdev_and_dsp(_rx_subdev(chan), _rx_dsp(), chan, target_freq, lo_off); } double get_rx_freq(size_t chan){ - return derive_freq_from_rx_subdev_and_dsp(_rx_subdev(chan), _rx_dsp(/*TODO*/)); + return derive_freq_from_rx_subdev_and_dsp(_rx_subdev(chan), _rx_dsp(), chan); } freq_range_t get_rx_freq_range(size_t chan){ @@ -201,7 +200,6 @@ public: ******************************************************************/ void set_tx_subdev_spec(const subdev_spec_t &spec){ _mboard()[MBOARD_PROP_TX_SUBDEV_SPEC] = spec; - std::cout << "TX " << this->get_tx_subdev_spec().to_pp_string() << std::endl; } subdev_spec_t get_tx_subdev_spec(void){ @@ -217,15 +215,15 @@ public: } tune_result_t set_tx_freq(double target_freq, size_t chan){ - return tune_tx_subdev_and_dsp(_tx_subdev(chan), _tx_dsp(/*TODO*/), target_freq); + return tune_tx_subdev_and_dsp(_tx_subdev(chan), _tx_dsp(), chan, target_freq); } tune_result_t set_tx_freq(double target_freq, double lo_off, size_t chan){ - return tune_tx_subdev_and_dsp(_tx_subdev(chan), _tx_dsp(/*TODO*/), target_freq, lo_off); + return tune_tx_subdev_and_dsp(_tx_subdev(chan), _tx_dsp(), chan, target_freq, lo_off); } double get_tx_freq(size_t chan){ - return derive_freq_from_tx_subdev_and_dsp(_tx_subdev(chan), _tx_dsp(/*TODO*/)); + return derive_freq_from_tx_subdev_and_dsp(_tx_subdev(chan), _tx_dsp(), chan); } freq_range_t get_tx_freq_range(size_t chan){ diff --git a/host/lib/usrp/tune_helper.cpp b/host/lib/usrp/tune_helper.cpp index e516477d3..7633c67f2 100644 --- a/host/lib/usrp/tune_helper.cpp +++ b/host/lib/usrp/tune_helper.cpp @@ -30,11 +30,12 @@ using namespace uhd::usrp; **********************************************************************/ static tune_result_t tune_xx_subdev_and_dxc( dboard_iface::unit_t unit, - wax::obj subdev, wax::obj dxc, + wax::obj subdev, wax::obj dxc, size_t chan, double target_freq, double lo_offset ){ wax::obj subdev_freq_proxy = subdev[SUBDEV_PROP_FREQ]; - wax::obj dxc_freq_proxy = dxc[DSP_PROP_FREQ_SHIFT]; + std::string freq_name = dxc[DSP_PROP_FREQ_SHIFT_NAMES].as<prop_names_t>().at(chan); + wax::obj dxc_freq_proxy = dxc[named_prop_t(DSP_PROP_FREQ_SHIFT, freq_name)]; double dxc_sample_rate = dxc[DSP_PROP_CODEC_RATE].as<double>(); // Ask the d'board to tune as closely as it can to target_freq+lo_offset @@ -65,11 +66,12 @@ static tune_result_t tune_xx_subdev_and_dxc( static double derive_freq_from_xx_subdev_and_dxc( dboard_iface::unit_t unit, - wax::obj subdev, wax::obj dxc + wax::obj subdev, wax::obj dxc, size_t chan ){ //extract actual dsp and IF frequencies double actual_inter_freq = subdev[SUBDEV_PROP_FREQ].as<double>(); - double actual_dxc_freq = dxc[DSP_PROP_FREQ_SHIFT].as<double>(); + std::string freq_name = dxc[DSP_PROP_FREQ_SHIFT_NAMES].as<prop_names_t>().at(chan); + double actual_dxc_freq = dxc[named_prop_t(DSP_PROP_FREQ_SHIFT, freq_name)].as<double>(); //invert the sign on the dxc freq given the following conditions if (unit == dboard_iface::UNIT_TX) actual_dxc_freq *= -1.0; @@ -81,50 +83,54 @@ static double derive_freq_from_xx_subdev_and_dxc( * RX Tune **********************************************************************/ tune_result_t usrp::tune_rx_subdev_and_dsp( - wax::obj subdev, wax::obj ddc, + wax::obj subdev, wax::obj ddc, size_t chan, double target_freq, double lo_offset ){ - return tune_xx_subdev_and_dxc(dboard_iface::UNIT_RX, subdev, ddc, target_freq, lo_offset); + return tune_xx_subdev_and_dxc(dboard_iface::UNIT_RX, subdev, ddc, chan, target_freq, lo_offset); } tune_result_t usrp::tune_rx_subdev_and_dsp( wax::obj subdev, wax::obj ddc, - double target_freq + size_t chan, double target_freq ){ double lo_offset = 0.0; //if the local oscillator will be in the passband, use an offset if (subdev[SUBDEV_PROP_USE_LO_OFFSET].as<bool>()){ lo_offset = 2.0*ddc[DSP_PROP_HOST_RATE].as<double>(); } - return tune_rx_subdev_and_dsp(subdev, ddc, target_freq, lo_offset); + return tune_rx_subdev_and_dsp(subdev, ddc, chan, target_freq, lo_offset); } -double usrp::derive_freq_from_rx_subdev_and_dsp(wax::obj subdev, wax::obj ddc){ - return derive_freq_from_xx_subdev_and_dxc(dboard_iface::UNIT_RX, subdev, ddc); +double usrp::derive_freq_from_rx_subdev_and_dsp( + wax::obj subdev, wax::obj ddc, size_t chan +){ + return derive_freq_from_xx_subdev_and_dxc(dboard_iface::UNIT_RX, subdev, ddc, chan); } /*********************************************************************** * TX Tune **********************************************************************/ tune_result_t usrp::tune_tx_subdev_and_dsp( - wax::obj subdev, wax::obj duc, + wax::obj subdev, wax::obj duc, size_t chan, double target_freq, double lo_offset ){ - return tune_xx_subdev_and_dxc(dboard_iface::UNIT_TX, subdev, duc, target_freq, lo_offset); + return tune_xx_subdev_and_dxc(dboard_iface::UNIT_TX, subdev, duc, chan, target_freq, lo_offset); } tune_result_t usrp::tune_tx_subdev_and_dsp( wax::obj subdev, wax::obj duc, - double target_freq + size_t chan, double target_freq ){ double lo_offset = 0.0; //if the local oscillator will be in the passband, use an offset if (subdev[SUBDEV_PROP_USE_LO_OFFSET].as<bool>()){ lo_offset = 2.0*duc[DSP_PROP_HOST_RATE].as<double>(); } - return tune_tx_subdev_and_dsp(subdev, duc, target_freq, lo_offset); + return tune_tx_subdev_and_dsp(subdev, duc, chan, target_freq, lo_offset); } -double usrp::derive_freq_from_tx_subdev_and_dsp(wax::obj subdev, wax::obj duc){ - return derive_freq_from_xx_subdev_and_dxc(dboard_iface::UNIT_TX, subdev, duc); +double usrp::derive_freq_from_tx_subdev_and_dsp( + wax::obj subdev, wax::obj duc, size_t chan +){ + return derive_freq_from_xx_subdev_and_dxc(dboard_iface::UNIT_TX, subdev, duc, chan); } diff --git a/host/lib/usrp/usrp1/dsp_impl.cpp b/host/lib/usrp/usrp1/dsp_impl.cpp index ba05fa6ed..573bce21f 100644 --- a/host/lib/usrp/usrp1/dsp_impl.cpp +++ b/host/lib/usrp/usrp1/dsp_impl.cpp @@ -21,6 +21,8 @@ #include <uhd/usrp/dsp_props.hpp> #include <boost/bind.hpp> #include <boost/format.hpp> +#include <boost/lexical_cast.hpp> +#include <boost/assign/list_of.hpp> #include <iostream> #include <cmath> @@ -42,8 +44,9 @@ void usrp1_impl::rx_dsp_init(void) /*********************************************************************** * RX DDC Get **********************************************************************/ -void usrp1_impl::rx_dsp_get(const wax::obj &key, wax::obj &val) -{ +void usrp1_impl::rx_dsp_get(const wax::obj &key_, wax::obj &val){ + named_prop_t key = named_prop_t::extract(key_); + switch(key.as<dsp_prop_t>()){ case DSP_PROP_NAME: val = str(boost::format("usrp1 ddc %uX %s") @@ -57,7 +60,16 @@ void usrp1_impl::rx_dsp_get(const wax::obj &key, wax::obj &val) return; case DSP_PROP_FREQ_SHIFT: - val = _rx_dsp_freq; + val = _rx_dsp_freqs[key.name]; + return; + + case DSP_PROP_FREQ_SHIFT_NAMES:{ + prop_names_t names; + for(size_t i = 0; i < this->get_num_ddcs(); i++){ + names.push_back(boost::lexical_cast<std::string>(i)); + } + val = names; + } return; case DSP_PROP_CODEC_RATE: @@ -76,25 +88,22 @@ void usrp1_impl::rx_dsp_get(const wax::obj &key, wax::obj &val) /*********************************************************************** * RX DDC Set **********************************************************************/ -void usrp1_impl::rx_dsp_set(const wax::obj &key, const wax::obj &val) -{ +void usrp1_impl::rx_dsp_set(const wax::obj &key_, const wax::obj &val){ + named_prop_t key = named_prop_t::extract(key_); + switch(key.as<dsp_prop_t>()) { case DSP_PROP_FREQ_SHIFT: { double new_freq = val.as<double>(); boost::uint32_t reg_word = dsp_type1::calc_cordic_word_and_update( new_freq, _clock_ctrl->get_master_clock_freq()); - //TODO TODO TODO TODO TODO TODO TODO TODO TODO - // - // Handle multiple receive channels / DDC's - // - //TODO TODO TODO TODO TODO TODO TODO TODO TODO - _iface->poke32(FR_RX_FREQ_0, reg_word); - _iface->poke32(FR_RX_FREQ_1, reg_word); - _iface->poke32(FR_RX_FREQ_2, reg_word); - _iface->poke32(FR_RX_FREQ_3, reg_word); - - _rx_dsp_freq = new_freq; + static const uhd::dict<std::string, boost::uint32_t> + freq_name_to_reg_val = boost::assign::map_list_of + ("0", FR_RX_FREQ_0) ("1", FR_RX_FREQ_1) + ("2", FR_RX_FREQ_2) ("3", FR_RX_FREQ_3) + ; + _iface->poke32(freq_name_to_reg_val[key.name], reg_word); + _rx_dsp_freqs[key.name] = new_freq; return; } case DSP_PROP_HOST_RATE: { @@ -136,8 +145,9 @@ void usrp1_impl::tx_dsp_init(void) /*********************************************************************** * TX DUC Get **********************************************************************/ -void usrp1_impl::tx_dsp_get(const wax::obj &key, wax::obj &val) -{ +void usrp1_impl::tx_dsp_get(const wax::obj &key_, wax::obj &val){ + named_prop_t key = named_prop_t::extract(key_); + switch(key.as<dsp_prop_t>()) { case DSP_PROP_NAME: val = str(boost::format("usrp1 duc %uX %s") @@ -151,7 +161,16 @@ void usrp1_impl::tx_dsp_get(const wax::obj &key, wax::obj &val) return; case DSP_PROP_FREQ_SHIFT: - val = _tx_dsp_freq; + val = _tx_dsp_freqs[key.name]; + return; + + case DSP_PROP_FREQ_SHIFT_NAMES:{ + prop_names_t names; + for(size_t i = 0; i < this->get_num_ducs(); i++){ + names.push_back(boost::lexical_cast<std::string>(i)); + } + val = names; + } return; case DSP_PROP_CODEC_RATE: @@ -170,20 +189,20 @@ void usrp1_impl::tx_dsp_get(const wax::obj &key, wax::obj &val) /*********************************************************************** * TX DUC Set **********************************************************************/ -void usrp1_impl::tx_dsp_set(const wax::obj &key, const wax::obj &val) -{ +void usrp1_impl::tx_dsp_set(const wax::obj &key_, const wax::obj &val){ + named_prop_t key = named_prop_t::extract(key_); + switch(key.as<dsp_prop_t>()) { - //TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO - // - // Set both codec frequencies until we have duality properties - // - //TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO case DSP_PROP_FREQ_SHIFT: { double new_freq = val.as<double>(); - _codec_ctrls[DBOARD_SLOT_A]->set_duc_freq(new_freq); - _codec_ctrls[DBOARD_SLOT_B]->set_duc_freq(new_freq); - _tx_dsp_freq = new_freq; + + //map the freq shift key to a subdev spec to a particular codec chip + std::string db_name = _tx_subdev_spec.at(boost::lexical_cast<size_t>(key.name)).db_name; + if (db_name == "A") _codec_ctrls[DBOARD_SLOT_A]->set_duc_freq(new_freq); + if (db_name == "B") _codec_ctrls[DBOARD_SLOT_B]->set_duc_freq(new_freq); + + _tx_dsp_freqs[key.name] = new_freq; return; } diff --git a/host/lib/usrp/usrp1/mboard_impl.cpp b/host/lib/usrp/usrp1/mboard_impl.cpp index 464a82494..e55c3685b 100644 --- a/host/lib/usrp/usrp1/mboard_impl.cpp +++ b/host/lib/usrp/usrp1/mboard_impl.cpp @@ -36,6 +36,8 @@ using namespace uhd; using namespace uhd::usrp; +static const bool usrp1_mboard_verbose = false; + /*********************************************************************** * Calculate the RX mux value: * The I and Q mux values are intentionally reversed to flip I and Q @@ -220,15 +222,13 @@ void usrp1_impl::mboard_init(void) // Set default for TX format to 16-bit I&Q _iface->poke32(FR_TX_FORMAT, 0x00000000); - // TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO - // - // Do something useful with the capabilities register - // - std::cout << "USRP1 Capabilities" << std::endl; - std::cout << " number of duc's: " << get_num_ddcs() << std::endl; - std::cout << " number of ddc's: " << get_num_ducs() << std::endl; - std::cout << " rx halfband: " << has_rx_halfband() << std::endl; - std::cout << " tx halfband: " << has_tx_halfband() << std::endl; + if (usrp1_mboard_verbose){ + std::cout << "USRP1 Capabilities" << std::endl; + std::cout << " number of duc's: " << get_num_ddcs() << std::endl; + std::cout << " number of ddc's: " << get_num_ducs() << std::endl; + std::cout << " rx halfband: " << has_rx_halfband() << std::endl; + std::cout << " tx halfband: " << has_tx_halfband() << std::endl; + } } void usrp1_impl::issue_stream_cmd(const stream_cmd_t &stream_cmd) @@ -362,18 +362,26 @@ void usrp1_impl::mboard_set(const wax::obj &key, const wax::obj &val) case MBOARD_PROP_RX_SUBDEV_SPEC: _rx_subdev_spec = val.as<subdev_spec_t>(); + if (_rx_subdev_spec.size() > this->get_num_ddcs()){ + throw std::runtime_error(str(boost::format( + "USRP1 suports up to %u RX channels.\n" + "However, this RX subdev spec requires %u channels\n" + ) % this->get_num_ddcs() % _rx_subdev_spec.size())); + } verify_rx_subdev_spec(_rx_subdev_spec, _mboard_proxy->get_link()); - //sanity check - UHD_ASSERT_THROW(_rx_subdev_spec.size() <= 2); //set the mux and set the number of rx channels _iface->poke32(FR_RX_MUX, calc_rx_mux(_rx_subdev_spec, _mboard_proxy->get_link())); return; case MBOARD_PROP_TX_SUBDEV_SPEC: _tx_subdev_spec = val.as<subdev_spec_t>(); + if (_tx_subdev_spec.size() > this->get_num_ducs()){ + throw std::runtime_error(str(boost::format( + "USRP1 suports up to %u TX channels.\n" + "However, this TX subdev spec requires %u channels\n" + ) % this->get_num_ducs() % _tx_subdev_spec.size())); + } verify_tx_subdev_spec(_tx_subdev_spec, _mboard_proxy->get_link()); - //sanity check - UHD_ASSERT_THROW(_tx_subdev_spec.size() <= 2); //set the mux and set the number of tx channels _iface->poke32(FR_TX_MUX, calc_tx_mux(_tx_subdev_spec, _mboard_proxy->get_link())); return; diff --git a/host/lib/usrp/usrp1/usrp1_impl.hpp b/host/lib/usrp/usrp1/usrp1_impl.hpp index 663fbb34b..f5e423654 100644 --- a/host/lib/usrp/usrp1/usrp1_impl.hpp +++ b/host/lib/usrp/usrp1/usrp1_impl.hpp @@ -179,14 +179,16 @@ private: void rx_dsp_init(void); void rx_dsp_get(const wax::obj &, wax::obj &); void rx_dsp_set(const wax::obj &, const wax::obj &); - double _rx_dsp_freq; size_t _rx_dsp_decim; + uhd::dict<std::string, double> _rx_dsp_freqs; + size_t _rx_dsp_decim; wax_obj_proxy::sptr _rx_dsp_proxy; //tx dsp functions and settings void tx_dsp_init(void); void tx_dsp_get(const wax::obj &, wax::obj &); void tx_dsp_set(const wax::obj &, const wax::obj &); - double _tx_dsp_freq; size_t _tx_dsp_interp; + uhd::dict<std::string, double> _tx_dsp_freqs; + size_t _tx_dsp_interp; wax_obj_proxy::sptr _tx_dsp_proxy; //transports diff --git a/host/test/tune_helper_test.cpp b/host/test/tune_helper_test.cpp index 570f47293..1ef4af330 100644 --- a/host/test/tune_helper_test.cpp +++ b/host/test/tune_helper_test.cpp @@ -99,7 +99,8 @@ public: /* NOP */ } private: - void get(const wax::obj &key, wax::obj &val){ + void get(const wax::obj &key_, wax::obj &val){ + named_prop_t key = named_prop_t::extract(key_); switch(key.as<dsp_prop_t>()){ case DSP_PROP_CODEC_RATE: val = _codec_rate; @@ -109,11 +110,16 @@ private: val = _freq_shift; return; + case DSP_PROP_FREQ_SHIFT_NAMES: + val = prop_names_t(1, ""); + return; + default: UHD_THROW_PROP_GET_ERROR(); } } - void set(const wax::obj &key, const wax::obj &val){ + void set(const wax::obj &key_, const wax::obj &val){ + named_prop_t key = named_prop_t::extract(key_); switch(key.as<dsp_prop_t>()){ case DSP_PROP_FREQ_SHIFT: _freq_shift = val.as<double>(); @@ -136,12 +142,12 @@ BOOST_AUTO_TEST_CASE(test_tune_helper_rx){ dummy_dsp dsp(100e6); std::cout << "Testing tune helper RX automatic LO offset" << std::endl; - tune_result_t tr = tune_rx_subdev_and_dsp(subdev.get_link(), dsp.get_link(), 2.3451e9); + tune_result_t tr = tune_rx_subdev_and_dsp(subdev.get_link(), dsp.get_link(), 0, 2.3451e9); std::cout << tr.to_pp_string() << std::endl; BOOST_CHECK_CLOSE(tr.actual_inter_freq, 2.345e9, tolerance); BOOST_CHECK_CLOSE(tr.actual_dsp_freq, -100e3, tolerance); - double freq_derived = derive_freq_from_rx_subdev_and_dsp(subdev.get_link(), dsp.get_link()); + double freq_derived = derive_freq_from_rx_subdev_and_dsp(subdev.get_link(), dsp.get_link(), 0); BOOST_CHECK_CLOSE(freq_derived, 2.3451e9, tolerance); } @@ -150,12 +156,12 @@ BOOST_AUTO_TEST_CASE(test_tune_helper_tx){ dummy_dsp dsp(100e6); std::cout << "Testing tune helper TX automatic LO offset" << std::endl; - tune_result_t tr = tune_tx_subdev_and_dsp(subdev.get_link(), dsp.get_link(), 2.3451e9); + tune_result_t tr = tune_tx_subdev_and_dsp(subdev.get_link(), dsp.get_link(), 0, 2.3451e9); std::cout << tr.to_pp_string() << std::endl; BOOST_CHECK_CLOSE(tr.actual_inter_freq, 2.345e9, tolerance); BOOST_CHECK_CLOSE(tr.actual_dsp_freq, 100e3, tolerance); - double freq_derived = derive_freq_from_tx_subdev_and_dsp(subdev.get_link(), dsp.get_link()); + double freq_derived = derive_freq_from_tx_subdev_and_dsp(subdev.get_link(), dsp.get_link(), 0); BOOST_CHECK_CLOSE(freq_derived, 2.3451e9, tolerance); } @@ -164,11 +170,11 @@ BOOST_AUTO_TEST_CASE(test_tune_helper_rx_nyquist){ dummy_dsp dsp(100e6); std::cout << "Testing tune helper RX dummy basic board" << std::endl; - tune_result_t tr = tune_rx_subdev_and_dsp(subdev.get_link(), dsp.get_link(), 55e6); + tune_result_t tr = tune_rx_subdev_and_dsp(subdev.get_link(), dsp.get_link(), 0, 55e6); std::cout << tr.to_pp_string() << std::endl; BOOST_CHECK_CLOSE(tr.actual_inter_freq, 0.0, tolerance); BOOST_CHECK_CLOSE(tr.actual_dsp_freq, 45e6, tolerance); - double freq_derived = derive_freq_from_rx_subdev_and_dsp(subdev.get_link(), dsp.get_link()); + double freq_derived = derive_freq_from_rx_subdev_and_dsp(subdev.get_link(), dsp.get_link(), 0); BOOST_CHECK_CLOSE(freq_derived, -45e6, tolerance); } |