summaryrefslogtreecommitdiffstats
path: root/host/lib/usrp/dboard
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2010-02-21 12:59:41 -0800
committerJosh Blum <josh@joshknows.com>2010-02-21 12:59:41 -0800
commitadd5d32f9b0cb3cda15624fb7aef3998096ff3f6 (patch)
treee5c10c2952b173b977e5835c34ac27ece92a0b45 /host/lib/usrp/dboard
parentaab51fa40769bb77af73aba69e16c9ac28e4943f (diff)
downloaduhd-add5d32f9b0cb3cda15624fb7aef3998096ff3f6.tar.gz
uhd-add5d32f9b0cb3cda15624fb7aef3998096ff3f6.tar.bz2
uhd-add5d32f9b0cb3cda15624fb7aef3998096ff3f6.zip
Moved lib and include contents of dboard and mboard one directory up and prefixed them with dboard_ and mboard_.
And yes, the code is compiling.
Diffstat (limited to 'host/lib/usrp/dboard')
-rw-r--r--host/lib/usrp/dboard/base.cpp117
-rw-r--r--host/lib/usrp/dboard/basic.cpp4
-rw-r--r--host/lib/usrp/dboard/dboards.hpp16
-rw-r--r--host/lib/usrp/dboard/id.cpp34
-rw-r--r--host/lib/usrp/dboard/interface.cpp54
-rw-r--r--host/lib/usrp/dboard/manager.cpp231
6 files changed, 10 insertions, 446 deletions
diff --git a/host/lib/usrp/dboard/base.cpp b/host/lib/usrp/dboard/base.cpp
deleted file mode 100644
index 92a886407..000000000
--- a/host/lib/usrp/dboard/base.cpp
+++ /dev/null
@@ -1,117 +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/base.hpp>
-#include <boost/format.hpp>
-#include <stdexcept>
-
-using namespace uhd::usrp::dboard;
-
-/***********************************************************************
- * base dboard base class
- **********************************************************************/
-base::base(ctor_args_t const& args){
- boost::tie(_subdev_name, _dboard_interface, _rx_id, _tx_id) = args;
-}
-
-base::~base(void){
- /* NOP */
-}
-
-std::string base::get_subdev_name(void){
- return _subdev_name;
-}
-
-interface::sptr base::get_interface(void){
- return _dboard_interface;
-}
-
-dboard_id_t base::get_rx_id(void){
- return _rx_id;
-}
-
-dboard_id_t base::get_tx_id(void){
- return _tx_id;
-}
-
-/***********************************************************************
- * xcvr dboard base class
- **********************************************************************/
-xcvr_base::xcvr_base(ctor_args_t const& args) : base(args){
- if (get_rx_id() == ID_NONE){
- throw std::runtime_error(str(boost::format(
- "cannot create xcvr board when the rx id is \"%s\""
- ) % id::to_string(ID_NONE)));
- }
- if (get_tx_id() == ID_NONE){
- throw std::runtime_error(str(boost::format(
- "cannot create xcvr board when the tx id is \"%s\""
- ) % id::to_string(ID_NONE)));
- }
-}
-
-xcvr_base::~xcvr_base(void){
- /* NOP */
-}
-
-/***********************************************************************
- * rx dboard base class
- **********************************************************************/
-rx_base::rx_base(ctor_args_t const& args) : base(args){
- if (get_tx_id() != ID_NONE){
- throw std::runtime_error(str(boost::format(
- "cannot create rx board when the tx id is \"%s\""
- " -> expected a tx id of \"%s\""
- ) % id::to_string(get_tx_id()) % id::to_string(ID_NONE)));
- }
-}
-
-rx_base::~rx_base(void){
- /* NOP */
-}
-
-void rx_base::tx_get(const wax::obj &, wax::obj &){
- throw std::runtime_error("cannot call tx_get on a rx dboard");
-}
-
-void rx_base::tx_set(const wax::obj &, const wax::obj &){
- throw std::runtime_error("cannot call tx_set on a rx dboard");
-}
-
-/***********************************************************************
- * tx dboard base class
- **********************************************************************/
-tx_base::tx_base(ctor_args_t const& args) : base(args){
- if (get_rx_id() != ID_NONE){
- throw std::runtime_error(str(boost::format(
- "cannot create tx board when the rx id is \"%s\""
- " -> expected a rx id of \"%s\""
- ) % id::to_string(get_rx_id()) % id::to_string(ID_NONE)));
- }
-}
-
-tx_base::~tx_base(void){
- /* NOP */
-}
-
-void tx_base::rx_get(const wax::obj &, wax::obj &){
- throw std::runtime_error("cannot call rx_get on a tx dboard");
-}
-
-void tx_base::rx_set(const wax::obj &, const wax::obj &){
- throw std::runtime_error("cannot call rx_set on a tx dboard");
-}
diff --git a/host/lib/usrp/dboard/basic.cpp b/host/lib/usrp/dboard/basic.cpp
index 35512aa5f..f39ebff2f 100644
--- a/host/lib/usrp/dboard/basic.cpp
+++ b/host/lib/usrp/dboard/basic.cpp
@@ -20,7 +20,7 @@
/***********************************************************************
* Basic RX dboard
**********************************************************************/
-basic_rx::basic_rx(ctor_args_t const& args) : rx_base(args){
+basic_rx::basic_rx(ctor_args_t const& args) : rx_dboard_base(args){
/* NOP */
}
@@ -39,7 +39,7 @@ void basic_rx::rx_set(const wax::obj &, const wax::obj &){
/***********************************************************************
* Basic TX dboard
**********************************************************************/
-basic_tx::basic_tx(ctor_args_t const& args) : tx_base(args){
+basic_tx::basic_tx(ctor_args_t const& args) : tx_dboard_base(args){
/* NOP */
}
diff --git a/host/lib/usrp/dboard/dboards.hpp b/host/lib/usrp/dboard/dboards.hpp
index 0e740856f..79b90d593 100644
--- a/host/lib/usrp/dboard/dboards.hpp
+++ b/host/lib/usrp/dboard/dboards.hpp
@@ -18,17 +18,17 @@
#ifndef INCLUDED_LOCAL_DBOARDS_HPP
#define INCLUDED_LOCAL_DBOARDS_HPP
-#include <uhd/usrp/dboard/base.hpp>
+#include <uhd/usrp/dboard_base.hpp>
-using namespace uhd::usrp::dboard;
+using namespace uhd::usrp;
/***********************************************************************
* The basic boards:
**********************************************************************/
-class basic_rx : public rx_base{
+class basic_rx : public rx_dboard_base{
public:
- static base::sptr make(ctor_args_t const& args){
- return base::sptr(new basic_rx(args));
+ static dboard_base::sptr make(ctor_args_t const& args){
+ return dboard_base::sptr(new basic_rx(args));
}
basic_rx(ctor_args_t const& args);
~basic_rx(void);
@@ -37,10 +37,10 @@ public:
void rx_set(const wax::obj &key, const wax::obj &val);
};
-class basic_tx : public tx_base{
+class basic_tx : public tx_dboard_base{
public:
- static base::sptr make(ctor_args_t const& args){
- return base::sptr(new basic_tx(args));
+ static dboard_base::sptr make(ctor_args_t const& args){
+ return dboard_base::sptr(new basic_tx(args));
}
basic_tx(ctor_args_t const& args);
~basic_tx(void);
diff --git a/host/lib/usrp/dboard/id.cpp b/host/lib/usrp/dboard/id.cpp
deleted file mode 100644
index b62e469de..000000000
--- a/host/lib/usrp/dboard/id.cpp
+++ /dev/null
@@ -1,34 +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/id.hpp>
-#include <boost/format.hpp>
-#include <uhd/dict.hpp>
-
-using namespace uhd::usrp::dboard;
-
-std::string id::to_string(const dboard_id_t &id){
- //map the dboard ids to string representations
- uhd::dict<dboard_id_t, std::string> id_to_str;
- id_to_str[ID_NONE] = "none";
- id_to_str[ID_BASIC_TX] = "basic tx";
- id_to_str[ID_BASIC_RX] = "basic rx";
-
- //get the string representation
- std::string name = (id_to_str.has_key(id))? id_to_str[id] : "unknown";
- return str(boost::format("%s (0x%.4x)") % name % id);
-}
diff --git a/host/lib/usrp/dboard/interface.cpp b/host/lib/usrp/dboard/interface.cpp
deleted file mode 100644
index b8f6724ba..000000000
--- a/host/lib/usrp/dboard/interface.cpp
+++ /dev/null
@@ -1,54 +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>
-
-using namespace uhd::usrp::dboard;
-
-interface::interface(void){
- /* NOP */
-}
-
-interface::~interface(void){
- /* NOP */
-}
-
-void interface::write_spi(
- spi_dev_t dev,
- spi_push_t push,
- const byte_vector_t &buf
-){
- transact_spi(dev, SPI_LATCH_RISE, push, buf, false); //dont readback
-}
-
-interface::byte_vector_t interface::read_spi(
- spi_dev_t dev,
- spi_latch_t latch,
- size_t num_bytes
-){
- byte_vector_t buf(num_bytes, 0x00); //dummy data
- return transact_spi(dev, latch, SPI_PUSH_RISE, buf, true); //readback
-}
-
-interface::byte_vector_t interface::read_write_spi(
- spi_dev_t dev,
- spi_latch_t latch,
- spi_push_t push,
- const byte_vector_t &buf
-){
- return transact_spi(dev, latch, push, buf, true); //readback
-}
diff --git a/host/lib/usrp/dboard/manager.cpp b/host/lib/usrp/dboard/manager.cpp
deleted file mode 100644
index 337c31ad6..000000000
--- a/host/lib/usrp/dboard/manager.cpp
+++ /dev/null
@@ -1,231 +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/manager.hpp>
-#include <uhd/utils.hpp>
-#include <boost/assign/list_of.hpp>
-#include <boost/tuple/tuple.hpp>
-#include <boost/format.hpp>
-#include <boost/foreach.hpp>
-#include "dboards.hpp"
-
-using namespace uhd;
-using namespace uhd::usrp::dboard;
-using namespace boost::assign;
-
-/***********************************************************************
- * register internal dboards
- *
- * Register internal/known dboards located in this build tree.
- * Each board should have entries below mapping an id to a constructor.
- * The xcvr type boards should register both rx and tx sides.
- *
- * This function will be called before new boards are registered.
- * This allows for internal boards to be externally overridden.
- * This function will also be called when creating a new manager
- * to ensure that the maps are filled with the entries below.
- **********************************************************************/
-static void register_internal_dboards(void){
- //ensure that this function can only be called once per instance
- static bool called = false;
- if (called) return; called = true;
- //register the known dboards (dboard id, constructor, subdev names)
- manager::register_subdevs(ID_BASIC_TX, &basic_tx::make, list_of(""));
- manager::register_subdevs(ID_BASIC_RX, &basic_rx::make, list_of("a")("b")("ab"));
-}
-
-/***********************************************************************
- * storage and registering for dboards
- **********************************************************************/
-typedef boost::tuple<manager::dboard_ctor_t, prop_names_t> args_t;
-
-//map a dboard id to a dboard constructor
-static uhd::dict<dboard_id_t, args_t> id_to_args_map;
-
-void manager::register_subdevs(
- dboard_id_t dboard_id,
- dboard_ctor_t dboard_ctor,
- const prop_names_t &subdev_names
-){
- register_internal_dboards(); //always call first
- id_to_args_map[dboard_id] = args_t(dboard_ctor, subdev_names);
-}
-
-/***********************************************************************
- * internal helper classes
- **********************************************************************/
-/*!
- * A special wax proxy object that forwards calls to a subdev.
- * A sptr to an instance will be used in the properties structure.
- */
-class subdev_proxy : boost::noncopyable, public wax::obj{
-public:
- typedef boost::shared_ptr<subdev_proxy> sptr;
- enum type_t{RX_TYPE, TX_TYPE};
-
- //structors
- subdev_proxy(base::sptr subdev, type_t type)
- : _subdev(subdev), _type(type){
- /* NOP */
- }
-
- ~subdev_proxy(void){
- /* NOP */
- }
-
-private:
- base::sptr _subdev;
- type_t _type;
-
- //forward the get calls to the rx or tx
- void get(const wax::obj &key, wax::obj &val){
- switch(_type){
- case RX_TYPE: return _subdev->rx_get(key, val);
- case TX_TYPE: return _subdev->tx_get(key, val);
- }
- }
-
- //forward the set calls to the rx or tx
- void set(const wax::obj &key, const wax::obj &val){
- switch(_type){
- case RX_TYPE: return _subdev->rx_set(key, val);
- case TX_TYPE: return _subdev->tx_set(key, val);
- }
- }
-};
-
-/***********************************************************************
- * dboard manager methods
- **********************************************************************/
-static args_t get_dboard_args(
- dboard_id_t dboard_id,
- std::string const& xx_type
-){
- //special case, its rx and the none id (0xffff)
- if (xx_type == "rx" and dboard_id == ID_NONE){
- return args_t(&basic_rx::make, list_of("ab"));
- }
-
- //special case, its tx and the none id (0xffff)
- if (xx_type == "tx" and dboard_id == ID_NONE){
- return args_t(&basic_tx::make, list_of(""));
- }
-
- //verify that there is a registered constructor for this id
- if (not id_to_args_map.has_key(dboard_id)){
- throw std::runtime_error(str(
- boost::format("Unknown %s dboard id: 0x%04x") % xx_type % dboard_id
- ));
- }
-
- //return the dboard args for this id
- return id_to_args_map[dboard_id];
-}
-
-manager::manager(
- dboard_id_t rx_dboard_id,
- dboard_id_t tx_dboard_id,
- interface::sptr dboard_interface
-){
- register_internal_dboards(); //always call first
-
- dboard_ctor_t rx_dboard_ctor; prop_names_t rx_subdevs;
- boost::tie(rx_dboard_ctor, rx_subdevs) = get_dboard_args(rx_dboard_id, "rx");
-
- dboard_ctor_t tx_dboard_ctor; prop_names_t tx_subdevs;
- boost::tie(tx_dboard_ctor, tx_subdevs) = get_dboard_args(tx_dboard_id, "tx");
-
- //initialize the gpio pins before creating subdevs
- dboard_interface->set_gpio_ddr(interface::GPIO_RX_BANK, 0x0000, 0xffff); //all inputs
- dboard_interface->set_gpio_ddr(interface::GPIO_TX_BANK, 0x0000, 0xffff);
-
- dboard_interface->write_gpio(interface::GPIO_RX_BANK, 0x0000, 0xffff); //all zeros
- dboard_interface->write_gpio(interface::GPIO_TX_BANK, 0x0000, 0xffff);
-
- dboard_interface->set_atr_reg(interface::GPIO_RX_BANK, 0x0000, 0x0000, 0x0000); //software controlled
- dboard_interface->set_atr_reg(interface::GPIO_TX_BANK, 0x0000, 0x0000, 0x0000);
-
- //make xcvr subdevs (make one subdev for both rx and tx dboards)
- if (rx_dboard_ctor == tx_dboard_ctor){
- ASSERT_THROW(rx_subdevs == tx_subdevs);
- BOOST_FOREACH(std::string name, rx_subdevs){
- base::sptr xcvr_dboard = rx_dboard_ctor(
- base::ctor_args_t(name, dboard_interface, rx_dboard_id, tx_dboard_id)
- );
- //create a rx proxy for this xcvr board
- _rx_dboards[name] = subdev_proxy::sptr(
- new subdev_proxy(xcvr_dboard, subdev_proxy::RX_TYPE)
- );
- //create a tx proxy for this xcvr board
- _tx_dboards[name] = subdev_proxy::sptr(
- new subdev_proxy(xcvr_dboard, subdev_proxy::TX_TYPE)
- );
- }
- }
-
- //make tx and rx subdevs (separate subdevs for rx and tx dboards)
- else{
- //make the rx subdevs
- BOOST_FOREACH(std::string name, rx_subdevs){
- base::sptr rx_dboard = rx_dboard_ctor(
- base::ctor_args_t(name, dboard_interface, rx_dboard_id, ID_NONE)
- );
- //create a rx proxy for this rx board
- _rx_dboards[name] = subdev_proxy::sptr(
- new subdev_proxy(rx_dboard, subdev_proxy::RX_TYPE)
- );
- }
- //make the tx subdevs
- BOOST_FOREACH(std::string name, tx_subdevs){
- base::sptr tx_dboard = tx_dboard_ctor(
- base::ctor_args_t(name, dboard_interface, ID_NONE, tx_dboard_id)
- );
- //create a tx proxy for this tx board
- _tx_dboards[name] = subdev_proxy::sptr(
- new subdev_proxy(tx_dboard, subdev_proxy::TX_TYPE)
- );
- }
- }
-}
-
-manager::~manager(void){
- /* NOP */
-}
-
-prop_names_t manager::get_rx_subdev_names(void){
- return _rx_dboards.get_keys();
-}
-
-prop_names_t manager::get_tx_subdev_names(void){
- return _tx_dboards.get_keys();
-}
-
-wax::obj manager::get_rx_subdev(const std::string &subdev_name){
- if (not _rx_dboards.has_key(subdev_name)) throw std::invalid_argument(
- str(boost::format("Unknown rx subdev name %s") % subdev_name)
- );
- //get a link to the rx subdev proxy
- return wax::cast<subdev_proxy::sptr>(_rx_dboards[subdev_name])->get_link();
-}
-
-wax::obj manager::get_tx_subdev(const std::string &subdev_name){
- if (not _tx_dboards.has_key(subdev_name)) throw std::invalid_argument(
- str(boost::format("Unknown tx subdev name %s") % subdev_name)
- );
- //get a link to the tx subdev proxy
- return wax::cast<subdev_proxy::sptr>(_tx_dboards[subdev_name])->get_link();
-}