diff options
author | Josh Blum <josh@joshknows.com> | 2011-03-03 16:28:26 -0800 |
---|---|---|
committer | Josh Blum <josh@joshknows.com> | 2011-03-03 16:28:26 -0800 |
commit | 98028b366f840efc3b289cc7051bed73aad0963c (patch) | |
tree | 5d26773de13c4f78326896c6eb0ff78213d0912f /host/include | |
parent | f938ed7938021c10bb0a0ce47e6d40d10f89abc2 (diff) | |
parent | 1b63cd2560886d851f3e2ba98bfddf772c44df34 (diff) | |
download | uhd-98028b366f840efc3b289cc7051bed73aad0963c.tar.gz uhd-98028b366f840efc3b289cc7051bed73aad0963c.tar.bz2 uhd-98028b366f840efc3b289cc7051bed73aad0963c.zip |
Merge branch 'mb_iface' into next
Conflicts:
host/lib/usrp/usrp2/usrp2_iface.hpp
Diffstat (limited to 'host/include')
-rw-r--r-- | host/include/uhd/types/serial.hpp | 53 | ||||
-rw-r--r-- | host/include/uhd/usrp/CMakeLists.txt | 1 | ||||
-rw-r--r-- | host/include/uhd/usrp/mboard_iface.hpp | 87 | ||||
-rw-r--r-- | host/include/uhd/usrp/mboard_props.hpp | 3 | ||||
-rw-r--r-- | host/include/uhd/usrp/multi_usrp.hpp | 7 |
5 files changed, 150 insertions, 1 deletions
diff --git a/host/include/uhd/types/serial.hpp b/host/include/uhd/types/serial.hpp index c134725f5..5c6de162b 100644 --- a/host/include/uhd/types/serial.hpp +++ b/host/include/uhd/types/serial.hpp @@ -116,6 +116,59 @@ namespace uhd{ */ spi_config_t(edge_t edge = EDGE_RISE); }; + + /*! + * The SPI interface class. + * Provides routines to transact SPI and do other useful things which haven't been defined yet. + */ + class UHD_API spi_iface{ + public: + /*! + * Perform a spi transaction. + * \param which_slave the slave device number + * \param config spi config args + * \param data the bits to write + * \param num_bits how many bits in data + * \param readback true to readback a value + * \return spi data if readback set + */ + virtual boost::uint32_t transact_spi( + int which_slave, + const spi_config_t &config, + boost::uint32_t data, + size_t num_bits, + bool readback + ) = 0; + + /*! + * Read from the SPI bus. + * \param which_slave the slave device number + * \param config spi config args + * \param data the bits to write out (be sure to set write bit) + * \param num_bits how many bits in data + * \return spi data + */ + virtual boost::uint32_t read_spi( + int which_slave, + const spi_config_t &config, + boost::uint16_t data, + size_t num_bits + ); + + /*! + * Write to the SPI bus. + * \param which_slave the slave device number + * \param config spi config args + * \param data the bits to write + * \param num_bits how many bits in data + */ + virtual void write_spi( + int which_slave, + const spi_config_t &config, + boost::uint16_t data, + size_t num_bits + ); + }; } //namespace uhd diff --git a/host/include/uhd/usrp/CMakeLists.txt b/host/include/uhd/usrp/CMakeLists.txt index f60b35e59..59a1302af 100644 --- a/host/include/uhd/usrp/CMakeLists.txt +++ b/host/include/uhd/usrp/CMakeLists.txt @@ -43,6 +43,7 @@ INSTALL(FILES ### interfaces ### single_usrp.hpp multi_usrp.hpp + mboard_iface.hpp DESTINATION ${INCLUDE_DIR}/uhd/usrp ) diff --git a/host/include/uhd/usrp/mboard_iface.hpp b/host/include/uhd/usrp/mboard_iface.hpp new file mode 100644 index 000000000..cfd273232 --- /dev/null +++ b/host/include/uhd/usrp/mboard_iface.hpp @@ -0,0 +1,87 @@ +// +// Copyright 2010-2011 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/>. +// + +#ifndef INCLUDED_UHD_USRP_MBOARD_IFACE_HPP +#define INCLUDED_UHD_USRP_MBOARD_IFACE_HPP + +#include <uhd/types/serial.hpp> +#include <uhd/usrp/mboard_eeprom.hpp> +#include <boost/shared_ptr.hpp> +#include <boost/utility.hpp> +#include <boost/cstdint.hpp> +#include <utility> +#include <string> + +namespace uhd{ namespace usrp{ + +/*! + * The mboard interface class: + * Provides a set of functions to implementation layer. + * Including spi, peek, poke, control... + */ +class mboard_iface : public uhd::i2c_iface, public uhd::spi_iface { +public: + typedef boost::shared_ptr<mboard_iface> sptr; + /*! + * Write a register (32 bits) + * \param addr the address + * \param data the 32bit data + */ + virtual void poke32(boost::uint32_t addr, boost::uint32_t data) = 0; + + /*! + * Read a register (32 bits) + * \param addr the address + * \return the 32bit data + */ + virtual boost::uint32_t peek32(boost::uint32_t addr) = 0; + + /*! + * Write a register (16 bits) + * \param addr the address + * \param data the 16bit data + */ + virtual void poke16(boost::uint32_t addr, boost::uint16_t data) = 0; + + /*! + * Read a register (16 bits) + * \param addr the address + * \return the 16bit data + */ + virtual boost::uint16_t peek16(boost::uint32_t addr) = 0; + + /*! + * Write to a serial port. + * \param dev which UART to write to + * \param buf the data to write + */ + virtual void write_uart(boost::uint8_t dev, const std::string &buf) = 0; + + /*! + * Read from a serial port. + * \param dev which UART to read from + * \return the data read from the serial port + */ + virtual std::string read_uart(boost::uint8_t dev) = 0; + + //motherboard eeprom map structure + uhd::usrp::mboard_eeprom_t mb_eeprom; +}; + +}} + +#endif //INCLUDED_UHD_USRP_DBOARD_IFACE_HPP diff --git a/host/include/uhd/usrp/mboard_props.hpp b/host/include/uhd/usrp/mboard_props.hpp index 180c4eeb3..a2580954e 100644 --- a/host/include/uhd/usrp/mboard_props.hpp +++ b/host/include/uhd/usrp/mboard_props.hpp @@ -47,7 +47,8 @@ namespace uhd{ namespace usrp{ MBOARD_PROP_CLOCK_CONFIG, //rw, clock_config_t MBOARD_PROP_TIME_NOW, //rw, time_spec_t MBOARD_PROP_TIME_PPS, //wo, time_spec_t - MBOARD_PROP_EEPROM_MAP //wr, mboard_eeprom_t + MBOARD_PROP_EEPROM_MAP, //wr, mboard_eeprom_t + MBOARD_PROP_IFACE, //ro, mboard_iface::sptr }; }} //namespace diff --git a/host/include/uhd/usrp/multi_usrp.hpp b/host/include/uhd/usrp/multi_usrp.hpp index b06975b6c..b161d1278 100644 --- a/host/include/uhd/usrp/multi_usrp.hpp +++ b/host/include/uhd/usrp/multi_usrp.hpp @@ -28,6 +28,7 @@ #include <uhd/types/sensors.hpp> #include <uhd/usrp/subdev_spec.hpp> #include <uhd/usrp/dboard_iface.hpp> +#include <uhd/usrp/mboard_iface.hpp> #include <boost/shared_ptr.hpp> #include <boost/utility.hpp> #include <vector> @@ -250,6 +251,12 @@ public: * \return a vector of sensor names */ virtual std::vector<std::string> get_mboard_sensor_names(size_t mboard = 0) = 0; + + /*! + * Get a handle to the mboard_iface object which controls peripheral access. + * \return a mboard_iface::sptr object + */ + virtual mboard_iface::sptr get_mboard_iface(size_t mboard) = 0; /******************************************************************* * RX methods |