diff options
Diffstat (limited to 'host/include')
-rw-r--r-- | host/include/uhd/usrp/dboard/interface.hpp | 48 | ||||
-rw-r--r-- | host/include/uhd/usrp/mboard/CMakeLists.txt | 1 | ||||
-rw-r--r-- | host/include/uhd/usrp/mboard/test.hpp | 46 |
3 files changed, 40 insertions, 55 deletions
diff --git a/host/include/uhd/usrp/dboard/interface.hpp b/host/include/uhd/usrp/dboard/interface.hpp index 68669b99d..e066f2061 100644 --- a/host/include/uhd/usrp/dboard/interface.hpp +++ b/host/include/uhd/usrp/dboard/interface.hpp @@ -19,6 +19,7 @@ #define INCLUDED_UHD_USRP_DBOARD_INTERFACE_HPP #include <boost/shared_ptr.hpp> +#include <vector> #include <stdint.h> namespace uhd{ namespace usrp{ namespace dboard{ @@ -32,6 +33,7 @@ namespace uhd{ namespace usrp{ namespace dboard{ class interface{ public: typedef boost::shared_ptr<interface> sptr; + typedef std::vector<uint8_t> byte_vector_t; //tells the host which device to use enum spi_dev_t{ @@ -119,7 +121,7 @@ public: * \param i2c_addr I2C bus address (7-bits) * \param buf the data to write */ - virtual void write_i2c(int i2c_addr, const std::string &buf) = 0; + virtual void write_i2c(int i2c_addr, const byte_vector_t &buf) = 0; /*! * \brief Read from I2C peripheral @@ -127,7 +129,7 @@ public: * \param len number of bytes to read * \return the data read if successful, else a zero length string. */ - virtual std::string read_i2c(int i2c_addr, size_t len) = 0; + virtual byte_vector_t read_i2c(int i2c_addr, size_t len) = 0; /*! * \brief Write data to SPI bus peripheral. @@ -136,17 +138,29 @@ public: * \param push args for writing * \param buf the data to write */ - virtual void write_spi(spi_dev_t dev, spi_push_t push, const std::string &buf) = 0; + void write_spi(spi_dev_t dev, spi_push_t push, const byte_vector_t &buf); /*! - * \brief Read data from SPI bus peripheral. + * \brief Read data to SPI bus peripheral. * * \param dev which spi device - * \param push args for reading - * \param len number of bytes to read - * \return the data read if sucessful, else a zero length string. + * \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 */ - virtual std::string read_spi(spi_dev_t dev, spi_latch_t latch, size_t len) = 0; + 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. @@ -160,6 +174,24 @@ public: */ 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 diff --git a/host/include/uhd/usrp/mboard/CMakeLists.txt b/host/include/uhd/usrp/mboard/CMakeLists.txt index 79aab8677..2cdb55143 100644 --- a/host/include/uhd/usrp/mboard/CMakeLists.txt +++ b/host/include/uhd/usrp/mboard/CMakeLists.txt @@ -18,7 +18,6 @@ INSTALL(FILES base.hpp - test.hpp usrp2.hpp DESTINATION ${HEADER_DIR}/uhd/usrp/mboard ) diff --git a/host/include/uhd/usrp/mboard/test.hpp b/host/include/uhd/usrp/mboard/test.hpp deleted file mode 100644 index 04d0ff4c4..000000000 --- a/host/include/uhd/usrp/mboard/test.hpp +++ /dev/null @@ -1,46 +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/>. -// - -#ifndef INCLUDED_UHD_USRP_MBOARD_TEST_HPP -#define INCLUDED_UHD_USRP_MBOARD_TEST_HPP - -#include <uhd/usrp/mboard/base.hpp> -#include <uhd/device_addr.hpp> -#include <uhd/usrp/dboard/manager.hpp> -#include <uhd/dict.hpp> - -namespace uhd{ namespace usrp{ namespace mboard{ - -/*! - * A test usrp mboard object. - * Exercises access routines for the test suite. - */ -class test : public base{ -public: - test(const device_addr_t &); - ~test(void); - -private: - void get(const wax::obj &, wax::obj &); - void set(const wax::obj &, const wax::obj &); - - uhd::dict<std::string, dboard::manager::sptr> _dboard_managers; -}; - -}}} //namespace - -#endif /* INCLUDED_UHD_USRP_MBOARD_TEST_HPP */ |