From add5d32f9b0cb3cda15624fb7aef3998096ff3f6 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Sun, 21 Feb 2010 12:59:41 -0800 Subject: 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. --- host/include/uhd/usrp/CMakeLists.txt | 9 +- host/include/uhd/usrp/dboard/CMakeLists.txt | 25 ---- host/include/uhd/usrp/dboard/base.hpp | 115 ---------------- host/include/uhd/usrp/dboard/id.hpp | 37 ----- host/include/uhd/usrp/dboard/interface.hpp | 207 ---------------------------- host/include/uhd/usrp/dboard/manager.hpp | 82 ----------- host/include/uhd/usrp/dboard_base.hpp | 115 ++++++++++++++++ host/include/uhd/usrp/dboard_id.hpp | 37 +++++ host/include/uhd/usrp/dboard_interface.hpp | 207 ++++++++++++++++++++++++++++ host/include/uhd/usrp/dboard_manager.hpp | 82 +++++++++++ host/include/uhd/usrp/mboard/CMakeLists.txt | 23 ---- host/include/uhd/usrp/mboard/base.hpp | 45 ------ host/include/uhd/usrp/mboard/usrp2.hpp | 51 ------- host/include/uhd/usrp/mboard_base.hpp | 45 ++++++ host/include/uhd/usrp/usrp.hpp | 4 +- host/include/uhd/usrp/usrp2.hpp | 51 +++++++ 16 files changed, 545 insertions(+), 590 deletions(-) delete mode 100644 host/include/uhd/usrp/dboard/CMakeLists.txt delete mode 100644 host/include/uhd/usrp/dboard/base.hpp delete mode 100644 host/include/uhd/usrp/dboard/id.hpp delete mode 100644 host/include/uhd/usrp/dboard/interface.hpp delete mode 100644 host/include/uhd/usrp/dboard/manager.hpp create mode 100644 host/include/uhd/usrp/dboard_base.hpp create mode 100644 host/include/uhd/usrp/dboard_id.hpp create mode 100644 host/include/uhd/usrp/dboard_interface.hpp create mode 100644 host/include/uhd/usrp/dboard_manager.hpp delete mode 100644 host/include/uhd/usrp/mboard/CMakeLists.txt delete mode 100644 host/include/uhd/usrp/mboard/base.hpp delete mode 100644 host/include/uhd/usrp/mboard/usrp2.hpp create mode 100644 host/include/uhd/usrp/mboard_base.hpp create mode 100644 host/include/uhd/usrp/usrp2.hpp (limited to 'host/include') diff --git a/host/include/uhd/usrp/CMakeLists.txt b/host/include/uhd/usrp/CMakeLists.txt index d3040c3cc..4b49e315f 100644 --- a/host/include/uhd/usrp/CMakeLists.txt +++ b/host/include/uhd/usrp/CMakeLists.txt @@ -16,10 +16,13 @@ # -ADD_SUBDIRECTORY(dboard) -ADD_SUBDIRECTORY(mboard) - INSTALL(FILES + dboard_base.hpp + dboard_id.hpp + dboard_interface.hpp + dboard_manager.hpp + mboard_base.hpp + usrp2.hpp usrp.hpp DESTINATION ${HEADER_DIR}/uhd/usrp ) diff --git a/host/include/uhd/usrp/dboard/CMakeLists.txt b/host/include/uhd/usrp/dboard/CMakeLists.txt deleted file mode 100644 index e1ecc3b70..000000000 --- a/host/include/uhd/usrp/dboard/CMakeLists.txt +++ /dev/null @@ -1,25 +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 . -# - - -INSTALL(FILES - base.hpp - id.hpp - interface.hpp - manager.hpp - DESTINATION ${HEADER_DIR}/uhd/usrp/dboard -) diff --git a/host/include/uhd/usrp/dboard/base.hpp b/host/include/uhd/usrp/dboard/base.hpp deleted file mode 100644 index 111820a8b..000000000 --- a/host/include/uhd/usrp/dboard/base.hpp +++ /dev/null @@ -1,115 +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 . -// - -#ifndef INCLUDED_UHD_USRP_DBOARD_BASE_HPP -#define INCLUDED_UHD_USRP_DBOARD_BASE_HPP - -#include -#include -#include -#include -#include -#include - -namespace uhd{ namespace usrp{ namespace dboard{ - -/*! - * A daughter board base class for all dboards. - * Only other dboard base classes should inherit this. - */ -class base : boost::noncopyable{ -public: - typedef boost::shared_ptr sptr; - //the constructor args consist of a subdev name and an interface - //derived classes should pass the args into the base class ctor - //but should not have to deal with the internals of the args - typedef boost::tuple ctor_args_t; - - //structors - base(ctor_args_t const&); - virtual ~base(void); - - //interface - virtual void rx_get(const wax::obj &key, wax::obj &val) = 0; - virtual void rx_set(const wax::obj &key, const wax::obj &val) = 0; - virtual void tx_get(const wax::obj &key, wax::obj &val) = 0; - virtual void tx_set(const wax::obj &key, const wax::obj &val) = 0; - -protected: - std::string get_subdev_name(void); - interface::sptr get_interface(void); - dboard_id_t get_rx_id(void); - dboard_id_t get_tx_id(void); - -private: - std::string _subdev_name; - interface::sptr _dboard_interface; - dboard_id_t _rx_id, _tx_id; -}; - -/*! - * A xcvr daughter board implements rx and tx methods - * Sub classes for xcvr boards should inherit this. - */ -class xcvr_base : public base{ -public: - /*! - * Create a new xcvr dboard object, override in subclasses. - */ - xcvr_base(ctor_args_t const&); - virtual ~xcvr_base(void); -}; - -/*! - * A rx daughter board only implements rx methods. - * Sub classes for rx-only boards should inherit this. - */ -class rx_base : public base{ -public: - /*! - * Create a new rx dboard object, override in subclasses. - */ - rx_base(ctor_args_t const&); - - virtual ~rx_base(void); - - //override here so the derived classes cannot - void tx_get(const wax::obj &key, wax::obj &val); - void tx_set(const wax::obj &key, const wax::obj &val); -}; - -/*! - * A tx daughter board only implements tx methods. - * Sub classes for rx-only boards should inherit this. - */ -class tx_base : public base{ -public: - /*! - * Create a new rx dboard object, override in subclasses. - */ - tx_base(ctor_args_t const&); - - virtual ~tx_base(void); - - //override here so the derived classes cannot - void rx_get(const wax::obj &key, wax::obj &val); - void rx_set(const wax::obj &key, const wax::obj &val); -}; - -}}} //namespace - -#endif /* INCLUDED_UHD_USRP_DBOARD_BASE_HPP */ diff --git a/host/include/uhd/usrp/dboard/id.hpp b/host/include/uhd/usrp/dboard/id.hpp deleted file mode 100644 index a890ee096..000000000 --- a/host/include/uhd/usrp/dboard/id.hpp +++ /dev/null @@ -1,37 +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 . -// - -#include - -#ifndef INCLUDED_UHD_USRP_DBOARD_ID_HPP -#define INCLUDED_UHD_USRP_DBOARD_ID_HPP - -namespace uhd{ namespace usrp{ namespace dboard{ - -enum dboard_id_t{ - ID_NONE = 0xffff, - ID_BASIC_TX = 0x0000, - ID_BASIC_RX = 0x0001 -}; - -struct id{ - static std::string to_string(const dboard_id_t &id); -}; - -}}} //namespace - -#endif /* INCLUDED_UHD_USRP_DBOARD_ID_HPP */ diff --git a/host/include/uhd/usrp/dboard/interface.hpp b/host/include/uhd/usrp/dboard/interface.hpp deleted file mode 100644 index 7c48f4d2b..000000000 --- a/host/include/uhd/usrp/dboard/interface.hpp +++ /dev/null @@ -1,207 +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 . -// - -#ifndef INCLUDED_UHD_USRP_DBOARD_INTERFACE_HPP -#define INCLUDED_UHD_USRP_DBOARD_INTERFACE_HPP - -#include -#include -#include - -namespace uhd{ namespace usrp{ namespace dboard{ - -/*! - * The daughter board interface to be subclassed. - * A dboard instance interfaces with the mboard though this api. - * This interface provides i2c, spi, gpio, atr, aux dac/adc access. - * Each mboard should have a specially tailored dboard interface. - */ -class interface{ -public: - typedef boost::shared_ptr sptr; - typedef std::vector byte_vector_t; - - //tells the host which unit to use - enum unit_type_t{ - UNIT_TYPE_RX, - UNIT_TYPE_TX - }; - - //tells the host which device to use - enum spi_dev_t{ - SPI_TX_DEV, - SPI_RX_DEV - }; - - //args for writing spi data - enum spi_push_t{ - SPI_PUSH_RISE, - SPI_PUSH_FALL - }; - - //args for reading spi data - enum spi_latch_t{ - SPI_LATCH_RISE, - SPI_LATCH_FALL - }; - - //tell the host which gpio bank - enum gpio_bank_t{ - GPIO_TX_BANK, - GPIO_RX_BANK - }; - - //structors - interface(void); - virtual ~interface(void); - - /*! - * Write to an aux dac. - * \param unit which unit rx or tx - * \param which_dac the dac index 0, 1, 2, 3... - * \param value the value to write - */ - virtual void write_aux_dac(unit_type_t unit, int which_dac, int value) = 0; - - /*! - * Read from an aux adc. - * \param unit which unit rx or tx - * \param which_adc the adc index 0, 1, 2, 3... - * \return the value that was read - */ - virtual int read_aux_adc(unit_type_t unit, int which_adc) = 0; - - /*! - * Set daughterboard ATR register. - * The ATR register for a particular bank has 2 values: - * one value when transmitting, one when receiving. - * The mask controls which pins are controlled by ATR. - * - * \param bank GPIO_TX_BANK or GPIO_RX_BANK - * \param tx_value 16-bits, 0=FPGA output low, 1=FPGA output high - * \param rx_value 16-bits, 0=FPGA output low, 1=FPGA output high - * \param mask 16-bits, 0=software, 1=atr - */ - virtual void set_atr_reg(gpio_bank_t bank, uint16_t tx_value, uint16_t rx_value, uint16_t mask) = 0; - - /*! - * Set daughterboard GPIO data direction register. - * - * \param bank GPIO_TX_BANK or GPIO_RX_BANK - * \param value 16-bits, 0=FPGA input, 1=FPGA output - * \param mask 16-bits, 0=ignore, 1=set - */ - virtual void set_gpio_ddr(gpio_bank_t bank, uint16_t value, uint16_t mask) = 0; - - /*! - * Set daughterboard GPIO pin values. - * - * \param bank GPIO_TX_BANK or GPIO_RX_BANK - * \param value 16 bits, 0=low, 1=high - * \param mask 16 bits, 0=ignore, 1=set - */ - virtual void write_gpio(gpio_bank_t bank, uint16_t value, uint16_t mask) = 0; - - /*! - * Read daughterboard GPIO pin values - * - * \param bank GPIO_TX_BANK or GPIO_RX_BANK - * \return the value of the gpio bank - */ - virtual uint16_t read_gpio(gpio_bank_t bank) = 0; - - /*! - * \brief Write to I2C peripheral - * \param i2c_addr I2C bus address (7-bits) - * \param buf the data to write - */ - virtual void write_i2c(int i2c_addr, const byte_vector_t &buf) = 0; - - /*! - * \brief Read from I2C peripheral - * \param i2c_addr I2C bus address (7-bits) - * \param num_bytes number of bytes to read - * \return the data read if successful, else a zero length string. - */ - virtual byte_vector_t read_i2c(int i2c_addr, size_t num_bytes) = 0; - - /*! - * \brief Write data to SPI bus peripheral. - * - * \param dev which spi device - * \param push args for writing - * \param buf the data to write - */ - void write_spi(spi_dev_t dev, spi_push_t push, const byte_vector_t &buf); - - /*! - * \brief Read data to SPI bus peripheral. - * - * \param dev which spi device - * \param latch args for reading - * \param num_bytes number of bytes to read - * \return the data that was read - */ - byte_vector_t read_spi(spi_dev_t dev, spi_latch_t latch, size_t num_bytes); - - /*! - * \brief Read and write data to SPI bus peripheral. - * The data read back will be the same length as the input buffer. - * - * \param dev which spi device - * \param latch args for reading - * \param push args for clock - * \param buf the data to write - * \return the data that was read - */ - byte_vector_t read_write_spi(spi_dev_t dev, spi_latch_t latch, spi_push_t push, const byte_vector_t &buf); - - /*! - * \brief Get the rate of the rx dboard clock. - * \return the clock rate - */ - virtual double get_rx_clock_rate(void) = 0; - - /*! - * \brief Get the rate of the tx dboard clock. - * \return the clock rate - */ - virtual double get_tx_clock_rate(void) = 0; - -private: - /*! - * \brief Read and write data to SPI bus peripheral. - * - * \param dev which spi device - * \param latch args for reading - * \param push args for clock - * \param buf the data to write - * \param readback false for write only - * \return the data that was read - */ - virtual byte_vector_t transact_spi( - spi_dev_t dev, - spi_latch_t latch, - spi_push_t push, - const byte_vector_t &buf, - bool readback - ) = 0; -}; - -}}} //namespace - -#endif /* INCLUDED_UHD_USRP_DBOARD_INTERFACE_HPP */ diff --git a/host/include/uhd/usrp/dboard/manager.hpp b/host/include/uhd/usrp/dboard/manager.hpp deleted file mode 100644 index e53ba8e52..000000000 --- a/host/include/uhd/usrp/dboard/manager.hpp +++ /dev/null @@ -1,82 +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 . -// - -#ifndef INCLUDED_UHD_USRP_DBOARD_MANAGER_HPP -#define INCLUDED_UHD_USRP_DBOARD_MANAGER_HPP - -#include -#include -#include -#include -#include -#include -#include - -namespace uhd{ namespace usrp{ namespace dboard{ - -/*! - * A daughter board subdev manager class. - * Create subdev instances for each subdev on a dboard. - * Provide wax::obj access to the subdevs inside. - */ -class manager : boost::noncopyable{ - -public: - - //dboard constructor (each dboard should have a ::make with this signature) - typedef base::sptr(*dboard_ctor_t)(base::ctor_args_t const&); - - /*! - * Register subdevices for a given dboard id. - * - * \param dboard_id the dboard id (rx or tx) - * \param dboard_ctor the dboard constructor function pointer - * \param subdev_names the names of the subdevs on this dboard - */ - static void register_subdevs( - dboard_id_t dboard_id, - dboard_ctor_t dboard_ctor, - const prop_names_t &subdev_names - ); - -public: - typedef boost::shared_ptr sptr; - //structors - manager( - dboard_id_t rx_dboard_id, - dboard_id_t tx_dboard_id, - interface::sptr dboard_interface - ); - ~manager(void); - - //interface - prop_names_t get_rx_subdev_names(void); - prop_names_t get_tx_subdev_names(void); - wax::obj get_rx_subdev(const std::string &subdev_name); - wax::obj get_tx_subdev(const std::string &subdev_name); - -private: - //list of rx and tx dboards in this manager - //each dboard here is actually a subdevice proxy - //the subdevice proxy is internal to the cpp file - uhd::dict _rx_dboards; - uhd::dict _tx_dboards; -}; - -}}} //namespace - -#endif /* INCLUDED_UHD_USRP_DBOARD_MANAGER_HPP */ diff --git a/host/include/uhd/usrp/dboard_base.hpp b/host/include/uhd/usrp/dboard_base.hpp new file mode 100644 index 000000000..b5c0d40ed --- /dev/null +++ b/host/include/uhd/usrp/dboard_base.hpp @@ -0,0 +1,115 @@ +// +// 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 . +// + +#ifndef INCLUDED_UHD_USRP_DBOARD_BASE_HPP +#define INCLUDED_UHD_USRP_DBOARD_BASE_HPP + +#include +#include +#include +#include +#include +#include + +namespace uhd{ namespace usrp{ + +/*! + * A daughter board dboard_base class for all dboards. + * Only other dboard dboard_base classes should inherit this. + */ +class dboard_base : boost::noncopyable{ +public: + typedef boost::shared_ptr sptr; + //the constructor args consist of a subdev name and an interface + //derived classes should pass the args into the dboard_base class ctor + //but should not have to deal with the internals of the args + typedef boost::tuple ctor_args_t; + + //structors + dboard_base(ctor_args_t const&); + virtual ~dboard_base(void); + + //interface + virtual void rx_get(const wax::obj &key, wax::obj &val) = 0; + virtual void rx_set(const wax::obj &key, const wax::obj &val) = 0; + virtual void tx_get(const wax::obj &key, wax::obj &val) = 0; + virtual void tx_set(const wax::obj &key, const wax::obj &val) = 0; + +protected: + std::string get_subdev_name(void); + dboard_interface::sptr get_interface(void); + dboard_id_t get_rx_id(void); + dboard_id_t get_tx_id(void); + +private: + std::string _subdev_name; + dboard_interface::sptr _dboard_interface; + dboard_id_t _rx_id, _tx_id; +}; + +/*! + * A xcvr daughter board implements rx and tx methods + * Sub classes for xcvr boards should inherit this. + */ +class xcvr_dboard_base : public dboard_base{ +public: + /*! + * Create a new xcvr dboard object, override in subclasses. + */ + xcvr_dboard_base(ctor_args_t const&); + virtual ~xcvr_dboard_base(void); +}; + +/*! + * A rx daughter board only implements rx methods. + * Sub classes for rx-only boards should inherit this. + */ +class rx_dboard_base : public dboard_base{ +public: + /*! + * Create a new rx dboard object, override in subclasses. + */ + rx_dboard_base(ctor_args_t const&); + + virtual ~rx_dboard_base(void); + + //override here so the derived classes cannot + void tx_get(const wax::obj &key, wax::obj &val); + void tx_set(const wax::obj &key, const wax::obj &val); +}; + +/*! + * A tx daughter board only implements tx methods. + * Sub classes for rx-only boards should inherit this. + */ +class tx_dboard_base : public dboard_base{ +public: + /*! + * Create a new rx dboard object, override in subclasses. + */ + tx_dboard_base(ctor_args_t const&); + + virtual ~tx_dboard_base(void); + + //override here so the derived classes cannot + void rx_get(const wax::obj &key, wax::obj &val); + void rx_set(const wax::obj &key, const wax::obj &val); +}; + +}} //namespace + +#endif /* INCLUDED_UHD_USRP_DBOARD_BASE_HPP */ diff --git a/host/include/uhd/usrp/dboard_id.hpp b/host/include/uhd/usrp/dboard_id.hpp new file mode 100644 index 000000000..8e904ff33 --- /dev/null +++ b/host/include/uhd/usrp/dboard_id.hpp @@ -0,0 +1,37 @@ +// +// 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 . +// + +#include + +#ifndef INCLUDED_UHD_USRP_DBOARD_ID_HPP +#define INCLUDED_UHD_USRP_DBOARD_ID_HPP + +namespace uhd{ namespace usrp{ + +enum dboard_id_t{ + ID_NONE = 0xffff, + ID_BASIC_TX = 0x0000, + ID_BASIC_RX = 0x0001 +}; + +struct dboard_id{ + static std::string to_string(const dboard_id_t &id); +}; + +}} //namespace + +#endif /* INCLUDED_UHD_USRP_DBOARD_ID_HPP */ diff --git a/host/include/uhd/usrp/dboard_interface.hpp b/host/include/uhd/usrp/dboard_interface.hpp new file mode 100644 index 000000000..84e1f5b22 --- /dev/null +++ b/host/include/uhd/usrp/dboard_interface.hpp @@ -0,0 +1,207 @@ +// +// 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 . +// + +#ifndef INCLUDED_UHD_USRP_DBOARD_INTERFACE_HPP +#define INCLUDED_UHD_USRP_DBOARD_INTERFACE_HPP + +#include +#include +#include + +namespace uhd{ namespace usrp{ + +/*! + * The daughter board dboard_interface to be subclassed. + * A dboard instance dboard_interfaces with the mboard though this api. + * This dboard_interface provides i2c, spi, gpio, atr, aux dac/adc access. + * Each mboard should have a specially tailored dboard dboard_interface. + */ +class dboard_interface{ +public: + typedef boost::shared_ptr sptr; + typedef std::vector byte_vector_t; + + //tells the host which unit to use + enum unit_type_t{ + UNIT_TYPE_RX, + UNIT_TYPE_TX + }; + + //tells the host which device to use + enum spi_dev_t{ + SPI_TX_DEV, + SPI_RX_DEV + }; + + //args for writing spi data + enum spi_push_t{ + SPI_PUSH_RISE, + SPI_PUSH_FALL + }; + + //args for reading spi data + enum spi_latch_t{ + SPI_LATCH_RISE, + SPI_LATCH_FALL + }; + + //tell the host which gpio bank + enum gpio_bank_t{ + GPIO_TX_BANK, + GPIO_RX_BANK + }; + + //structors + dboard_interface(void); + virtual ~dboard_interface(void); + + /*! + * Write to an aux dac. + * \param unit which unit rx or tx + * \param which_dac the dac index 0, 1, 2, 3... + * \param value the value to write + */ + virtual void write_aux_dac(unit_type_t unit, int which_dac, int value) = 0; + + /*! + * Read from an aux adc. + * \param unit which unit rx or tx + * \param which_adc the adc index 0, 1, 2, 3... + * \return the value that was read + */ + virtual int read_aux_adc(unit_type_t unit, int which_adc) = 0; + + /*! + * Set daughterboard ATR register. + * The ATR register for a particular bank has 2 values: + * one value when transmitting, one when receiving. + * The mask controls which pins are controlled by ATR. + * + * \param bank GPIO_TX_BANK or GPIO_RX_BANK + * \param tx_value 16-bits, 0=FPGA output low, 1=FPGA output high + * \param rx_value 16-bits, 0=FPGA output low, 1=FPGA output high + * \param mask 16-bits, 0=software, 1=atr + */ + virtual void set_atr_reg(gpio_bank_t bank, uint16_t tx_value, uint16_t rx_value, uint16_t mask) = 0; + + /*! + * Set daughterboard GPIO data direction register. + * + * \param bank GPIO_TX_BANK or GPIO_RX_BANK + * \param value 16-bits, 0=FPGA input, 1=FPGA output + * \param mask 16-bits, 0=ignore, 1=set + */ + virtual void set_gpio_ddr(gpio_bank_t bank, uint16_t value, uint16_t mask) = 0; + + /*! + * Set daughterboard GPIO pin values. + * + * \param bank GPIO_TX_BANK or GPIO_RX_BANK + * \param value 16 bits, 0=low, 1=high + * \param mask 16 bits, 0=ignore, 1=set + */ + virtual void write_gpio(gpio_bank_t bank, uint16_t value, uint16_t mask) = 0; + + /*! + * Read daughterboard GPIO pin values + * + * \param bank GPIO_TX_BANK or GPIO_RX_BANK + * \return the value of the gpio bank + */ + virtual uint16_t read_gpio(gpio_bank_t bank) = 0; + + /*! + * \brief Write to I2C peripheral + * \param i2c_addr I2C bus address (7-bits) + * \param buf the data to write + */ + virtual void write_i2c(int i2c_addr, const byte_vector_t &buf) = 0; + + /*! + * \brief Read from I2C peripheral + * \param i2c_addr I2C bus address (7-bits) + * \param num_bytes number of bytes to read + * \return the data read if successful, else a zero length string. + */ + virtual byte_vector_t read_i2c(int i2c_addr, size_t num_bytes) = 0; + + /*! + * \brief Write data to SPI bus peripheral. + * + * \param dev which spi device + * \param push args for writing + * \param buf the data to write + */ + void write_spi(spi_dev_t dev, spi_push_t push, const byte_vector_t &buf); + + /*! + * \brief Read data to SPI bus peripheral. + * + * \param dev which spi device + * \param latch args for reading + * \param num_bytes number of bytes to read + * \return the data that was read + */ + byte_vector_t read_spi(spi_dev_t dev, spi_latch_t latch, size_t num_bytes); + + /*! + * \brief Read and write data to SPI bus peripheral. + * The data read back will be the same length as the input buffer. + * + * \param dev which spi device + * \param latch args for reading + * \param push args for clock + * \param buf the data to write + * \return the data that was read + */ + byte_vector_t read_write_spi(spi_dev_t dev, spi_latch_t latch, spi_push_t push, const byte_vector_t &buf); + + /*! + * \brief Get the rate of the rx dboard clock. + * \return the clock rate + */ + virtual double get_rx_clock_rate(void) = 0; + + /*! + * \brief Get the rate of the tx dboard clock. + * \return the clock rate + */ + virtual double get_tx_clock_rate(void) = 0; + +private: + /*! + * \brief Read and write data to SPI bus peripheral. + * + * \param dev which spi device + * \param latch args for reading + * \param push args for clock + * \param buf the data to write + * \param readback false for write only + * \return the data that was read + */ + virtual byte_vector_t transact_spi( + spi_dev_t dev, + spi_latch_t latch, + spi_push_t push, + const byte_vector_t &buf, + bool readback + ) = 0; +}; + +}} //namespace + +#endif /* INCLUDED_UHD_USRP_DBOARD_INTERFACE_HPP */ diff --git a/host/include/uhd/usrp/dboard_manager.hpp b/host/include/uhd/usrp/dboard_manager.hpp new file mode 100644 index 000000000..d927f6231 --- /dev/null +++ b/host/include/uhd/usrp/dboard_manager.hpp @@ -0,0 +1,82 @@ +// +// 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 . +// + +#ifndef INCLUDED_UHD_USRP_DBOARD_MANAGER_HPP +#define INCLUDED_UHD_USRP_DBOARD_MANAGER_HPP + +#include +#include +#include +#include +#include +#include +#include + +namespace uhd{ namespace usrp{ + +/*! + * A daughter board subdev dboard_manager class. + * Create subdev instances for each subdev on a dboard. + * Provide wax::obj access to the subdevs inside. + */ +class dboard_manager : boost::noncopyable{ + +public: + + //dboard constructor (each dboard should have a ::make with this signature) + typedef dboard_base::sptr(*dboard_ctor_t)(dboard_base::ctor_args_t const&); + + /*! + * Register subdevices for a given dboard id. + * + * \param dboard_id the dboard id (rx or tx) + * \param dboard_ctor the dboard constructor function pointer + * \param subdev_names the names of the subdevs on this dboard + */ + static void register_subdevs( + dboard_id_t dboard_id, + dboard_ctor_t dboard_ctor, + const prop_names_t &subdev_names + ); + +public: + typedef boost::shared_ptr sptr; + //structors + dboard_manager( + dboard_id_t rx_dboard_id, + dboard_id_t tx_dboard_id, + dboard_interface::sptr interface + ); + ~dboard_manager(void); + + //dboard_interface + prop_names_t get_rx_subdev_names(void); + prop_names_t get_tx_subdev_names(void); + wax::obj get_rx_subdev(const std::string &subdev_name); + wax::obj get_tx_subdev(const std::string &subdev_name); + +private: + //list of rx and tx dboards in this dboard_manager + //each dboard here is actually a subdevice proxy + //the subdevice proxy is internal to the cpp file + uhd::dict _rx_dboards; + uhd::dict _tx_dboards; +}; + +}} //namespace + +#endif /* INCLUDED_UHD_USRP_DBOARD_MANAGER_HPP */ diff --git a/host/include/uhd/usrp/mboard/CMakeLists.txt b/host/include/uhd/usrp/mboard/CMakeLists.txt deleted file mode 100644 index 2cdb55143..000000000 --- a/host/include/uhd/usrp/mboard/CMakeLists.txt +++ /dev/null @@ -1,23 +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 . -# - - -INSTALL(FILES - base.hpp - usrp2.hpp - DESTINATION ${HEADER_DIR}/uhd/usrp/mboard -) diff --git a/host/include/uhd/usrp/mboard/base.hpp b/host/include/uhd/usrp/mboard/base.hpp deleted file mode 100644 index a8de81a7e..000000000 --- a/host/include/uhd/usrp/mboard/base.hpp +++ /dev/null @@ -1,45 +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 . -// - -#ifndef INCLUDED_UHD_USRP_MBOARD_BASE_HPP -#define INCLUDED_UHD_USRP_MBOARD_BASE_HPP - -#include -#include -#include - -namespace uhd{ namespace usrp{ namespace mboard{ - -/*! - * A base class for usrp mboard objects. - */ -class base : boost::noncopyable, public wax::obj{ -public: - typedef boost::shared_ptr sptr; - base(void); - ~base(void); - - //TODO other api calls - -private: - virtual void get(const wax::obj &, wax::obj &) = 0; - virtual void set(const wax::obj &, const wax::obj &) = 0; -}; - -}}} //namespace - -#endif /* INCLUDED_UHD_USRP_MBOARD_BASE_HPP */ diff --git a/host/include/uhd/usrp/mboard/usrp2.hpp b/host/include/uhd/usrp/mboard/usrp2.hpp deleted file mode 100644 index 5da9f874d..000000000 --- a/host/include/uhd/usrp/mboard/usrp2.hpp +++ /dev/null @@ -1,51 +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 . -// - -#ifndef INCLUDED_UHD_USRP_MBOARD_USRP2_HPP -#define INCLUDED_UHD_USRP_MBOARD_USRP2_HPP - -#include -#include - -namespace uhd{ namespace usrp{ namespace mboard{ - -/*! - * The usrp2 mboard class. - */ -class usrp2 : public base{ -public: - /*! - * Discover usrp2 devices over the ethernet. - * This static method will be called by the device::discover. - * \param hint a device addr with the usrp2 address filled in - * \return a vector of device addresses for all usrp2s found - */ - static device_addrs_t discover(const device_addr_t &hint); - - usrp2(const device_addr_t &); - ~usrp2(void); - -private: - void get(const wax::obj &, wax::obj &); - void set(const wax::obj &, const wax::obj &); - - wax::obj _impl; -}; - -}}} //namespace - -#endif /* INCLUDED_UHD_USRP_MBOARD_USRP2_HPP */ diff --git a/host/include/uhd/usrp/mboard_base.hpp b/host/include/uhd/usrp/mboard_base.hpp new file mode 100644 index 000000000..498a46681 --- /dev/null +++ b/host/include/uhd/usrp/mboard_base.hpp @@ -0,0 +1,45 @@ +// +// 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 . +// + +#ifndef INCLUDED_UHD_USRP_MBOARD_BASE_HPP +#define INCLUDED_UHD_USRP_MBOARD_BASE_HPP + +#include +#include +#include + +namespace uhd{ namespace usrp{ + +/*! + * A mboard_base class for usrp mboard objects. + */ +class mboard_base : boost::noncopyable, public wax::obj{ +public: + typedef boost::shared_ptr sptr; + mboard_base(void); + ~mboard_base(void); + + //TODO other api calls + +private: + virtual void get(const wax::obj &, wax::obj &) = 0; + virtual void set(const wax::obj &, const wax::obj &) = 0; +}; + +}} //namespace + +#endif /* INCLUDED_UHD_USRP_MBOARD_BASE_HPP */ diff --git a/host/include/uhd/usrp/usrp.hpp b/host/include/uhd/usrp/usrp.hpp index 98c357b77..cc5ed601e 100644 --- a/host/include/uhd/usrp/usrp.hpp +++ b/host/include/uhd/usrp/usrp.hpp @@ -16,7 +16,7 @@ // #include -#include +#include #include #ifndef INCLUDED_UHD_USRP_USRP_HPP @@ -43,7 +43,7 @@ private: void get(const wax::obj &, wax::obj &); void set(const wax::obj &, const wax::obj &); - uhd::dict _mboards; + uhd::dict _mboards; boost::function &)> _send_raw_cb; boost::function _recv_raw_cb; }; diff --git a/host/include/uhd/usrp/usrp2.hpp b/host/include/uhd/usrp/usrp2.hpp new file mode 100644 index 000000000..68d4c513c --- /dev/null +++ b/host/include/uhd/usrp/usrp2.hpp @@ -0,0 +1,51 @@ +// +// 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 . +// + +#ifndef INCLUDED_UHD_USRP_MBOARD_USRP2_HPP +#define INCLUDED_UHD_USRP_MBOARD_USRP2_HPP + +#include +#include + +namespace uhd{ namespace usrp{ + +/*! + * The usrp2 mboard class. + */ +class usrp2 : public mboard_base{ +public: + /*! + * Discover usrp2 devices over the ethernet. + * This static method will be called by the device::discover. + * \param hint a device addr with the usrp2 address filled in + * \return a vector of device addresses for all usrp2s found + */ + static device_addrs_t discover(const device_addr_t &hint); + + usrp2(const device_addr_t &); + ~usrp2(void); + +private: + void get(const wax::obj &, wax::obj &); + void set(const wax::obj &, const wax::obj &); + + wax::obj _impl; +}; + +}} //namespace + +#endif /* INCLUDED_UHD_USRP_MBOARD_USRP2_HPP */ -- cgit v1.2.3