summaryrefslogtreecommitdiffstats
path: root/host/lib
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2010-03-16 13:49:39 -0700
committerJosh Blum <josh@joshknows.com>2010-03-16 13:49:39 -0700
commit8be3b883f5b1a889f4f07611e8954449cc07c2b3 (patch)
tree0622e8702105a6e43569b902b16700a0072d4cbd /host/lib
parentfc40ff2f1327d01c72c4d7dbc07a14e473251981 (diff)
downloaduhd-8be3b883f5b1a889f4f07611e8954449cc07c2b3.tar.gz
uhd-8be3b883f5b1a889f4f07611e8954449cc07c2b3.tar.bz2
uhd-8be3b883f5b1a889f4f07611e8954449cc07c2b3.zip
Added ability to set the subdevices in use for rx and tx dboards.
This is used to calculate and set the ddc and duc muxes. Also, minor fix for burning addrs (wrong pointer....)
Diffstat (limited to 'host/lib')
-rw-r--r--host/lib/usrp/dboard/basic.cpp2
-rw-r--r--host/lib/usrp/dboard_manager.cpp4
-rw-r--r--host/lib/usrp/usrp2/dboard_impl.cpp82
-rw-r--r--host/lib/usrp/usrp2/dboard_interface.cpp39
-rw-r--r--host/lib/usrp/usrp2/dboard_interface.hpp63
-rw-r--r--host/lib/usrp/usrp2/fw_common.h7
-rw-r--r--host/lib/usrp/usrp2/usrp2_impl.hpp12
7 files changed, 127 insertions, 82 deletions
diff --git a/host/lib/usrp/dboard/basic.cpp b/host/lib/usrp/dboard/basic.cpp
index 095b77ce1..5a82bf145 100644
--- a/host/lib/usrp/dboard/basic.cpp
+++ b/host/lib/usrp/dboard/basic.cpp
@@ -100,7 +100,7 @@ void basic_rx::rx_get(const wax::obj &key_, wax::obj &val){
//handle the get request conditioned on the key
switch(key.as<subdev_prop_t>()){
case SUBDEV_PROP_NAME:
- val = std::string(str(boost::format("%s:%s")
+ val = std::string(str(boost::format("%s - %s")
% dboard_id::to_string(get_rx_id())
% get_subdev_name()
));
diff --git a/host/lib/usrp/dboard_manager.cpp b/host/lib/usrp/dboard_manager.cpp
index eeabbda99..6ca15e98c 100644
--- a/host/lib/usrp/dboard_manager.cpp
+++ b/host/lib/usrp/dboard_manager.cpp
@@ -46,7 +46,7 @@ void dboard_manager::register_dboard(
//std::cout << "registering: " << name << std::endl;
if (get_id_to_args_map().has_key(dboard_id)){
throw std::runtime_error(str(boost::format(
- "The dboard id 0x%.4x is already registered to %s."
+ "The dboard id 0x%04x is already registered to %s."
) % dboard_id % dboard_id::to_string(dboard_id)));
}
get_id_to_args_map()[dboard_id] = args_t(dboard_ctor, name, subdev_names);
@@ -54,7 +54,7 @@ void dboard_manager::register_dboard(
std::string dboard_id::to_string(const dboard_id_t &id){
std::string name = (get_id_to_args_map().has_key(id))? get_id_to_args_map()[id].get<1>() : "unknown";
- return str(boost::format("%s (0x%.4x)") % name % id);
+ return str(boost::format("%s (0x%04x)") % name % id);
}
/***********************************************************************
diff --git a/host/lib/usrp/usrp2/dboard_impl.cpp b/host/lib/usrp/usrp2/dboard_impl.cpp
index 6d957436e..502a7daa0 100644
--- a/host/lib/usrp/usrp2/dboard_impl.cpp
+++ b/host/lib/usrp/usrp2/dboard_impl.cpp
@@ -18,7 +18,6 @@
#include <uhd/utils.hpp>
#include <boost/format.hpp>
#include "usrp2_impl.hpp"
-#include "dboard_interface.hpp"
using namespace uhd;
using namespace uhd::usrp;
@@ -32,23 +31,16 @@ void usrp2_impl::dboard_init(void){
out_data.id = htonl(USRP2_CTRL_ID_GIVE_ME_YOUR_DBOARD_IDS_BRO);
usrp2_ctrl_data_t in_data = ctrl_send_and_recv(out_data);
ASSERT_THROW(htonl(in_data.id) == USRP2_CTRL_ID_THESE_ARE_MY_DBOARD_IDS_DUDE);
- std::cout << boost::format("rx id 0x%.2x, tx id 0x%.2x")
- % ntohs(in_data.data.dboard_ids.rx_id)
- % ntohs(in_data.data.dboard_ids.tx_id) << std::endl;
- //extract the dboard ids an convert them to enums
- dboard_id_t rx_dboard_id = static_cast<dboard_id_t>(
- ntohs(in_data.data.dboard_ids.rx_id)
- );
- dboard_id_t tx_dboard_id = static_cast<dboard_id_t>(
- ntohs(in_data.data.dboard_ids.tx_id)
- );
+ //extract the dboard ids an convert them
+ dboard_id_t rx_dboard_id = ntohs(in_data.data.dboard_ids.rx_id);
+ dboard_id_t tx_dboard_id = ntohs(in_data.data.dboard_ids.tx_id);
//create a new dboard interface and manager
dboard_interface::sptr _dboard_interface(
- new usrp2_dboard_interface(this)
+ make_usrp2_dboard_interface(this)
);
- dboard_manager::sptr _dboard_manager = dboard_manager::make(
+ _dboard_manager = dboard_manager::make(
rx_dboard_id, tx_dboard_id, _dboard_interface
);
@@ -61,6 +53,46 @@ void usrp2_impl::dboard_init(void){
boost::bind(&usrp2_impl::tx_dboard_get, this, _1, _2),
boost::bind(&usrp2_impl::tx_dboard_set, this, _1, _2)
);
+
+ //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));
+ _tx_subdevs_in_use = prop_names_t(1, _dboard_manager->get_tx_subdev_names().at(0));
+ update_mux_config();
+}
+
+void usrp2_impl::update_mux_config(void){
+ //calculate the rx mux
+ uint32_t rx_mux = 0;
+ 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);
+ }
+
+ //calculate the tx mux
+ uint32_t tx_mux = 0x10;
+ 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) & 0x1) << 1) | (((tx_mux >> 1) & 0x1) << 0);
+ }
+
+ //setup the out data
+ usrp2_ctrl_data_t out_data;
+ out_data.id = htonl(USRP2_CTRL_ID_UPDATE_THOSE_MUX_SETTINGS_BRO);
+ out_data.data.mux_args.rx_mux = htonl(rx_mux);
+ out_data.data.mux_args.tx_mux = htonl(tx_mux);
+
+ //send and recv
+ usrp2_ctrl_data_t in_data = ctrl_send_and_recv(out_data);
+ ASSERT_THROW(htonl(in_data.id) == USRP2_CTRL_ID_UPDATED_THE_MUX_SETTINGS_DUDE);
}
/***********************************************************************
@@ -84,12 +116,22 @@ void usrp2_impl::rx_dboard_get(const wax::obj &key_, wax::obj &val){
val = _dboard_manager->get_rx_subdev_names();
return;
+ case DBOARD_PROP_USED_SUBDEVS:
+ val = _rx_subdevs_in_use;
+ return;
+
//case DBOARD_PROP_CODEC:
// throw std::runtime_error("unhandled prop in usrp2 dboard");
}
}
-void usrp2_impl::rx_dboard_set(const wax::obj &, const wax::obj &){
+void usrp2_impl::rx_dboard_set(const wax::obj &key, const wax::obj &val){
+ if (key.as<dboard_prop_t>() == DBOARD_PROP_USED_SUBDEVS){
+ _rx_subdevs_in_use = val.as<prop_names_t>();
+ update_mux_config(); //if the val is bad, this will throw
+ return;
+ }
+
throw std::runtime_error("Cannot set on usrp2 dboard");
}
@@ -114,11 +156,21 @@ void usrp2_impl::tx_dboard_get(const wax::obj &key_, wax::obj &val){
val = _dboard_manager->get_tx_subdev_names();
return;
+ case DBOARD_PROP_USED_SUBDEVS:
+ val = _tx_subdevs_in_use;
+ return;
+
//case DBOARD_PROP_CODEC:
// throw std::runtime_error("unhandled prop in usrp2 dboard");
}
}
-void usrp2_impl::tx_dboard_set(const wax::obj &, const wax::obj &){
+void usrp2_impl::tx_dboard_set(const wax::obj &key, const wax::obj &val){
+ if (key.as<dboard_prop_t>() == DBOARD_PROP_USED_SUBDEVS){
+ _tx_subdevs_in_use = val.as<prop_names_t>();
+ update_mux_config(); //if the val is bad, this will throw
+ return;
+ }
+
throw std::runtime_error("Cannot set on usrp2 dboard");
}
diff --git a/host/lib/usrp/usrp2/dboard_interface.cpp b/host/lib/usrp/usrp2/dboard_interface.cpp
index f12b101f3..cefd69ba9 100644
--- a/host/lib/usrp/usrp2/dboard_interface.cpp
+++ b/host/lib/usrp/usrp2/dboard_interface.cpp
@@ -16,11 +16,48 @@
//
#include <uhd/utils.hpp>
-#include "dboard_interface.hpp"
#include "usrp2_impl.hpp"
using namespace uhd::usrp;
+class usrp2_dboard_interface : public dboard_interface{
+public:
+ usrp2_dboard_interface(usrp2_impl *impl);
+ ~usrp2_dboard_interface(void);
+
+ void write_aux_dac(unit_type_t, int, int);
+ int read_aux_adc(unit_type_t, int);
+
+ void set_atr_reg(gpio_bank_t, uint16_t, uint16_t, uint16_t);
+ void set_gpio_ddr(gpio_bank_t, uint16_t, uint16_t);
+ void write_gpio(gpio_bank_t, uint16_t, uint16_t);
+ uint16_t read_gpio(gpio_bank_t);
+
+ void write_i2c(int, const byte_vector_t &);
+ byte_vector_t read_i2c(int, size_t);
+
+ double get_rx_clock_rate(void);
+ double get_tx_clock_rate(void);
+
+private:
+ byte_vector_t transact_spi(
+ spi_dev_t dev,
+ spi_latch_t latch,
+ spi_push_t push,
+ const byte_vector_t &buf,
+ bool readback
+ );
+
+ usrp2_impl *_impl;
+};
+
+/***********************************************************************
+ * Make Function
+ **********************************************************************/
+dboard_interface::sptr make_usrp2_dboard_interface(usrp2_impl *impl){
+ return dboard_interface::sptr(new usrp2_dboard_interface(impl));
+}
+
/***********************************************************************
* Structors
**********************************************************************/
diff --git a/host/lib/usrp/usrp2/dboard_interface.hpp b/host/lib/usrp/usrp2/dboard_interface.hpp
deleted file mode 100644
index a06359e5e..000000000
--- a/host/lib/usrp/usrp2/dboard_interface.hpp
+++ /dev/null
@@ -1,63 +0,0 @@
-//
-// 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/usrp/dboard_interface.hpp>
-
-#ifndef INCLUDED_DBOARD_INTERFACE_HPP
-#define INCLUDED_DBOARD_INTERFACE_HPP
-
-class usrp2_impl; //dummy class declaration
-
-class usrp2_dboard_interface : public uhd::usrp::dboard_interface{
-public:
- usrp2_dboard_interface(usrp2_impl *impl);
-
- ~usrp2_dboard_interface(void);
-
- void write_aux_dac(unit_type_t, int, int);
-
- int read_aux_adc(unit_type_t, int);
-
- void set_atr_reg(gpio_bank_t, uint16_t, uint16_t, uint16_t);
-
- void set_gpio_ddr(gpio_bank_t, uint16_t, uint16_t);
-
- void write_gpio(gpio_bank_t, uint16_t, uint16_t);
-
- uint16_t read_gpio(gpio_bank_t);
-
- void write_i2c(int, const byte_vector_t &);
-
- byte_vector_t read_i2c(int, size_t);
-
- double get_rx_clock_rate(void);
-
- double get_tx_clock_rate(void);
-
-private:
- byte_vector_t transact_spi(
- spi_dev_t dev,
- spi_latch_t latch,
- spi_push_t push,
- const byte_vector_t &buf,
- bool readback
- );
-
- usrp2_impl *_impl;
-};
-
-#endif /* INCLUDED_DBOARD_INTERFACE_HPP */
diff --git a/host/lib/usrp/usrp2/fw_common.h b/host/lib/usrp/usrp2/fw_common.h
index 10c1ef8cf..03e8d3a37 100644
--- a/host/lib/usrp/usrp2/fw_common.h
+++ b/host/lib/usrp/usrp2/fw_common.h
@@ -94,6 +94,9 @@ typedef enum{
USRP2_CTRL_ID_GOT_A_NEW_TIME_FOR_YOU_BRO,
USRP2_CTRL_ID_SWEET_I_GOT_THAT_TIME_DUDE,
+ USRP2_CTRL_ID_UPDATE_THOSE_MUX_SETTINGS_BRO,
+ USRP2_CTRL_ID_UPDATED_THE_MUX_SETTINGS_DUDE,
+
USRP2_CTRL_ID_PEACE_OUT
} usrp2_ctrl_id_t;
@@ -194,6 +197,10 @@ typedef struct{
uint32_t ticks;
uint8_t now;
} time_args;
+ struct {
+ uint32_t rx_mux;
+ uint32_t tx_mux;
+ } mux_args;
} data;
} usrp2_ctrl_data_t;
diff --git a/host/lib/usrp/usrp2/usrp2_impl.hpp b/host/lib/usrp/usrp2/usrp2_impl.hpp
index fc713c2bf..2c6b6f8c9 100644
--- a/host/lib/usrp/usrp2/usrp2_impl.hpp
+++ b/host/lib/usrp/usrp2/usrp2_impl.hpp
@@ -31,6 +31,15 @@
#ifndef INCLUDED_USRP2_IMPL_HPP
#define INCLUDED_USRP2_IMPL_HPP
+class usrp2_impl; //dummy class declaration
+
+/*!
+ * Make a usrp2 dboard interface.
+ * \param impl a pointer to the usrp2 impl object
+ * \return a sptr to a new dboard interface
+ */
+uhd::usrp::dboard_interface::sptr make_usrp2_dboard_interface(usrp2_impl *impl);
+
/*!
* Simple wax obj proxy class:
* Provides a wax obj interface for a set and a get function.
@@ -156,11 +165,14 @@ private:
void rx_dboard_get(const wax::obj &, wax::obj &);
void rx_dboard_set(const wax::obj &, const wax::obj &);
uhd::dict<std::string, wax_obj_proxy> _rx_dboards;
+ uhd::prop_names_t _rx_subdevs_in_use;
//properties interface for tx dboard
void tx_dboard_get(const wax::obj &, wax::obj &);
void tx_dboard_set(const wax::obj &, const wax::obj &);
uhd::dict<std::string, wax_obj_proxy> _tx_dboards;
+ uhd::prop_names_t _tx_subdevs_in_use;
+ void update_mux_config(void);
//methods and shadows for the ddc dsp
std::vector<size_t> _allowed_decim_and_interp_rates;