summaryrefslogtreecommitdiffstats
path: root/host
diff options
context:
space:
mode:
Diffstat (limited to 'host')
-rw-r--r--host/lib/usrp/dboard/db_basic_and_lf.cpp4
-rw-r--r--host/lib/usrp/dsp_utils.hpp35
-rw-r--r--host/lib/usrp/usrp2/dboard_impl.cpp64
-rw-r--r--host/lib/usrp/usrp2/usrp2_impl.hpp2
-rw-r--r--host/utils/CMakeLists.txt4
-rw-r--r--host/utils/uhd_usrp_probe.cpp166
6 files changed, 229 insertions, 46 deletions
diff --git a/host/lib/usrp/dboard/db_basic_and_lf.cpp b/host/lib/usrp/dboard/db_basic_and_lf.cpp
index 23ac98872..766deac78 100644
--- a/host/lib/usrp/dboard/db_basic_and_lf.cpp
+++ b/host/lib/usrp/dboard/db_basic_and_lf.cpp
@@ -127,7 +127,7 @@ void basic_rx::rx_get(const wax::obj &key_, wax::obj &val){
return;
case SUBDEV_PROP_FREQ_RANGE:
- val = freq_range_t(+_max_freq, -_max_freq);
+ val = freq_range_t(-_max_freq, +_max_freq);
return;
case SUBDEV_PROP_ANTENNA:
@@ -226,7 +226,7 @@ void basic_tx::tx_get(const wax::obj &key_, wax::obj &val){
return;
case SUBDEV_PROP_FREQ_RANGE:
- val = freq_range_t(+_max_freq, -_max_freq);
+ val = freq_range_t(-_max_freq, +_max_freq);
return;
case SUBDEV_PROP_ANTENNA:
diff --git a/host/lib/usrp/dsp_utils.hpp b/host/lib/usrp/dsp_utils.hpp
index cfe5375f8..e0ec46184 100644
--- a/host/lib/usrp/dsp_utils.hpp
+++ b/host/lib/usrp/dsp_utils.hpp
@@ -32,6 +32,41 @@ namespace dsp_type1{
}
/*!
+ * Calculate the rx mux word from properties.
+ * \param is_quadrature true if the subdev is complex
+ * \param is_iq_swapped true if the i and q are reversed
+ * \param the 32-bit rx mux control word
+ */
+ static inline boost::uint32_t calc_rx_mux_word(
+ bool is_quadrature,
+ bool is_iq_swapped
+ ){
+ boost::uint32_t rx_mux = 0;
+ if (is_quadrature){
+ rx_mux = (0x01 << 2) | (0x00 << 0); //Q=ADC1, I=ADC0
+ }else{
+ rx_mux = (0x11 << 2) | (0x00 << 0); //Q=ZERO, I=ADC0
+ }
+ if (is_iq_swapped){
+ rx_mux = (rx_mux << 2) | (rx_mux >> 2);
+ }
+ return rx_mux;
+ }
+
+ /*!
+ * Calculate the tx mux word from properties.
+ * \param is_iq_swapped true if the i and q are reversed
+ * \param the 32-bit tx mux control word
+ */
+ static inline boost::uint32_t calc_tx_mux_word(bool is_iq_swapped){
+ boost::uint32_t tx_mux = 0x10;
+ if (is_iq_swapped){
+ tx_mux = (tx_mux << 4) | (tx_mux >> 4);
+ }
+ return tx_mux;
+ }
+
+ /*!
* Calculate the cordic word from the frequency and clock rate.
* The frequency will be set to the actual (possible) frequency.
*
diff --git a/host/lib/usrp/usrp2/dboard_impl.cpp b/host/lib/usrp/usrp2/dboard_impl.cpp
index 4a3a70467..fef486771 100644
--- a/host/lib/usrp/usrp2/dboard_impl.cpp
+++ b/host/lib/usrp/usrp2/dboard_impl.cpp
@@ -18,6 +18,7 @@
#include "usrp2_impl.hpp"
#include "usrp2_regs.hpp"
+#include "../dsp_utils.hpp"
#include <uhd/usrp/subdev_props.hpp>
#include <uhd/usrp/dboard_props.hpp>
#include <uhd/utils/assert.hpp>
@@ -54,42 +55,8 @@ void usrp2_impl::dboard_init(void){
);
//init the subdevs in use (use the first subdevice)
- _rx_subdevs_in_use = prop_names_t(1, _dboard_manager->get_rx_subdev_names().at(0));
- update_rx_mux_config();
-
- _tx_subdevs_in_use = prop_names_t(1, _dboard_manager->get_tx_subdev_names().at(0));
- update_tx_mux_config();
-}
-
-void usrp2_impl::update_rx_mux_config(void){
- //calculate the rx mux
- boost::uint32_t rx_mux = 0;
- UHD_ASSERT_THROW(_rx_subdevs_in_use.size() == 1);
- wax::obj rx_subdev = _dboard_manager->get_rx_subdev(_rx_subdevs_in_use.at(0));
- std::cout << "Using: " << rx_subdev[SUBDEV_PROP_NAME].as<std::string>() << std::endl;
- if (rx_subdev[SUBDEV_PROP_QUADRATURE].as<bool>()){
- rx_mux = (0x01 << 2) | (0x00 << 0); //Q=ADC1, I=ADC0
- }else{
- rx_mux = 0x00; //ADC0
- }
- if (rx_subdev[SUBDEV_PROP_IQ_SWAPPED].as<bool>()){
- rx_mux = (((rx_mux >> 0) & 0x3) << 2) | (((rx_mux >> 2) & 0x3) << 0);
- }
-
- _iface->poke32(U2_REG_DSP_RX_MUX, rx_mux);
-}
-
-void usrp2_impl::update_tx_mux_config(void){
- //calculate the tx mux
- boost::uint32_t tx_mux = 0x10;
- UHD_ASSERT_THROW(_tx_subdevs_in_use.size() == 1);
- wax::obj tx_subdev = _dboard_manager->get_tx_subdev(_tx_subdevs_in_use.at(0));
- std::cout << "Using: " << tx_subdev[SUBDEV_PROP_NAME].as<std::string>() << std::endl;
- if (tx_subdev[SUBDEV_PROP_IQ_SWAPPED].as<bool>()){
- tx_mux = (((tx_mux >> 0) & 0xf) << 4) | (((tx_mux >> 4) & 0xf) << 0);
- }
-
- _iface->poke32(U2_REG_DSP_TX_MUX, tx_mux);
+ rx_dboard_set(DBOARD_PROP_USED_SUBDEVS, prop_names_t(1, _dboard_manager->get_rx_subdev_names().at(0)));
+ tx_dboard_set(DBOARD_PROP_USED_SUBDEVS, prop_names_t(1, _dboard_manager->get_tx_subdev_names().at(0)));
}
/***********************************************************************
@@ -131,9 +98,16 @@ void usrp2_impl::rx_dboard_get(const wax::obj &key_, wax::obj &val){
void usrp2_impl::rx_dboard_set(const wax::obj &key, const wax::obj &val){
switch(key.as<dboard_prop_t>()){
- case DBOARD_PROP_USED_SUBDEVS:
- _rx_subdevs_in_use = val.as<prop_names_t>();
- update_rx_mux_config(); //if the val is bad, this will throw
+ case DBOARD_PROP_USED_SUBDEVS:{
+ _rx_subdevs_in_use = val.as<prop_names_t>();
+ UHD_ASSERT_THROW(_rx_subdevs_in_use.size() == 1);
+ wax::obj rx_subdev = _dboard_manager->get_rx_subdev(_rx_subdevs_in_use.at(0));
+ std::cout << "Using: " << rx_subdev[SUBDEV_PROP_NAME].as<std::string>() << std::endl;
+ _iface->poke32(U2_REG_DSP_RX_MUX, dsp_type1::calc_rx_mux_word(
+ rx_subdev[SUBDEV_PROP_QUADRATURE].as<bool>(),
+ rx_subdev[SUBDEV_PROP_IQ_SWAPPED].as<bool>()
+ ));
+ }
return;
case DBOARD_PROP_DBOARD_ID:
@@ -184,9 +158,15 @@ void usrp2_impl::tx_dboard_get(const wax::obj &key_, wax::obj &val){
void usrp2_impl::tx_dboard_set(const wax::obj &key, const wax::obj &val){
switch(key.as<dboard_prop_t>()){
- case DBOARD_PROP_USED_SUBDEVS:
- _tx_subdevs_in_use = val.as<prop_names_t>();
- update_tx_mux_config(); //if the val is bad, this will throw
+ case DBOARD_PROP_USED_SUBDEVS:{
+ _tx_subdevs_in_use = val.as<prop_names_t>();
+ UHD_ASSERT_THROW(_tx_subdevs_in_use.size() == 1);
+ wax::obj tx_subdev = _dboard_manager->get_tx_subdev(_tx_subdevs_in_use.at(0));
+ std::cout << "Using: " << tx_subdev[SUBDEV_PROP_NAME].as<std::string>() << std::endl;
+ _iface->poke32(U2_REG_DSP_TX_MUX, dsp_type1::calc_tx_mux_word(
+ tx_subdev[SUBDEV_PROP_IQ_SWAPPED].as<bool>()
+ ));
+ }
return;
case DBOARD_PROP_DBOARD_ID:
diff --git a/host/lib/usrp/usrp2/usrp2_impl.hpp b/host/lib/usrp/usrp2/usrp2_impl.hpp
index 77148ee62..ccc09003e 100644
--- a/host/lib/usrp/usrp2/usrp2_impl.hpp
+++ b/host/lib/usrp/usrp2/usrp2_impl.hpp
@@ -190,8 +190,6 @@ private:
wax_obj_proxy::sptr _tx_dboard_proxy;
uhd::prop_names_t _tx_subdevs_in_use;
uhd::usrp::dboard_eeprom_t _tx_db_eeprom;
- void update_rx_mux_config(void);
- void update_tx_mux_config(void);
//methods and shadows for the ddc dsp
std::vector<size_t> _allowed_decim_and_interp_rates;
diff --git a/host/utils/CMakeLists.txt b/host/utils/CMakeLists.txt
index 69a013a28..8d260c06c 100644
--- a/host/utils/CMakeLists.txt
+++ b/host/utils/CMakeLists.txt
@@ -19,6 +19,10 @@ ADD_EXECUTABLE(uhd_find_devices uhd_find_devices.cpp)
TARGET_LINK_LIBRARIES(uhd_find_devices uhd)
INSTALL(TARGETS uhd_find_devices RUNTIME DESTINATION ${RUNTIME_DIR})
+ADD_EXECUTABLE(uhd_usrp_probe uhd_usrp_probe.cpp)
+TARGET_LINK_LIBRARIES(uhd_usrp_probe uhd)
+INSTALL(TARGETS uhd_usrp_probe RUNTIME DESTINATION ${RUNTIME_DIR})
+
ADD_EXECUTABLE(usrp2_addr_burner usrp2_addr_burner.cpp)
TARGET_LINK_LIBRARIES(usrp2_addr_burner uhd)
INSTALL(TARGETS usrp2_addr_burner RUNTIME DESTINATION ${PKG_DATA_DIR}/utils)
diff --git a/host/utils/uhd_usrp_probe.cpp b/host/utils/uhd_usrp_probe.cpp
new file mode 100644
index 000000000..1e8e726d2
--- /dev/null
+++ b/host/utils/uhd_usrp_probe.cpp
@@ -0,0 +1,166 @@
+//
+// 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 <http://www.gnu.org/licenses/>.
+//
+
+#include <uhd/utils/safe_main.hpp>
+#include <uhd/device.hpp>
+#include <uhd/types/ranges.hpp>
+#include <uhd/usrp/device_props.hpp>
+#include <uhd/usrp/mboard_props.hpp>
+#include <uhd/usrp/dboard_props.hpp>
+#include <uhd/usrp/dsp_props.hpp>
+#include <uhd/usrp/subdev_props.hpp>
+#include <uhd/usrp/dboard_id.hpp>
+#include <boost/program_options.hpp>
+#include <boost/algorithm/string.hpp>
+#include <boost/format.hpp>
+#include <boost/foreach.hpp>
+#include <iostream>
+#include <sstream>
+
+namespace po = boost::program_options;
+using namespace uhd;
+
+static std::string indent(size_t level){
+ return (level)? (indent(level-1) + " ") : "";
+}
+
+static std::string make_border(const std::string &text){
+ std::stringstream ss;
+ ss << boost::format(" _____________________________________________________") << std::endl;
+ ss << boost::format(" /") << std::endl;
+ std::vector<std::string> lines; boost::split(lines, text, boost::is_any_of("\n"));
+ while (lines.back() == "") lines.pop_back(); //strip trailing newlines
+ if (lines.size()) lines[0] = " " + lines[0]; //indent the title line
+ BOOST_FOREACH(const std::string &line, lines){
+ ss << boost::format("| %s") % line << std::endl;
+ }
+ //ss << boost::format(" \\____________________________________________________") << std::endl;
+ return ss.str();
+}
+
+static std::string get_dsp_pp_string(const std::string &type, wax::obj dsp){
+ std::stringstream ss;
+ ss << boost::format("%s DSP: %s") % type % dsp[usrp::DSP_PROP_NAME].as<std::string>() << std::endl;
+ //ss << std::endl;
+ ss << boost::format("Codec Rate: %f Msps") % (dsp[usrp::DSP_PROP_CODEC_RATE].as<double>()/1e6) << std::endl;
+ //ss << boost::format("Host Rate: %f Msps") % (dsp[usrp::DSP_PROP_HOST_RATE].as<double>()/1e6) << std::endl;
+ //ss << boost::format("Freq Shift: %f Mhz") % (dsp[usrp::DSP_PROP_FREQ_SHIFT].as<double>()/1e6) << std::endl;
+ return ss.str();
+}
+
+static std::string prop_names_to_pp_string(const prop_names_t &prop_names){
+ std::stringstream ss; size_t count = 0;
+ BOOST_FOREACH(const std::string &prop_name, prop_names){
+ ss << ((count++)? ", " : "") << prop_name;
+ }
+ return ss.str();
+}
+
+static std::string get_subdev_pp_string(const std::string &type, wax::obj subdev){
+ std::stringstream ss;
+ ss << boost::format("%s Subdev: %s") % type % subdev[usrp::SUBDEV_PROP_NAME].as<std::string>() << std::endl;
+ //ss << std::endl;
+
+ prop_names_t ant_names(subdev[usrp::SUBDEV_PROP_ANTENNA_NAMES].as<prop_names_t>());
+ ss << boost::format("Antennas: %s") % prop_names_to_pp_string(ant_names) << std::endl;
+
+ freq_range_t freq_range(subdev[usrp::SUBDEV_PROP_FREQ_RANGE].as<freq_range_t>());
+ ss << boost::format("Freq range: %.3f to %.3f Mhz") % (freq_range.min/1e6) % (freq_range.max/1e6) << std::endl;
+
+ prop_names_t gain_names(subdev[usrp::SUBDEV_PROP_GAIN_NAMES].as<prop_names_t>());
+ if (gain_names.size() == 0) ss << "Gain Elements: None" << std::endl;
+ BOOST_FOREACH(const std::string &gain_name, gain_names){
+ gain_range_t gain_range(subdev[named_prop_t(usrp::SUBDEV_PROP_GAIN_RANGE, gain_name)].as<gain_range_t>());
+ ss << boost::format("Gain range %s: %.1f to %.1f step %.1f dB") % gain_name % gain_range.min % gain_range.max % gain_range.step << std::endl;
+ }
+
+ ss << boost::format("Is Quadrature: %s") % (subdev[usrp::SUBDEV_PROP_QUADRATURE].as<bool>()? "Yes" : "No") << std::endl;
+ ss << boost::format("Is IQ Swapped: %s") % (subdev[usrp::SUBDEV_PROP_IQ_SWAPPED].as<bool>()? "Yes" : "No") << std::endl;
+ ss << boost::format("Is Spectrum Inverted: %s") % (subdev[usrp::SUBDEV_PROP_SPECTRUM_INVERTED].as<bool>()? "Yes" : "No") << std::endl;
+ ss << boost::format("Uses LO offset: %s") % (subdev[usrp::SUBDEV_PROP_USE_LO_OFFSET].as<bool>()? "Yes" : "No") << std::endl;
+
+ return ss.str();
+}
+
+static std::string get_dboard_pp_string(const std::string &type, wax::obj dboard){
+ std::stringstream ss;
+ ss << boost::format("%s Dboard: %s") % type % dboard[usrp::DBOARD_PROP_NAME].as<std::string>() << std::endl;
+ //ss << std::endl;
+ BOOST_FOREACH(const std::string &subdev_name, dboard[usrp::DBOARD_PROP_SUBDEV_NAMES].as<prop_names_t>()){
+ ss << make_border(get_subdev_pp_string(type, dboard[named_prop_t(usrp::DBOARD_PROP_SUBDEV, subdev_name)]));
+ }
+ return ss.str();
+}
+
+static std::string get_mboard_pp_string(wax::obj mboard){
+ std::stringstream ss;
+ ss << boost::format("Mboard: %s") % mboard[usrp::MBOARD_PROP_NAME].as<std::string>() << std::endl;
+ //ss << std::endl;
+ BOOST_FOREACH(const std::string &other_name, mboard[usrp::MBOARD_PROP_OTHERS].as<prop_names_t>()){
+ try{
+ ss << boost::format("%s: %s") % other_name % mboard[other_name].as<std::string>() << std::endl;
+ } catch(...){}
+ }
+ BOOST_FOREACH(const std::string &dsp_name, mboard[usrp::MBOARD_PROP_RX_DSP_NAMES].as<prop_names_t>()){
+ ss << make_border(get_dsp_pp_string("RX", mboard[named_prop_t(usrp::MBOARD_PROP_RX_DSP, dsp_name)]));
+ }
+ BOOST_FOREACH(const std::string &dsp_name, mboard[usrp::MBOARD_PROP_TX_DSP_NAMES].as<prop_names_t>()){
+ ss << make_border(get_dsp_pp_string("TX", mboard[named_prop_t(usrp::MBOARD_PROP_TX_DSP, dsp_name)]));
+ }
+ BOOST_FOREACH(const std::string &dsp_name, mboard[usrp::MBOARD_PROP_RX_DBOARD_NAMES].as<prop_names_t>()){
+ ss << make_border(get_dboard_pp_string("RX", mboard[named_prop_t(usrp::MBOARD_PROP_RX_DBOARD, dsp_name)]));
+ }
+ BOOST_FOREACH(const std::string &dsp_name, mboard[usrp::MBOARD_PROP_TX_DBOARD_NAMES].as<prop_names_t>()){
+ ss << make_border(get_dboard_pp_string("TX", mboard[named_prop_t(usrp::MBOARD_PROP_TX_DBOARD, dsp_name)]));
+ }
+ return ss.str();
+}
+
+
+static std::string get_device_pp_string(device::sptr dev){
+ std::stringstream ss;
+ ss << boost::format("Device: %s") % (*dev)[usrp::DEVICE_PROP_NAME].as<std::string>() << std::endl;
+ //ss << std::endl;
+ BOOST_FOREACH(const std::string &mboard_name, (*dev)[usrp::DEVICE_PROP_MBOARD_NAMES].as<prop_names_t>()){
+ ss << make_border(get_mboard_pp_string((*dev)[named_prop_t(usrp::DEVICE_PROP_MBOARD, mboard_name)]));
+ }
+ return ss.str();
+}
+
+int UHD_SAFE_MAIN(int argc, char *argv[]){
+ po::options_description desc("Allowed options");
+ desc.add_options()
+ ("help", "help message")
+ ("args", po::value<std::string>()->default_value(""), "device address args")
+ ;
+
+ po::variables_map vm;
+ po::store(po::parse_command_line(argc, argv, desc), vm);
+ po::notify(vm);
+
+ //print the help message
+ if (vm.count("help")){
+ std::cout << boost::format("UHD USRP Probe %s") % desc << std::endl;
+ return ~0;
+ }
+
+ device::sptr dev = device::make(vm["args"].as<std::string>());
+
+ std::cout << make_border(get_device_pp_string(dev)) << std::endl;
+
+ return 0;
+}