summaryrefslogtreecommitdiffstats
path: root/host
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2010-08-15 18:49:06 -0700
committerJosh Blum <josh@joshknows.com>2010-08-15 18:49:06 -0700
commit5c0d3d30606b25c72c98785d49c13cc27ad49ec1 (patch)
tree3abc29f89c400fe03551c06b79ffc6973dbc78bb /host
parent2e978d8835b8f954b7c34c42138b64d3a5767f81 (diff)
downloaduhd-5c0d3d30606b25c72c98785d49c13cc27ad49ec1.tar.gz
uhd-5c0d3d30606b25c72c98785d49c13cc27ad49ec1.tar.bz2
uhd-5c0d3d30606b25c72c98785d49c13cc27ad49ec1.zip
usrp1: created daughterboard duality
everything that should have two is now stored into a dictionary of slot to type the set and get functions are now bound with a third argument for dboard slot the dboard iface has yet to be completed with the correct registers for a vs b
Diffstat (limited to 'host')
-rw-r--r--host/lib/usrp/usrp1/codec_ctrl.cpp16
-rw-r--r--host/lib/usrp/usrp1/codec_ctrl.hpp3
-rw-r--r--host/lib/usrp/usrp1/codec_impl.cpp42
-rw-r--r--host/lib/usrp/usrp1/dboard_iface.cpp28
-rw-r--r--host/lib/usrp/usrp1/dboard_impl.cpp148
-rw-r--r--host/lib/usrp/usrp1/dsp_impl.cpp55
-rw-r--r--host/lib/usrp/usrp1/mboard_impl.cpp21
-rw-r--r--host/lib/usrp/usrp1/usrp1_impl.cpp13
-rw-r--r--host/lib/usrp/usrp1/usrp1_impl.hpp103
9 files changed, 246 insertions, 183 deletions
diff --git a/host/lib/usrp/usrp1/codec_ctrl.cpp b/host/lib/usrp/usrp1/codec_ctrl.cpp
index d0576a769..01617de94 100644
--- a/host/lib/usrp/usrp1/codec_ctrl.cpp
+++ b/host/lib/usrp/usrp1/codec_ctrl.cpp
@@ -17,8 +17,6 @@
#include "codec_ctrl.hpp"
#include "usrp_commands.h"
-#include "fpga_regs_standard.h"
-#include "usrp_spi_defs.h"
#include "ad9862_regs.hpp"
#include <uhd/types/dict.hpp>
#include <uhd/utils/assert.hpp>
@@ -45,7 +43,7 @@ const gain_range_t usrp1_codec_ctrl::rx_pga_gain_range(0, 20, 1);
class usrp1_codec_ctrl_impl : public usrp1_codec_ctrl {
public:
//structors
- usrp1_codec_ctrl_impl(usrp1_iface::sptr iface);
+ usrp1_codec_ctrl_impl(usrp1_iface::sptr iface, int spi_slave);
~usrp1_codec_ctrl_impl(void);
//aux adc and dac control
@@ -63,6 +61,7 @@ public:
private:
usrp1_iface::sptr _iface;
+ int _spi_slave;
ad9862_regs_t _ad9862_regs;
aux_adc_t _last_aux_adc_a, _last_aux_adc_b;
void send_reg(boost::uint8_t addr);
@@ -78,9 +77,10 @@ private:
/***********************************************************************
* Codec Control Structors
**********************************************************************/
-usrp1_codec_ctrl_impl::usrp1_codec_ctrl_impl(usrp1_iface::sptr iface)
+usrp1_codec_ctrl_impl::usrp1_codec_ctrl_impl(usrp1_iface::sptr iface, int spi_slave)
{
_iface = iface;
+ _spi_slave = spi_slave;
//soft reset
_ad9862_regs.soft_reset = 1;
@@ -295,7 +295,7 @@ void usrp1_codec_ctrl_impl::send_reg(boost::uint8_t addr)
std::cout << "codec control write reg: 0x";
std::cout << std::setw(8) << std::hex << reg << std::endl;
}
- _iface->transact_spi(SPI_ENABLE_CODEC_A,
+ _iface->transact_spi(_spi_slave,
spi_config_t::EDGE_RISE, reg, 16, false);
}
@@ -309,7 +309,7 @@ void usrp1_codec_ctrl_impl::recv_reg(boost::uint8_t addr)
std::cout << std::setw(8) << std::hex << reg << std::endl;
}
- boost::uint32_t ret = _iface->transact_spi(SPI_ENABLE_CODEC_A,
+ boost::uint32_t ret = _iface->transact_spi(_spi_slave,
spi_config_t::EDGE_RISE, reg, 16, true);
if (codec_debug) {
@@ -435,7 +435,7 @@ bool usrp1_codec_ctrl_impl::set_duc_freq(double freq)
/***********************************************************************
* Codec Control Make
**********************************************************************/
-usrp1_codec_ctrl::sptr usrp1_codec_ctrl::make(usrp1_iface::sptr iface)
+usrp1_codec_ctrl::sptr usrp1_codec_ctrl::make(usrp1_iface::sptr iface, int spi_slave)
{
- return sptr(new usrp1_codec_ctrl_impl(iface));
+ return sptr(new usrp1_codec_ctrl_impl(iface, spi_slave));
}
diff --git a/host/lib/usrp/usrp1/codec_ctrl.hpp b/host/lib/usrp/usrp1/codec_ctrl.hpp
index 0605e3228..6440f97d1 100644
--- a/host/lib/usrp/usrp1/codec_ctrl.hpp
+++ b/host/lib/usrp/usrp1/codec_ctrl.hpp
@@ -38,9 +38,10 @@ public:
/*!
* Make a new clock control object.
* \param iface the usrp1 iface object
+ * \param spi_slave which spi device
* \return the clock control object
*/
- static sptr make(usrp1_iface::sptr iface);
+ static sptr make(usrp1_iface::sptr iface, int spi_slave);
//! aux adc identifier constants
enum aux_adc_t{
diff --git a/host/lib/usrp/usrp1/codec_impl.cpp b/host/lib/usrp/usrp1/codec_impl.cpp
index 7bf5631fb..766a7948f 100644
--- a/host/lib/usrp/usrp1/codec_impl.cpp
+++ b/host/lib/usrp/usrp1/codec_impl.cpp
@@ -19,6 +19,8 @@
#include <uhd/utils/assert.hpp>
#include <uhd/usrp/codec_props.hpp>
#include <boost/bind.hpp>
+#include <boost/foreach.hpp>
+#include <boost/format.hpp>
using namespace uhd;
using namespace uhd::usrp;
@@ -29,13 +31,15 @@ using namespace uhd::usrp;
void usrp1_impl::codec_init(void)
{
//make proxies
- _rx_codec_proxy = wax_obj_proxy::make(
- boost::bind(&usrp1_impl::rx_codec_get, this, _1, _2),
- boost::bind(&usrp1_impl::rx_codec_set, this, _1, _2));
-
- _tx_codec_proxy = wax_obj_proxy::make(
- boost::bind(&usrp1_impl::tx_codec_get, this, _1, _2),
- boost::bind(&usrp1_impl::tx_codec_set, this, _1, _2));
+ BOOST_FOREACH(dboard_slot_t dboard_slot, _dboard_slots){
+ _rx_codec_proxies[dboard_slot] = wax_obj_proxy::make(
+ boost::bind(&usrp1_impl::rx_codec_get, this, _1, _2, dboard_slot),
+ boost::bind(&usrp1_impl::rx_codec_set, this, _1, _2, dboard_slot));
+
+ _tx_codec_proxies[dboard_slot] = wax_obj_proxy::make(
+ boost::bind(&usrp1_impl::tx_codec_get, this, _1, _2, dboard_slot),
+ boost::bind(&usrp1_impl::tx_codec_set, this, _1, _2, dboard_slot));
+ }
}
/***********************************************************************
@@ -43,14 +47,14 @@ void usrp1_impl::codec_init(void)
**********************************************************************/
static const std::string ad9862_pga_gain_name = "ad9862 pga";
-void usrp1_impl::rx_codec_get(const wax::obj &key_, wax::obj &val)
+void usrp1_impl::rx_codec_get(const wax::obj &key_, wax::obj &val, dboard_slot_t dboard_slot)
{
named_prop_t key = named_prop_t::extract(key_);
//handle the get request conditioned on the key
switch(key.as<codec_prop_t>()) {
case CODEC_PROP_NAME:
- val = std::string("usrp1 adc - ad9862");
+ val = str(boost::format("usrp1 adc - ad9862 - slot %c") % dboard_slot);
return;
case CODEC_PROP_OTHERS:
@@ -68,19 +72,19 @@ void usrp1_impl::rx_codec_get(const wax::obj &key_, wax::obj &val)
case CODEC_PROP_GAIN_I:
UHD_ASSERT_THROW(key.name == ad9862_pga_gain_name);
- val = _codec_ctrl->get_rx_pga_gain('A');
+ val = _codec_ctrls[dboard_slot]->get_rx_pga_gain('A');
return;
case CODEC_PROP_GAIN_Q:
UHD_ASSERT_THROW(key.name == ad9862_pga_gain_name);
- val = _codec_ctrl->get_rx_pga_gain('B');
+ val = _codec_ctrls[dboard_slot]->get_rx_pga_gain('B');
return;
default: UHD_THROW_PROP_GET_ERROR();
}
}
-void usrp1_impl::rx_codec_set(const wax::obj &key_, const wax::obj &val)
+void usrp1_impl::rx_codec_set(const wax::obj &key_, const wax::obj &val, dboard_slot_t dboard_slot)
{
named_prop_t key = named_prop_t::extract(key_);
@@ -88,12 +92,12 @@ void usrp1_impl::rx_codec_set(const wax::obj &key_, const wax::obj &val)
switch(key.as<codec_prop_t>()) {
case CODEC_PROP_GAIN_I:
UHD_ASSERT_THROW(key.name == ad9862_pga_gain_name);
- _codec_ctrl->set_rx_pga_gain(val.as<float>(), 'A');
+ _codec_ctrls[dboard_slot]->set_rx_pga_gain(val.as<float>(), 'A');
return;
case CODEC_PROP_GAIN_Q:
UHD_ASSERT_THROW(key.name == ad9862_pga_gain_name);
- _codec_ctrl->set_rx_pga_gain(val.as<float>(), 'B');
+ _codec_ctrls[dboard_slot]->set_rx_pga_gain(val.as<float>(), 'B');
return;
default: UHD_THROW_PROP_SET_ERROR();
@@ -103,14 +107,14 @@ void usrp1_impl::rx_codec_set(const wax::obj &key_, const wax::obj &val)
/***********************************************************************
* TX Codec Properties
**********************************************************************/
-void usrp1_impl::tx_codec_get(const wax::obj &key_, wax::obj &val)
+void usrp1_impl::tx_codec_get(const wax::obj &key_, wax::obj &val, dboard_slot_t dboard_slot)
{
named_prop_t key = named_prop_t::extract(key_);
//handle the get request conditioned on the key
switch(key.as<codec_prop_t>()) {
case CODEC_PROP_NAME:
- val = std::string("usrp1 dac - ad9862");
+ val = str(boost::format("usrp1 dac - ad9862 - slot %c") % dboard_slot);
return;
case CODEC_PROP_OTHERS:
@@ -129,14 +133,14 @@ void usrp1_impl::tx_codec_get(const wax::obj &key_, wax::obj &val)
case CODEC_PROP_GAIN_I: //only one gain for I and Q
case CODEC_PROP_GAIN_Q:
UHD_ASSERT_THROW(key.name == ad9862_pga_gain_name);
- val = _codec_ctrl->get_tx_pga_gain();
+ val = _codec_ctrls[dboard_slot]->get_tx_pga_gain();
return;
default: UHD_THROW_PROP_GET_ERROR();
}
}
-void usrp1_impl::tx_codec_set(const wax::obj &key_, const wax::obj &val)
+void usrp1_impl::tx_codec_set(const wax::obj &key_, const wax::obj &val, dboard_slot_t dboard_slot)
{
named_prop_t key = named_prop_t::extract(key_);
@@ -145,7 +149,7 @@ void usrp1_impl::tx_codec_set(const wax::obj &key_, const wax::obj &val)
case CODEC_PROP_GAIN_I: //only one gain for I and Q
case CODEC_PROP_GAIN_Q:
UHD_ASSERT_THROW(key.name == ad9862_pga_gain_name);
- _codec_ctrl->set_tx_pga_gain(val.as<float>());
+ _codec_ctrls[dboard_slot]->set_tx_pga_gain(val.as<float>());
return;
default: UHD_THROW_PROP_SET_ERROR();
diff --git a/host/lib/usrp/usrp1/dboard_iface.cpp b/host/lib/usrp/usrp1/dboard_iface.cpp
index ef6a1e67b..82ef9e65b 100644
--- a/host/lib/usrp/usrp1/dboard_iface.cpp
+++ b/host/lib/usrp/usrp1/dboard_iface.cpp
@@ -16,6 +16,7 @@
//
#include "usrp1_iface.hpp"
+#include "usrp1_impl.hpp"
#include "fpga_regs_common.h"
#include "usrp_spi_defs.h"
#include "clock_ctrl.hpp"
@@ -30,16 +31,27 @@ using namespace uhd;
using namespace uhd::usrp;
using namespace boost::assign;
+/***********************************************************************
+ * TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO
+ * TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO
+ * TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO
+ * TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO
+ *
+ * check the _dboard_slot and handle conditionally...
+ **********************************************************************/
+
class usrp1_dboard_iface : public dboard_iface {
public:
usrp1_dboard_iface(usrp1_iface::sptr iface,
usrp1_clock_ctrl::sptr clock,
- usrp1_codec_ctrl::sptr codec)
- {
+ usrp1_codec_ctrl::sptr codec,
+ usrp1_impl::dboard_slot_t dboard_slot
+ ){
_iface = iface;
_clock = clock;
_codec = codec;
+ _dboard_slot = dboard_slot;
//init the clock rate shadows
this->set_clock_rate(UNIT_RX, _clock->get_master_clock_freq());
@@ -55,7 +67,7 @@ public:
{
special_props_t props;
props.soft_clock_divider = true;
- props.mangle_i2c_addrs = false; //TODO true on side B
+ props.mangle_i2c_addrs = (_dboard_slot == usrp1_impl::DBOARD_SLOT_B);
return props;
}
@@ -91,16 +103,18 @@ private:
usrp1_clock_ctrl::sptr _clock;
usrp1_codec_ctrl::sptr _codec;
uhd::dict<unit_t, double> _clock_rates;
+ usrp1_impl::dboard_slot_t _dboard_slot;
};
/***********************************************************************
* Make Function
**********************************************************************/
-dboard_iface::sptr make_usrp1_dboard_iface(usrp1_iface::sptr iface,
+dboard_iface::sptr usrp1_impl::make_dboard_iface(usrp1_iface::sptr iface,
usrp1_clock_ctrl::sptr clock,
- usrp1_codec_ctrl::sptr codec)
-{
- return dboard_iface::sptr(new usrp1_dboard_iface(iface, clock, codec));
+ usrp1_codec_ctrl::sptr codec,
+ usrp1_impl::dboard_slot_t dboard_slot
+){
+ return dboard_iface::sptr(new usrp1_dboard_iface(iface, clock, codec, dboard_slot));
}
/***********************************************************************
diff --git a/host/lib/usrp/usrp1/dboard_impl.cpp b/host/lib/usrp/usrp1/dboard_impl.cpp
index 9df87432d..ba826d2f5 100644
--- a/host/lib/usrp/usrp1/dboard_impl.cpp
+++ b/host/lib/usrp/usrp1/dboard_impl.cpp
@@ -23,96 +23,107 @@
#include <uhd/usrp/dboard_props.hpp>
#include <uhd/usrp/subdev_props.hpp>
#include <boost/bind.hpp>
+#include <boost/foreach.hpp>
+#include <boost/format.hpp>
#include <iostream>
using namespace uhd;
using namespace uhd::usrp;
/***********************************************************************
- * Dboard Initialization
+ * Helper Functions
**********************************************************************/
-void usrp1_impl::dboard_init(void)
-{
- _rx_db_eeprom = dboard_eeprom_t(
- _iface->read_eeprom(I2C_ADDR_RX_A, 0, dboard_eeprom_t::num_bytes()));
-
- _tx_db_eeprom = dboard_eeprom_t(
- _iface->read_eeprom(I2C_ADDR_TX_A, 0, dboard_eeprom_t::num_bytes()));
-
-
- //create a new dboard interface and manager
- _dboard_iface = make_usrp1_dboard_iface(_iface, _clock_ctrl, _codec_ctrl);
-
- _dboard_manager = dboard_manager::make(_rx_db_eeprom.id,
- _tx_db_eeprom.id,
- _dboard_iface);
-
- //setup the dboard proxies
- _rx_dboard_proxy = wax_obj_proxy::make(
- boost::bind(&usrp1_impl::rx_dboard_get, this, _1, _2),
- boost::bind(&usrp1_impl::rx_dboard_set, this, _1, _2));
-
- _tx_dboard_proxy = wax_obj_proxy::make(
- boost::bind(&usrp1_impl::tx_dboard_get, this, _1, _2),
- boost::bind(&usrp1_impl::tx_dboard_set, this, _1, _2));
+static boost::uint8_t get_rx_ee_addr(usrp1_impl::dboard_slot_t dboard_slot){
+ switch(dboard_slot){
+ case usrp1_impl::DBOARD_SLOT_A: return I2C_ADDR_RX_A;
+ case usrp1_impl::DBOARD_SLOT_B: return I2C_ADDR_RX_B;
+ default: UHD_THROW_INVALID_CODE_PATH();
+ }
+}
+static boost::uint8_t get_tx_ee_addr(usrp1_impl::dboard_slot_t dboard_slot){
+ switch(dboard_slot){
+ case usrp1_impl::DBOARD_SLOT_A: return I2C_ADDR_TX_A;
+ case usrp1_impl::DBOARD_SLOT_B: return I2C_ADDR_TX_B;
+ default: UHD_THROW_INVALID_CODE_PATH();
+ }
}
+
/***********************************************************************
- * Helper functions
+ * Dboard Initialization
**********************************************************************/
-//static int slot_to_i2c_addr (int slot)
-//{
-// switch (slot) {
-// case SLOT_TX_A:
-// return I2C_ADDR_TX_A;
-// case SLOT_RX_A:
-// return I2C_ADDR_RX_A;
-// case SLOT_TX_B:
-// return I2C_ADDR_TX_B;
-// case SLOT_RX_B:
-// return I2C_ADDR_RX_B;
-// default:
-// return -1;
-// }
-//}
+void usrp1_impl::dboard_init(void)
+{
+ BOOST_FOREACH(dboard_slot_t dboard_slot, _dboard_slots){
+
+ //read the tx and rx dboard eeproms
+ _rx_db_eeproms[dboard_slot] = dboard_eeprom_t(_iface->read_eeprom(
+ get_rx_ee_addr(dboard_slot), 0, dboard_eeprom_t::num_bytes()
+ ));
+
+ _tx_db_eeproms[dboard_slot] = dboard_eeprom_t(_iface->read_eeprom(
+ get_tx_ee_addr(dboard_slot), 0, dboard_eeprom_t::num_bytes()
+ ));
+
+ //create a new dboard interface and manager
+ _dboard_ifaces[dboard_slot] = make_dboard_iface(
+ _iface, _clock_ctrl, _codec_ctrls[dboard_slot], dboard_slot
+ );
+
+ _dboard_managers[dboard_slot] = dboard_manager::make(
+ _rx_db_eeproms[dboard_slot].id,
+ _tx_db_eeproms[dboard_slot].id,
+ _dboard_ifaces[dboard_slot]
+ );
+
+ //setup the dboard proxies
+ _rx_dboard_proxies[dboard_slot] = wax_obj_proxy::make(
+ boost::bind(&usrp1_impl::rx_dboard_get, this, _1, _2, dboard_slot),
+ boost::bind(&usrp1_impl::rx_dboard_set, this, _1, _2, dboard_slot));
+
+ _tx_dboard_proxies[dboard_slot] = wax_obj_proxy::make(
+ boost::bind(&usrp1_impl::tx_dboard_get, this, _1, _2, dboard_slot),
+ boost::bind(&usrp1_impl::tx_dboard_set, this, _1, _2, dboard_slot));
+ }
+}
/***********************************************************************
* RX Dboard Get
**********************************************************************/
-void usrp1_impl::rx_dboard_get(const wax::obj &key_, wax::obj &val)
+void usrp1_impl::rx_dboard_get(const wax::obj &key_, wax::obj &val, dboard_slot_t dboard_slot)
{
named_prop_t key = named_prop_t::extract(key_);
//handle the get request conditioned on the key
switch(key.as<dboard_prop_t>()){
case DBOARD_PROP_NAME:
- val = std::string("usrp1 dboard (rx unit)");
+ val = str(boost::format("usrp1 dboard (rx unit) - %c") % dboard_slot);
return;
case DBOARD_PROP_SUBDEV:
- val = _dboard_manager->get_rx_subdev(key.name);
+ val = _dboard_managers[dboard_slot]->get_rx_subdev(key.name);
return;
case DBOARD_PROP_SUBDEV_NAMES:
- val = _dboard_manager->get_rx_subdev_names();
+ val = _dboard_managers[dboard_slot]->get_rx_subdev_names();
return;
case DBOARD_PROP_DBOARD_ID:
- val = _rx_db_eeprom.id;
+ val = _rx_db_eeproms[dboard_slot].id;
return;
case DBOARD_PROP_DBOARD_IFACE:
- val = _dboard_iface;
+ val = _dboard_ifaces[dboard_slot];
return;
case DBOARD_PROP_CODEC:
- val = _rx_codec_proxy->get_link();
+ val = _rx_codec_proxies[dboard_slot]->get_link();
return;
case DBOARD_PROP_GAIN_GROUP:
- val = make_gain_group(_dboard_manager->get_rx_subdev(key.name),
- _rx_codec_proxy->get_link());
+ val = make_gain_group(_dboard_managers[dboard_slot]->get_rx_subdev(key.name),
+ _rx_codec_proxies[dboard_slot]->get_link());
return;
default: UHD_THROW_PROP_GET_ERROR();
@@ -122,13 +133,15 @@ void usrp1_impl::rx_dboard_get(const wax::obj &key_, wax::obj &val)
/***********************************************************************
* RX Dboard Set
**********************************************************************/
-void usrp1_impl::rx_dboard_set(const wax::obj &key, const wax::obj &val)
+void usrp1_impl::rx_dboard_set(const wax::obj &key, const wax::obj &val, dboard_slot_t dboard_slot)
{
switch(key.as<dboard_prop_t>()) {
case DBOARD_PROP_DBOARD_ID:
- _rx_db_eeprom.id = val.as<dboard_id_t>();
- _iface->write_eeprom(I2C_ADDR_RX_A, 0,
- _rx_db_eeprom.get_eeprom_bytes());
+ _rx_db_eeproms[dboard_slot].id = val.as<dboard_id_t>();
+ _iface->write_eeprom(
+ get_rx_ee_addr(dboard_slot), 0,
+ _rx_db_eeproms[dboard_slot].get_eeprom_bytes()
+ );
return;
default:
@@ -139,39 +152,39 @@ void usrp1_impl::rx_dboard_set(const wax::obj &key, const wax::obj &val)
/***********************************************************************
* TX Dboard Get
**********************************************************************/
-void usrp1_impl::tx_dboard_get(const wax::obj &key_, wax::obj &val)
+void usrp1_impl::tx_dboard_get(const wax::obj &key_, wax::obj &val, dboard_slot_t dboard_slot)
{
named_prop_t key = named_prop_t::extract(key_);
//handle the get request conditioned on the key
switch(key.as<dboard_prop_t>()){
case DBOARD_PROP_NAME:
- val = std::string("usrp1 dboard (tx unit)");
+ val = str(boost::format("usrp1 dboard (tx unit) - %c") % dboard_slot);
return;
case DBOARD_PROP_SUBDEV:
- val = _dboard_manager->get_tx_subdev(key.name);
+ val = _dboard_managers[dboard_slot]->get_tx_subdev(key.name);
return;
case DBOARD_PROP_SUBDEV_NAMES:
- val = _dboard_manager->get_tx_subdev_names();
+ val = _dboard_managers[dboard_slot]->get_tx_subdev_names();
return;
case DBOARD_PROP_DBOARD_ID:
- val = _tx_db_eeprom.id;
+ val = _tx_db_eeproms[dboard_slot].id;
return;
case DBOARD_PROP_DBOARD_IFACE:
- val = _dboard_iface;
+ val = _dboard_ifaces[dboard_slot];
return;
case DBOARD_PROP_CODEC:
- val = _tx_codec_proxy->get_link();
+ val = _tx_codec_proxies[dboard_slot]->get_link();
return;
case DBOARD_PROP_GAIN_GROUP:
- val = make_gain_group(_dboard_manager->get_tx_subdev(key.name),
- _tx_codec_proxy->get_link());
+ val = make_gain_group(_dboard_managers[dboard_slot]->get_tx_subdev(key.name),
+ _tx_codec_proxies[dboard_slot]->get_link());
return;
default: UHD_THROW_PROP_GET_ERROR();
@@ -181,12 +194,15 @@ void usrp1_impl::tx_dboard_get(const wax::obj &key_, wax::obj &val)
/***********************************************************************
* TX Dboard Set
**********************************************************************/
-void usrp1_impl::tx_dboard_set(const wax::obj &key, const wax::obj &val)
+void usrp1_impl::tx_dboard_set(const wax::obj &key, const wax::obj &val, dboard_slot_t dboard_slot)
{
switch(key.as<dboard_prop_t>()) {
case DBOARD_PROP_DBOARD_ID:
- _tx_db_eeprom.id = val.as<dboard_id_t>();
- _iface->write_eeprom(I2C_ADDR_TX_A, 0, _tx_db_eeprom.get_eeprom_bytes());
+ _tx_db_eeproms[dboard_slot].id = val.as<dboard_id_t>();
+ _iface->write_eeprom(
+ get_tx_ee_addr(dboard_slot), 0,
+ _tx_db_eeproms[dboard_slot].get_eeprom_bytes()
+ );
return;
default: UHD_THROW_PROP_SET_ERROR();
diff --git a/host/lib/usrp/usrp1/dsp_impl.cpp b/host/lib/usrp/usrp1/dsp_impl.cpp
index e9900131f..1a8993a01 100644
--- a/host/lib/usrp/usrp1/dsp_impl.cpp
+++ b/host/lib/usrp/usrp1/dsp_impl.cpp
@@ -29,19 +29,19 @@ using namespace uhd::usrp;
/***********************************************************************
* RX DDC Initialization
**********************************************************************/
-void usrp1_impl::rx_ddc_init(void)
+void usrp1_impl::rx_dsp_init(void)
{
- _rx_ddc_proxy = wax_obj_proxy::make(
- boost::bind(&usrp1_impl::rx_ddc_get, this, _1, _2),
- boost::bind(&usrp1_impl::rx_ddc_set, this, _1, _2));
+ _rx_dsp_proxy = wax_obj_proxy::make(
+ boost::bind(&usrp1_impl::rx_dsp_get, this, _1, _2),
+ boost::bind(&usrp1_impl::rx_dsp_set, this, _1, _2));
- rx_ddc_set(DSP_PROP_HOST_RATE, double(64e6/10));
+ rx_dsp_set(DSP_PROP_HOST_RATE, double(64e6/10)); //FIXME magic number
}
/***********************************************************************
* RX DDC Get
**********************************************************************/
-void usrp1_impl::rx_ddc_get(const wax::obj &key, wax::obj &val)
+void usrp1_impl::rx_dsp_get(const wax::obj &key, wax::obj &val)
{
switch(key.as<dsp_prop_t>()){
case DSP_PROP_NAME:
@@ -53,7 +53,7 @@ void usrp1_impl::rx_ddc_get(const wax::obj &key, wax::obj &val)
return;
case DSP_PROP_FREQ_SHIFT:
- val = _ddc_freq;
+ val = _rx_dsp_freq;
return;
case DSP_PROP_CODEC_RATE:
@@ -61,7 +61,7 @@ void usrp1_impl::rx_ddc_get(const wax::obj &key, wax::obj &val)
return;
case DSP_PROP_HOST_RATE:
- val = _clock_ctrl->get_master_clock_freq()/_ddc_decim;
+ val = _clock_ctrl->get_master_clock_freq()/_rx_dsp_decim;
return;
default: UHD_THROW_PROP_GET_ERROR();
@@ -90,13 +90,13 @@ unsigned int compute_freq_word(double master, double target)
return (unsigned int) v;
}
-void usrp1_impl::rx_ddc_set(const wax::obj &key, const wax::obj &val)
+void usrp1_impl::rx_dsp_set(const wax::obj &key, const wax::obj &val)
{
switch(key.as<dsp_prop_t>()) {
case DSP_PROP_FREQ_SHIFT: {
double new_freq = val.as<double>();
- _iface->poke32(FR_RX_FREQ_0, compute_freq_word(64e6, new_freq));
- _ddc_freq = new_freq;
+ _iface->poke32(FR_RX_FREQ_0, compute_freq_word(64e6, new_freq)); //FIXME magic rate
+ _tx_dsp_freq = new_freq;
return;
}
case DSP_PROP_HOST_RATE: {
@@ -110,8 +110,8 @@ void usrp1_impl::rx_ddc_set(const wax::obj &key, const wax::obj &val)
return;
}
- _ddc_decim = rate;
- _iface->poke32(FR_DECIM_RATE, _ddc_decim/2 - 1);
+ _rx_dsp_decim = rate;
+ _iface->poke32(FR_DECIM_RATE, _rx_dsp_decim/2 - 1);
}
return;
@@ -123,20 +123,20 @@ void usrp1_impl::rx_ddc_set(const wax::obj &key, const wax::obj &val)
/***********************************************************************
* TX DUC Initialization
**********************************************************************/
-void usrp1_impl::tx_duc_init(void)
+void usrp1_impl::tx_dsp_init(void)
{
- _tx_duc_proxy = wax_obj_proxy::make(
- boost::bind(&usrp1_impl::tx_duc_get, this, _1, _2),
- boost::bind(&usrp1_impl::tx_duc_set, this, _1, _2));
+ _tx_dsp_proxy = wax_obj_proxy::make(
+ boost::bind(&usrp1_impl::tx_dsp_get, this, _1, _2),
+ boost::bind(&usrp1_impl::tx_dsp_set, this, _1, _2));
//initial config and update
- tx_duc_set(DSP_PROP_HOST_RATE, double(64e6/10));
+ tx_dsp_set(DSP_PROP_HOST_RATE, double(64e6/10)); //FIXME magic number
}
/***********************************************************************
* TX DUC Get
**********************************************************************/
-void usrp1_impl::tx_duc_get(const wax::obj &key, wax::obj &val)
+void usrp1_impl::tx_dsp_get(const wax::obj &key, wax::obj &val)
{
switch(key.as<dsp_prop_t>()) {
case DSP_PROP_NAME:
@@ -148,7 +148,7 @@ void usrp1_impl::tx_duc_get(const wax::obj &key, wax::obj &val)
return;
case DSP_PROP_FREQ_SHIFT:
- val = _duc_freq;
+ val = _tx_dsp_freq;
return;
case DSP_PROP_CODEC_RATE:
@@ -156,7 +156,7 @@ void usrp1_impl::tx_duc_get(const wax::obj &key, wax::obj &val)
return;
case DSP_PROP_HOST_RATE:
- val = _clock_ctrl->get_master_clock_freq() * 2 / _duc_interp;
+ val = _clock_ctrl->get_master_clock_freq() * 2 / _tx_dsp_interp;
return;
default: UHD_THROW_PROP_GET_ERROR();
@@ -167,16 +167,19 @@ void usrp1_impl::tx_duc_get(const wax::obj &key, wax::obj &val)
/***********************************************************************
* TX DUC Set
**********************************************************************/
-void usrp1_impl::tx_duc_set(const wax::obj &key, const wax::obj &val)
+void usrp1_impl::tx_dsp_set(const wax::obj &key, const wax::obj &val)
{
switch(key.as<dsp_prop_t>()) {
case DSP_PROP_FREQ_SHIFT: {
double new_freq = val.as<double>();
- _codec_ctrl->set_duc_freq(new_freq);
- _duc_freq = new_freq;
+ _codec_ctrls[DBOARD_SLOT_A]->set_duc_freq(new_freq);
+ _tx_dsp_freq = new_freq;
return;
}
+
+ //TODO freq prop secondary: DBOARD_SLOT_B codec...
+
case DSP_PROP_HOST_RATE: {
unsigned int rate =
_clock_ctrl->get_master_clock_freq() * 2 / val.as<double>();
@@ -187,8 +190,8 @@ void usrp1_impl::tx_duc_set(const wax::obj &key, const wax::obj &val)
return;
}
- _duc_interp = rate;
- _iface->poke32(FR_INTERP_RATE, _duc_interp / 4 - 1);
+ _tx_dsp_interp = rate;
+ _iface->poke32(FR_INTERP_RATE, _tx_dsp_interp / 4 - 1);
return;
}
default: UHD_THROW_PROP_SET_ERROR();
diff --git a/host/lib/usrp/usrp1/mboard_impl.cpp b/host/lib/usrp/usrp1/mboard_impl.cpp
index 2514072e0..e0a7fefb1 100644
--- a/host/lib/usrp/usrp1/mboard_impl.cpp
+++ b/host/lib/usrp/usrp1/mboard_impl.cpp
@@ -19,6 +19,7 @@
#include "usrp_commands.h"
#include <uhd/utils/assert.hpp>
#include <uhd/usrp/mboard_props.hpp>
+#include <boost/assign/list_of.hpp>
#include <boost/bind.hpp>
#include <iostream>
@@ -109,6 +110,8 @@ void usrp1_impl::issue_stream_cmd(const stream_cmd_t &stream_cmd)
/***********************************************************************
* Mboard Get
**********************************************************************/
+static prop_names_t dboard_names = boost::assign::list_of("A")("B");
+
void usrp1_impl::mboard_get(const wax::obj &key_, wax::obj &val)
{
named_prop_t key = named_prop_t::extract(key_);
@@ -124,26 +127,28 @@ void usrp1_impl::mboard_get(const wax::obj &key_, wax::obj &val)
return;
case MBOARD_PROP_RX_DBOARD:
- UHD_ASSERT_THROW(key.name == "");
- val = _rx_dboard_proxy->get_link();
+ uhd::assert_has(dboard_names, key.name, "dboard name");
+ if (key.name == "A") val = _rx_dboard_proxies[DBOARD_SLOT_A]->get_link();
+ if (key.name == "B") val = _rx_dboard_proxies[DBOARD_SLOT_B]->get_link();
return;
case MBOARD_PROP_RX_DBOARD_NAMES:
- val = prop_names_t(1, ""); //vector of size 1 with empty string
+ val = dboard_names;
return;
case MBOARD_PROP_TX_DBOARD:
- UHD_ASSERT_THROW(key.name == "");
- val = _tx_dboard_proxy->get_link();
+ uhd::assert_has(dboard_names, key.name, "dboard name");
+ if (key.name == "A") val = _tx_dboard_proxies[DBOARD_SLOT_A]->get_link();
+ if (key.name == "B") val = _tx_dboard_proxies[DBOARD_SLOT_B]->get_link();
return;
case MBOARD_PROP_TX_DBOARD_NAMES:
- val = prop_names_t(1, ""); //vector of size 1 with empty string
+ val = dboard_names;
return;
case MBOARD_PROP_RX_DSP:
UHD_ASSERT_THROW(key.name == "");
- val = _rx_ddc_proxy->get_link();
+ val = _rx_dsp_proxy->get_link();
return;
case MBOARD_PROP_RX_DSP_NAMES:
@@ -152,7 +157,7 @@ void usrp1_impl::mboard_get(const wax::obj &key_, wax::obj &val)
case MBOARD_PROP_TX_DSP:
UHD_ASSERT_THROW(key.name == "");
- val = _tx_duc_proxy->get_link();
+ val = _tx_dsp_proxy->get_link();
return;
case MBOARD_PROP_TX_DSP_NAMES:
diff --git a/host/lib/usrp/usrp1/usrp1_impl.cpp b/host/lib/usrp/usrp1/usrp1_impl.cpp
index 1435b981c..ece5f1dea 100644
--- a/host/lib/usrp/usrp1/usrp1_impl.cpp
+++ b/host/lib/usrp/usrp1/usrp1_impl.cpp
@@ -18,11 +18,13 @@
#include "usrp1_impl.hpp"
#include "usrp1_ctrl.hpp"
#include "fpga_regs_standard.h"
+#include "usrp_spi_defs.h"
#include <uhd/transport/usb_control.hpp>
#include <uhd/usrp/device_props.hpp>
#include <uhd/utils/assert.hpp>
#include <uhd/utils/static.hpp>
#include <boost/format.hpp>
+#include <boost/assign/list_of.hpp>
#include <boost/filesystem.hpp>
#include <iostream>
@@ -30,6 +32,10 @@ using namespace uhd;
using namespace uhd::usrp;
using namespace uhd::transport;
+const std::vector<usrp1_impl::dboard_slot_t> usrp1_impl::_dboard_slots = boost::assign::list_of
+ (usrp1_impl::DBOARD_SLOT_A)(usrp1_impl::DBOARD_SLOT_B)
+;
+
/***********************************************************************
* Discovery
**********************************************************************/
@@ -132,7 +138,8 @@ usrp1_impl::usrp1_impl(uhd::transport::usb_zero_copy::sptr data_transport,
_clock_ctrl = usrp1_clock_ctrl::make(_iface);
//create codec interface
- _codec_ctrl = usrp1_codec_ctrl::make(_iface);
+ _codec_ctrls[DBOARD_SLOT_A] = usrp1_codec_ctrl::make(_iface, SPI_ENABLE_CODEC_A);
+ _codec_ctrls[DBOARD_SLOT_B] = usrp1_codec_ctrl::make(_iface, SPI_ENABLE_CODEC_B);
//initialize the codecs
codec_init();
@@ -144,10 +151,10 @@ usrp1_impl::usrp1_impl(uhd::transport::usb_zero_copy::sptr data_transport,
dboard_init();
//initialize the dsps
- rx_ddc_init();
+ rx_dsp_init();
//initialize the dsps
- tx_duc_init();
+ tx_dsp_init();
//initialize the send/recv
io_init();
diff --git a/host/lib/usrp/usrp1/usrp1_impl.hpp b/host/lib/usrp/usrp1/usrp1_impl.hpp
index 5abc37c7f..84ec26827 100644
--- a/host/lib/usrp/usrp1/usrp1_impl.hpp
+++ b/host/lib/usrp/usrp1/usrp1_impl.hpp
@@ -21,6 +21,7 @@
#include "codec_ctrl.hpp"
#include <uhd/device.hpp>
#include <uhd/utils/pimpl.hpp>
+#include <uhd/types/dict.hpp>
#include <uhd/types/otw_type.hpp>
#include <uhd/types/clock_config.hpp>
#include <uhd/types/stream_cmd.hpp>
@@ -34,17 +35,6 @@
static const double MASTER_CLOCK_RATE = 64e6; //TODO get from clock control
/*!
- * Make a usrp1 dboard interface.
- * \param iface the usrp1 interface object
- * \param clock the clock control interface
- * \param codec the codec control interface
- * \return a sptr to a new dboard interface
- */
-uhd::usrp::dboard_iface::sptr make_usrp1_dboard_iface(usrp1_iface::sptr iface,
- usrp1_clock_ctrl::sptr clock,
- usrp1_codec_ctrl::sptr codec);
-
-/*!
* Simple wax obj proxy class:
* Provides a wax obj interface for a set and a get function.
* This allows us to create nested properties structures
@@ -75,6 +65,14 @@ private:
*/
class usrp1_impl : public uhd::device {
public:
+ //! used everywhere to differentiate slots/sides...
+ enum dboard_slot_t{
+ DBOARD_SLOT_A = 'A',
+ DBOARD_SLOT_B = 'B'
+ };
+ //and a way to enumerate through a list of the above...
+ static const std::vector<dboard_slot_t> _dboard_slots;
+
//structors
usrp1_impl(uhd::transport::usb_zero_copy::sptr data_transport,
usrp_ctrl::sptr ctrl_transport);
@@ -97,9 +95,27 @@ public:
size_t get_max_send_samps_per_packet(void) const { return 0; }
size_t get_max_recv_samps_per_packet(void) const { return 0; }
- bool recv_async_msg(uhd::async_metadata_t &, size_t) { return true; }
+ bool recv_async_msg(uhd::async_metadata_t &, size_t) {
+ //TODO sleep the number of ms supplied (dont want to hog CPU)
+ return false;
+ }
private:
+ /*!
+ * Make a usrp1 dboard interface.
+ * \param iface the usrp1 interface object
+ * \param clock the clock control interface
+ * \param codec the codec control interface
+ * \param dboard_slot the slot identifier
+ * \return a sptr to a new dboard interface
+ */
+ static uhd::usrp::dboard_iface::sptr make_dboard_iface(
+ usrp1_iface::sptr iface,
+ usrp1_clock_ctrl::sptr clock,
+ usrp1_codec_ctrl::sptr codec,
+ dboard_slot_t dboard_slot
+ );
+
//interface to ioctls and file descriptor
usrp1_iface::sptr _iface;
@@ -120,16 +136,15 @@ private:
usrp1_clock_ctrl::sptr _clock_ctrl;
//ad9862 codec control interface
- usrp1_codec_ctrl::sptr _codec_ctrl;
+ uhd::dict<dboard_slot_t, usrp1_codec_ctrl::sptr> _codec_ctrls;
//codec properties interfaces
void codec_init(void);
- void rx_codec_get(const wax::obj &, wax::obj &);
- void rx_codec_set(const wax::obj &, const wax::obj &);
- void tx_codec_get(const wax::obj &, wax::obj &);
- void tx_codec_set(const wax::obj &, const wax::obj &);
- wax_obj_proxy::sptr _rx_codec_proxy;
- wax_obj_proxy::sptr _tx_codec_proxy;
+ void rx_codec_get(const wax::obj &, wax::obj &, dboard_slot_t);
+ void rx_codec_set(const wax::obj &, const wax::obj &, dboard_slot_t);
+ void tx_codec_get(const wax::obj &, wax::obj &, dboard_slot_t);
+ void tx_codec_set(const wax::obj &, const wax::obj &, dboard_slot_t);
+ uhd::dict<dboard_slot_t, wax_obj_proxy::sptr> _rx_codec_proxies, _tx_codec_proxies;
//device functions and settings
void get(const wax::obj &, wax::obj &);
@@ -143,36 +158,34 @@ private:
//xx dboard functions and settings
void dboard_init(void);
- uhd::usrp::dboard_manager::sptr _dboard_manager;
- uhd::usrp::dboard_iface::sptr _dboard_iface;
+ uhd::dict<dboard_slot_t, uhd::usrp::dboard_manager::sptr> _dboard_managers;
+ uhd::dict<dboard_slot_t, uhd::usrp::dboard_iface::sptr> _dboard_ifaces;
//rx dboard functions and settings
- uhd::usrp::dboard_eeprom_t _rx_db_eeprom;
- void rx_dboard_get(const wax::obj &, wax::obj &);
- void rx_dboard_set(const wax::obj &, const wax::obj &);
- uhd::prop_names_t _rx_subdevs_in_use;
- wax_obj_proxy::sptr _rx_dboard_proxy;
+ uhd::dict<dboard_slot_t, uhd::usrp::dboard_eeprom_t> _rx_db_eeproms;
+ void rx_dboard_get(const wax::obj &, wax::obj &, dboard_slot_t);
+ void rx_dboard_set(const wax::obj &, const wax::obj &, dboard_slot_t);
+ uhd::dict<dboard_slot_t, wax_obj_proxy::sptr> _rx_dboard_proxies;
//tx dboard functions and settings
- uhd::usrp::dboard_eeprom_t _tx_db_eeprom;
- void tx_dboard_get(const wax::obj &, wax::obj &);
- void tx_dboard_set(const wax::obj &, const wax::obj &);
- uhd::prop_names_t _tx_subdevs_in_use;
- wax_obj_proxy::sptr _tx_dboard_proxy;
-
- //rx ddc functions and settings
- void rx_ddc_init(void);
- void rx_ddc_get(const wax::obj &, wax::obj &);
- void rx_ddc_set(const wax::obj &, const wax::obj &);
- double _ddc_freq; size_t _ddc_decim;
- wax_obj_proxy::sptr _rx_ddc_proxy;
-
- //tx duc functions and settings
- void tx_duc_init(void);
- void tx_duc_get(const wax::obj &, wax::obj &);
- void tx_duc_set(const wax::obj &, const wax::obj &);
- double _duc_freq; size_t _duc_interp;
- wax_obj_proxy::sptr _tx_duc_proxy;
+ uhd::dict<dboard_slot_t, uhd::usrp::dboard_eeprom_t> _tx_db_eeproms;
+ void tx_dboard_get(const wax::obj &, wax::obj &, dboard_slot_t);
+ void tx_dboard_set(const wax::obj &, const wax::obj &, dboard_slot_t);
+ uhd::dict<dboard_slot_t, wax_obj_proxy::sptr> _tx_dboard_proxies;
+
+ //rx dsp functions and settings
+ 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;
+ 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;
+ wax_obj_proxy::sptr _tx_dsp_proxy;
//transports
uhd::transport::usb_zero_copy::sptr _data_transport;