summaryrefslogtreecommitdiffstats
path: root/host/lib/usrp/usrp2
diff options
context:
space:
mode:
authorNick Foster <nick@nerdnetworks.org>2010-08-18 14:48:35 -0700
committerNick Foster <nick@nerdnetworks.org>2010-08-18 14:48:35 -0700
commit2da87fa5082c507d324dce743d63667a6d21fd80 (patch)
treeead6d4b7e9af0a403d6079134f9fa992dc52102c /host/lib/usrp/usrp2
parent40faee2e6d87f7364a0c0c2cf310f1483c0331cf (diff)
parent8740197dfed997bb235b73ec649edb803d544326 (diff)
downloaduhd-2da87fa5082c507d324dce743d63667a6d21fd80.tar.gz
uhd-2da87fa5082c507d324dce743d63667a6d21fd80.tar.bz2
uhd-2da87fa5082c507d324dce743d63667a6d21fd80.zip
Merge branch 'master' of ettus.sourcerepo.com:ettus/uhdpriv into usrp2p
Diffstat (limited to 'host/lib/usrp/usrp2')
-rw-r--r--host/lib/usrp/usrp2/codec_impl.cpp8
-rw-r--r--host/lib/usrp/usrp2/dboard_iface.cpp7
-rw-r--r--host/lib/usrp/usrp2/dboard_impl.cpp22
-rw-r--r--host/lib/usrp/usrp2/dsp_impl.cpp11
-rw-r--r--host/lib/usrp/usrp2/fw_common.h2
-rw-r--r--host/lib/usrp/usrp2/mboard_impl.cpp37
-rw-r--r--host/lib/usrp/usrp2/usrp2_impl.cpp17
7 files changed, 47 insertions, 57 deletions
diff --git a/host/lib/usrp/usrp2/codec_impl.cpp b/host/lib/usrp/usrp2/codec_impl.cpp
index 969b5b4b9..f7f9ce2d5 100644
--- a/host/lib/usrp/usrp2/codec_impl.cpp
+++ b/host/lib/usrp/usrp2/codec_impl.cpp
@@ -53,9 +53,7 @@ void usrp2_mboard_impl::codec_init(void){
/***********************************************************************
* RX Codec Properties
**********************************************************************/
-void usrp2_mboard_impl::rx_codec_get(const wax::obj &key_, wax::obj &val){
- wax::obj key; std::string name;
- boost::tie(key, name) = extract_named_prop(key_);
+void usrp2_mboard_impl::rx_codec_get(const wax::obj &key, wax::obj &val){
//handle the get request conditioned on the key
switch(key.as<codec_prop_t>()){
@@ -136,9 +134,7 @@ void usrp2_mboard_impl::rx_codec_set_gain(float gain, const std::string &name){
/***********************************************************************
* TX Codec Properties
**********************************************************************/
-void usrp2_mboard_impl::tx_codec_get(const wax::obj &key_, wax::obj &val){
- wax::obj key; std::string name;
- boost::tie(key, name) = extract_named_prop(key_);
+void usrp2_mboard_impl::tx_codec_get(const wax::obj &key, wax::obj &val){
//handle the get request conditioned on the key
switch(key.as<codec_prop_t>()){
diff --git a/host/lib/usrp/usrp2/dboard_iface.cpp b/host/lib/usrp/usrp2/dboard_iface.cpp
index be45c2c9e..cff13292b 100644
--- a/host/lib/usrp/usrp2/dboard_iface.cpp
+++ b/host/lib/usrp/usrp2/dboard_iface.cpp
@@ -37,7 +37,12 @@ public:
usrp2_dboard_iface(usrp2_iface::sptr iface, usrp2_clock_ctrl::sptr clock_ctrl);
~usrp2_dboard_iface(void);
- std::string get_mboard_name(void){return "usrp2";}
+ special_props_t get_special_props(void){
+ special_props_t props;
+ props.soft_clock_divider = false;
+ props.mangle_i2c_addrs = false;
+ return props;
+ }
void write_aux_dac(unit_t, aux_dac_t, float);
float read_aux_adc(unit_t, aux_adc_t);
diff --git a/host/lib/usrp/usrp2/dboard_impl.cpp b/host/lib/usrp/usrp2/dboard_impl.cpp
index 075f22388..a462b93c2 100644
--- a/host/lib/usrp/usrp2/dboard_impl.cpp
+++ b/host/lib/usrp/usrp2/dboard_impl.cpp
@@ -17,8 +17,8 @@
#include "usrp2_impl.hpp"
#include "usrp2_regs.hpp"
-#include "../dsp_utils.hpp"
-#include "../misc_utils.hpp"
+#include <uhd/usrp/misc_utils.hpp>
+#include <uhd/usrp/dsp_utils.hpp>
#include <uhd/usrp/subdev_props.hpp>
#include <uhd/usrp/dboard_props.hpp>
#include <uhd/utils/assert.hpp>
@@ -59,8 +59,7 @@ void usrp2_mboard_impl::dboard_init(void){
* RX DBoard Properties
**********************************************************************/
void usrp2_mboard_impl::rx_dboard_get(const wax::obj &key_, wax::obj &val){
- wax::obj key; std::string name;
- boost::tie(key, name) = extract_named_prop(key_);
+ named_prop_t key = named_prop_t::extract(key_);
//handle the get request conditioned on the key
switch(key.as<dboard_prop_t>()){
@@ -69,7 +68,7 @@ void usrp2_mboard_impl::rx_dboard_get(const wax::obj &key_, wax::obj &val){
return;
case DBOARD_PROP_SUBDEV:
- val = _dboard_manager->get_rx_subdev(name);
+ val = _dboard_manager->get_rx_subdev(key.name);
return;
case DBOARD_PROP_SUBDEV_NAMES:
@@ -90,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(name), _rx_codec_proxy->get_link()
+ _dboard_manager->get_rx_subdev(key.name),
+ _rx_codec_proxy->get_link(),
+ GAIN_GROUP_POLICY_RX
);
return;
@@ -114,8 +115,7 @@ void usrp2_mboard_impl::rx_dboard_set(const wax::obj &key, const wax::obj &val){
* TX DBoard Properties
**********************************************************************/
void usrp2_mboard_impl::tx_dboard_get(const wax::obj &key_, wax::obj &val){
- wax::obj key; std::string name;
- boost::tie(key, name) = extract_named_prop(key_);
+ named_prop_t key = named_prop_t::extract(key_);
//handle the get request conditioned on the key
switch(key.as<dboard_prop_t>()){
@@ -124,7 +124,7 @@ void usrp2_mboard_impl::tx_dboard_get(const wax::obj &key_, wax::obj &val){
return;
case DBOARD_PROP_SUBDEV:
- val = _dboard_manager->get_tx_subdev(name);
+ val = _dboard_manager->get_tx_subdev(key.name);
return;
case DBOARD_PROP_SUBDEV_NAMES:
@@ -145,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(name), _tx_codec_proxy->get_link()
+ _dboard_manager->get_tx_subdev(key.name),
+ _tx_codec_proxy->get_link(),
+ GAIN_GROUP_POLICY_TX
);
return;
diff --git a/host/lib/usrp/usrp2/dsp_impl.cpp b/host/lib/usrp/usrp2/dsp_impl.cpp
index 936b1f7a2..97bda51fc 100644
--- a/host/lib/usrp/usrp2/dsp_impl.cpp
+++ b/host/lib/usrp/usrp2/dsp_impl.cpp
@@ -17,9 +17,10 @@
#include "usrp2_impl.hpp"
#include "usrp2_regs.hpp"
-#include "../dsp_utils.hpp"
+#include <uhd/usrp/dsp_utils.hpp>
#include <uhd/usrp/dsp_props.hpp>
#include <boost/bind.hpp>
+#include <cmath>
using namespace uhd;
using namespace uhd::usrp;
@@ -30,10 +31,10 @@ static const size_t default_interp = 16;
/***********************************************************************
* DDC Helper Methods
**********************************************************************/
-template <class rate_t> static rate_t
-pick_closest_rate(double exact_rate, const std::vector<rate_t> &rates){
- rate_t closest_match = rates.at(0);
- BOOST_FOREACH(rate_t possible_rate, rates){
+template <typename rate_type>
+static rate_type pick_closest_rate(double exact_rate, const std::vector<rate_type> &rates){
+ unsigned closest_match = rates.front();
+ BOOST_FOREACH(rate_type possible_rate, rates){
if(std::abs(exact_rate - possible_rate) < std::abs(exact_rate - closest_match))
closest_match = possible_rate;
}
diff --git a/host/lib/usrp/usrp2/fw_common.h b/host/lib/usrp/usrp2/fw_common.h
index fc1e6f2a7..4d3b62d6b 100644
--- a/host/lib/usrp/usrp2/fw_common.h
+++ b/host/lib/usrp/usrp2/fw_common.h
@@ -34,7 +34,7 @@ extern "C" {
//fpga and firmware compatibility numbers
#define USRP2_FPGA_COMPAT_NUM 1
-#define USRP2_FW_COMPAT_NUM 5
+#define USRP2_FW_COMPAT_NUM 6
//used to differentiate control packets over data port
#define USRP2_INVALID_VRT_HEADER 0
diff --git a/host/lib/usrp/usrp2/mboard_impl.cpp b/host/lib/usrp/usrp2/mboard_impl.cpp
index 6c4234641..fc1cc3a9a 100644
--- a/host/lib/usrp/usrp2/mboard_impl.cpp
+++ b/host/lib/usrp/usrp2/mboard_impl.cpp
@@ -17,13 +17,15 @@
#include "usrp2_impl.hpp"
#include "usrp2_regs.hpp"
-#include "../dsp_utils.hpp"
+#include <uhd/usrp/misc_utils.hpp>
+#include <uhd/usrp/dsp_utils.hpp>
#include <uhd/usrp/mboard_props.hpp>
#include <uhd/utils/assert.hpp>
#include <uhd/utils/algorithm.hpp>
#include <uhd/types/mac_addr.hpp>
#include <uhd/types/dict.hpp>
#include <boost/bind.hpp>
+#include <boost/assign/list_of.hpp>
#include <boost/asio/ip/address_v4.hpp>
#include <iostream>
#include <boost/date_time/posix_time/posix_time.hpp>
@@ -194,12 +196,13 @@ void usrp2_mboard_impl::issue_ddc_stream_cmd(const stream_cmd_t &stream_cmd){
/***********************************************************************
* MBoard Get Properties
**********************************************************************/
+static const std::string dboard_name = "0";
+
void usrp2_mboard_impl::get(const wax::obj &key_, wax::obj &val){
- wax::obj key; std::string name;
- boost::tie(key, name) = extract_named_prop(key_);
+ named_prop_t key = named_prop_t::extract(key_);
//handle the other props
- if (key.type() == typeid(std::string)){
+ if (key_.type() == typeid(std::string)){
if (key.as<std::string>() == "mac-addr"){
byte_vector_t bytes = _iface->read_eeprom(USRP2_I2C_ADDR_MBOARD, USRP2_EE_MBOARD_MAC_ADDR, 6);
val = mac_addr_t::from_bytes(bytes).to_string();
@@ -230,25 +233,25 @@ void usrp2_mboard_impl::get(const wax::obj &key_, wax::obj &val){
return;
case MBOARD_PROP_RX_DBOARD:
- UHD_ASSERT_THROW(name == "");
+ UHD_ASSERT_THROW(key.name == dboard_name);
val = _rx_dboard_proxy->get_link();
return;
case MBOARD_PROP_RX_DBOARD_NAMES:
- val = prop_names_t(1, "");
+ val = prop_names_t(1, dboard_name);
return;
case MBOARD_PROP_TX_DBOARD:
- UHD_ASSERT_THROW(name == "");
+ UHD_ASSERT_THROW(key.name == dboard_name);
val = _tx_dboard_proxy->get_link();
return;
case MBOARD_PROP_TX_DBOARD_NAMES:
- val = prop_names_t(1, "");
+ val = prop_names_t(1, dboard_name);
return;
case MBOARD_PROP_RX_DSP:
- UHD_ASSERT_THROW(name == "");
+ UHD_ASSERT_THROW(key.name == "");
val = _rx_dsp_proxy->get_link();
return;
@@ -257,7 +260,7 @@ void usrp2_mboard_impl::get(const wax::obj &key_, wax::obj &val){
return;
case MBOARD_PROP_TX_DSP:
- UHD_ASSERT_THROW(name == "");
+ UHD_ASSERT_THROW(key.name == "");
val = _tx_dsp_proxy->get_link();
return;
@@ -333,14 +336,9 @@ void usrp2_mboard_impl::set(const wax::obj &key, const wax::obj &val){
case MBOARD_PROP_RX_SUBDEV_SPEC:
_rx_subdev_spec = val.as<subdev_spec_t>();
- //handle automatic
- if (_rx_subdev_spec.empty()) _rx_subdev_spec.push_back(
- subdev_spec_pair_t("", _dboard_manager->get_rx_subdev_names().front())
- );
+ verify_rx_subdev_spec(_rx_subdev_spec, this->get_link());
//sanity check
UHD_ASSERT_THROW(_rx_subdev_spec.size() == 1);
- uhd::assert_has((*this)[MBOARD_PROP_RX_DBOARD_NAMES].as<prop_names_t>(), _rx_subdev_spec.front().db_name, "rx dboard names");
- uhd::assert_has(_dboard_manager->get_rx_subdev_names(), _rx_subdev_spec.front().sd_name, "rx subdev names");
//set the mux
_iface->poke32(_iface->regs.dsp_rx_mux, dsp_type1::calc_rx_mux_word(
_dboard_manager->get_rx_subdev(_rx_subdev_spec.front().sd_name)[SUBDEV_PROP_CONNECTION].as<subdev_conn_t>()
@@ -349,14 +347,9 @@ void usrp2_mboard_impl::set(const wax::obj &key, const wax::obj &val){
case MBOARD_PROP_TX_SUBDEV_SPEC:
_tx_subdev_spec = val.as<subdev_spec_t>();
- //handle automatic
- if (_tx_subdev_spec.empty()) _tx_subdev_spec.push_back(
- subdev_spec_pair_t("", _dboard_manager->get_tx_subdev_names().front())
- );
+ verify_tx_subdev_spec(_tx_subdev_spec, this->get_link());
//sanity check
UHD_ASSERT_THROW(_tx_subdev_spec.size() == 1);
- uhd::assert_has((*this)[MBOARD_PROP_TX_DBOARD_NAMES].as<prop_names_t>(), _tx_subdev_spec.front().db_name, "tx dboard names");
- uhd::assert_has(_dboard_manager->get_tx_subdev_names(), _tx_subdev_spec.front().sd_name, "tx subdev names");
//set the mux
_iface->poke32(_iface->regs.dsp_tx_mux, dsp_type1::calc_tx_mux_word(
_dboard_manager->get_tx_subdev(_tx_subdev_spec.front().sd_name)[SUBDEV_PROP_CONNECTION].as<subdev_conn_t>()
diff --git a/host/lib/usrp/usrp2/usrp2_impl.cpp b/host/lib/usrp/usrp2/usrp2_impl.cpp
index 21f411afe..568c87a22 100644
--- a/host/lib/usrp/usrp2/usrp2_impl.cpp
+++ b/host/lib/usrp/usrp2/usrp2_impl.cpp
@@ -21,7 +21,7 @@
#include <uhd/usrp/device_props.hpp>
#include <uhd/utils/assert.hpp>
#include <uhd/utils/static.hpp>
-#include <boost/algorithm/string.hpp>
+#include <uhd/utils/algorithm.hpp>
#include <boost/assign/list_of.hpp>
#include <boost/format.hpp>
#include <boost/foreach.hpp>
@@ -41,12 +41,6 @@ static const size_t DISCOVERY_TIMEOUT_MS = 100;
/***********************************************************************
* Helper Functions
**********************************************************************/
-std::vector<std::string> split_addrs(const std::string &addrs_str){
- std::vector<std::string> addrs;
- boost::split(addrs, addrs_str, boost::is_any_of("\t "));
- return addrs;
-}
-
template <class T> std::string num2str(T num){
return boost::lexical_cast<std::string>(num);
}
@@ -80,7 +74,7 @@ static uhd::device_addrs_t usrp2_find(const device_addr_t &hint){
}
//if there are multiple addresses, just return good, dont test
- std::vector<std::string> addrs = split_addrs(hint["addr"]);
+ std::vector<std::string> addrs = std::split_string(hint["addr"]);
if (addrs.size() > 1){
device_addr_t new_addr;
new_addr["type"] = "usrp2";
@@ -155,7 +149,7 @@ static device::sptr usrp2_make(const device_addr_t &device_addr){
std::vector<udp_simple::sptr> ctrl_transports;
std::vector<udp_zero_copy::sptr> data_transports;
- BOOST_FOREACH(const std::string &addr, split_addrs(device_addr["addr"])){
+ BOOST_FOREACH(const std::string &addr, std::split_string(device_addr["addr"])){
ctrl_transports.push_back(udp_simple::make_connected(
addr, num2str(USRP2_UDP_CTRL_PORT)
));
@@ -207,8 +201,7 @@ usrp2_impl::~usrp2_impl(void){
* Device Properties
**********************************************************************/
void usrp2_impl::get(const wax::obj &key_, wax::obj &val){
- wax::obj key; std::string name;
- boost::tie(key, name) = extract_named_prop(key_);
+ named_prop_t key = named_prop_t::extract(key_);
//handle the get request conditioned on the key
switch(key.as<device_prop_t>()){
@@ -218,7 +211,7 @@ void usrp2_impl::get(const wax::obj &key_, wax::obj &val){
return;
case DEVICE_PROP_MBOARD:
- val = _mboard_dict[name]->get_link();
+ val = _mboard_dict[key.name]->get_link();
return;
case DEVICE_PROP_MBOARD_NAMES: