From 8ff364f409b2648e308668a1ddaf6c1d2e8529b1 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Fri, 25 Feb 2011 15:23:01 -0800 Subject: uhd: make ic reg maps depend on common.py --- host/lib/CMakeLists.txt | 2 +- host/lib/ic_reg_maps/CMakeLists.txt | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/host/lib/CMakeLists.txt b/host/lib/CMakeLists.txt index c2dbef89b..597da85c4 100644 --- a/host/lib/CMakeLists.txt +++ b/host/lib/CMakeLists.txt @@ -33,7 +33,7 @@ MACRO(LIBUHD_PYTHON_GEN_SOURCE pyfile outfile) #make the outfile depend on the python script ADD_CUSTOM_COMMAND( - OUTPUT ${outfile} DEPENDS ${pyfile} + OUTPUT ${outfile} DEPENDS ${pyfile} ${LIBUHD_PYTHON_GEN_SOURCE_DEPS} COMMAND ${PYTHON_EXECUTABLE} -B ${pyfile} ${outfile} COMMENT "Generating ${outfile}" ) diff --git a/host/lib/ic_reg_maps/CMakeLists.txt b/host/lib/ic_reg_maps/CMakeLists.txt index 67a63c32b..9e1f4705e 100644 --- a/host/lib/ic_reg_maps/CMakeLists.txt +++ b/host/lib/ic_reg_maps/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2010 Ettus Research LLC +# 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 @@ -20,6 +20,7 @@ ######################################################################## INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}) +SET(LIBUHD_PYTHON_GEN_SOURCE_DEPS ${CMAKE_CURRENT_SOURCE_DIR}/common.py) LIBUHD_PYTHON_GEN_SOURCE( ${CMAKE_CURRENT_SOURCE_DIR}/gen_adf4350_regs.py @@ -90,3 +91,5 @@ LIBUHD_PYTHON_GEN_SOURCE( ${CMAKE_CURRENT_SOURCE_DIR}/gen_tuner_4937di5_regs.py ${CMAKE_CURRENT_BINARY_DIR}/tuner_4937di5_regs.hpp ) + +UNSET(LIBUHD_PYTHON_GEN_SOURCE_DEPS) -- cgit v1.2.3 From c1e1398d011364176761ea815fec88c97a33c9c6 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Fri, 25 Feb 2011 16:08:31 -0800 Subject: usrp-e100: disable the global reset for now --- host/lib/usrp/usrp_e100/usrp_e100_iface.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/host/lib/usrp/usrp_e100/usrp_e100_iface.cpp b/host/lib/usrp/usrp_e100/usrp_e100_iface.cpp index 076ec2fd6..8ac00c2fe 100644 --- a/host/lib/usrp/usrp_e100/usrp_e100_iface.cpp +++ b/host/lib/usrp/usrp_e100/usrp_e100_iface.cpp @@ -110,7 +110,7 @@ public: } //very first thing, reset all the wishbone, always do first! - this->poke32(UE_REG_CLEAR_GLOBAL, 0); + //disabled for now: this->poke32(UE_REG_CLEAR_GLOBAL, 0); mb_eeprom = mboard_eeprom_t(get_i2c_dev_iface(), mboard_eeprom_t::MAP_E100); } -- cgit v1.2.3 From 720475c315f4ca11f0ad222d0acce80e2ce19602 Mon Sep 17 00:00:00 2001 From: Jason Abele Date: Mon, 28 Feb 2011 09:03:45 -0800 Subject: Fix typo in usrp1 external clock modification docs --- host/docs/usrp1.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/host/docs/usrp1.rst b/host/docs/usrp1.rst index 4a239444a..142b849ff 100644 --- a/host/docs/usrp1.rst +++ b/host/docs/usrp1.rst @@ -131,7 +131,7 @@ External clock modification The USRP can be modified to accept an external clock reference instead of the 64MHz onboard reference. * Solder SMA (LTI-SASF54GT) connector to J2001 * Move 0 ohm 0603 resistor R2029 to R2930 - * Move 0.01uF 0603 capacitor C929 to C926 + * Move 0.01uF 0603 capacitor C925 to C926 * Remove 0.01uF 0603 capacitor C924 The new external clock needs to be a square wave between +7dBm and +15dBm -- cgit v1.2.3 From 09bf40269874608c4f6769185fa297c6fb92d1a2 Mon Sep 17 00:00:00 2001 From: Jason Abele Date: Mon, 28 Feb 2011 12:59:54 -0800 Subject: Hopefully the last typo in external clock mod for usrp1 --- host/docs/usrp1.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/host/docs/usrp1.rst b/host/docs/usrp1.rst index 142b849ff..984f89ae9 100644 --- a/host/docs/usrp1.rst +++ b/host/docs/usrp1.rst @@ -130,7 +130,7 @@ External clock modification ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ The USRP can be modified to accept an external clock reference instead of the 64MHz onboard reference. * Solder SMA (LTI-SASF54GT) connector to J2001 - * Move 0 ohm 0603 resistor R2029 to R2930 + * Move 0 ohm 0603 resistor R2029 to R2030 * Move 0.01uF 0603 capacitor C925 to C926 * Remove 0.01uF 0603 capacitor C924 -- cgit v1.2.3 From 6b4a9212da7eb78112b575d47b5ecafebdf5f866 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Mon, 28 Feb 2011 17:10:27 -0800 Subject: usrp2: minor optimization, only disable interruption when we need to wait() --- host/lib/usrp/usrp2/io_impl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/host/lib/usrp/usrp2/io_impl.cpp b/host/lib/usrp/usrp2/io_impl.cpp index 082d77d3e..27a32d7a8 100644 --- a/host/lib/usrp/usrp2/io_impl.cpp +++ b/host/lib/usrp/usrp2/io_impl.cpp @@ -83,10 +83,10 @@ public: * \return false on timeout */ UHD_INLINE bool check_fc_condition(seq_type seq, double timeout){ - boost::this_thread::disable_interruption di; //disable because the wait can throw boost::unique_lock lock(_fc_mutex); _last_seq_out = seq; if (this->ready()) return true; + boost::this_thread::disable_interruption di; //disable because the wait can throw return _fc_cond.timed_wait(lock, to_time_dur(timeout), _ready_fcn); } -- cgit v1.2.3 From 90c907074c65bf9112c0a85341ebf18e811df3f8 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Tue, 1 Mar 2011 11:12:30 -0800 Subject: udp: return the managed recv buffer to the buffer queue on timeout --- host/lib/transport/udp_zero_copy.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/host/lib/transport/udp_zero_copy.cpp b/host/lib/transport/udp_zero_copy.cpp index dda3bb547..5810f441c 100644 --- a/host/lib/transport/udp_zero_copy.cpp +++ b/host/lib/transport/udp_zero_copy.cpp @@ -196,6 +196,8 @@ public: if (wait_for_recv_ready(_sock_fd, timeout)) return mrb->get_new( ::recv(_sock_fd, mrb->cast(), _recv_frame_size, 0) ); + + this->handle_recv(mrb); //timeout: return the managed buffer to the queue } return managed_recv_buffer::sptr(); } -- cgit v1.2.3 From 77319389b09c663170284ed64961ab27cf77488e Mon Sep 17 00:00:00 2001 From: Nick Foster Date: Tue, 1 Mar 2011 18:06:13 -0800 Subject: Generalized the mboard_iface into mboard_iface.hpp and made each of the USRP devices inherit from it. --- host/include/uhd/usrp/mboard_iface.hpp | 103 ++++++++++++++++++++++++++++ host/lib/usrp/usrp1/usrp1_iface.cpp | 17 +++++ host/lib/usrp/usrp1/usrp1_iface.hpp | 36 +--------- host/lib/usrp/usrp2/usrp2_iface.hpp | 58 +--------------- host/lib/usrp/usrp_e100/usrp_e100_iface.cpp | 8 +++ host/lib/usrp/usrp_e100/usrp_e100_iface.hpp | 51 +------------- 6 files changed, 134 insertions(+), 139 deletions(-) create mode 100644 host/include/uhd/usrp/mboard_iface.hpp diff --git a/host/include/uhd/usrp/mboard_iface.hpp b/host/include/uhd/usrp/mboard_iface.hpp new file mode 100644 index 000000000..4924bc99b --- /dev/null +++ b/host/include/uhd/usrp/mboard_iface.hpp @@ -0,0 +1,103 @@ +// +// 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 . +// + +#ifndef INCLUDED_UHD_USRP_MBOARD_IFACE_HPP +#define INCLUDED_UHD_USRP_MBOARD_IFACE_HPP + +#include +#include +#include +#include +#include +#include +#include + +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: + /*! + * 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; + + /*! + * Perform an 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 uhd::spi_config_t &config, + boost::uint32_t data, + size_t num_bits, + bool readback + ) = 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/lib/usrp/usrp1/usrp1_iface.cpp b/host/lib/usrp/usrp1/usrp1_iface.cpp index 947847044..591bbda87 100644 --- a/host/lib/usrp/usrp1/usrp1_iface.cpp +++ b/host/lib/usrp/usrp1/usrp1_iface.cpp @@ -93,6 +93,23 @@ public: return uhd::ntohx(value_out); } + + void poke16(boost::uint32_t addr, boost::uint16_t value) { + throw std::runtime_error("Unhandled command poke16()"); + } + + boost::uint16_t peek16(boost::uint32_t addr) { + throw std::runtime_error("Unhandled command peek16()"); + return 0; + } + + void write_uart(boost::uint8_t dev, const std::string &buf) { + throw std::runtime_error("Unhandled command write_uart()"); + } + + std::string read_uart(boost::uint8_t dev) { + throw std::runtime_error("Unhandled command read_uart()"); + } /******************************************************************* * I2C diff --git a/host/lib/usrp/usrp1/usrp1_iface.hpp b/host/lib/usrp/usrp1/usrp1_iface.hpp index 34a2330b5..e808e2959 100644 --- a/host/lib/usrp/usrp1/usrp1_iface.hpp +++ b/host/lib/usrp/usrp1/usrp1_iface.hpp @@ -18,8 +18,7 @@ #ifndef INCLUDED_USRP1_IFACE_HPP #define INCLUDED_USRP1_IFACE_HPP -#include -#include +#include #include #include #include "usrp1_ctrl.hpp" @@ -29,7 +28,7 @@ * Provides a set of functions to implementation layer. * Including spi, peek, poke, control... */ -class usrp1_iface : boost::noncopyable, public uhd::i2c_iface{ +class usrp1_iface : public uhd::usrp::mboard_iface, boost::noncopyable{ public: typedef boost::shared_ptr sptr; @@ -40,35 +39,6 @@ public: */ static sptr make(usrp_ctrl::sptr ctrl_transport); - /*! - * 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; - - /*! - * Perform an 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 uhd::spi_config_t &config, - boost::uint32_t data, - size_t num_bits, - bool readback) = 0; - /*! * Perform a general USB firmware OUT operation * \param request @@ -82,8 +52,6 @@ public: boost::uint16_t index, unsigned char* buff, boost::uint16_t length) = 0; - - uhd::usrp::mboard_eeprom_t mb_eeprom; }; #endif /* INCLUDED_USRP1_IFACE_HPP */ diff --git a/host/lib/usrp/usrp2/usrp2_iface.hpp b/host/lib/usrp/usrp2/usrp2_iface.hpp index 49cb0e6dc..55fcdc0d2 100644 --- a/host/lib/usrp/usrp2/usrp2_iface.hpp +++ b/host/lib/usrp/usrp2/usrp2_iface.hpp @@ -19,8 +19,7 @@ #define INCLUDED_USRP2_IFACE_HPP #include -#include -#include +#include #include #include #include @@ -40,10 +39,9 @@ typedef boost::function gps_recv_fn_t; * Provides a set of functions to implementation layer. * Including spi, peek, poke, control... */ -class usrp2_iface : public uhd::i2c_iface, boost::noncopyable{ +class usrp2_iface : public uhd::usrp::mboard_iface, boost::noncopyable{ public: typedef boost::shared_ptr sptr; - /*! * Make a new usrp2 interface with the control transport. * \param ctrl_transport the udp transport object @@ -58,55 +56,6 @@ public: */ virtual usrp2_ctrl_data_t ctrl_send_and_recv(const usrp2_ctrl_data_t &data) = 0; - /*! - * 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; - - /*! - * Perform an 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 uhd::spi_config_t &config, - boost::uint32_t data, - size_t num_bits, - bool readback - ) = 0; - - virtual void write_uart(boost::uint8_t dev, const std::string &buf) = 0; - - virtual std::string read_uart(boost::uint8_t dev) = 0; - virtual gps_recv_fn_t get_gps_read_fn(void) = 0; virtual gps_send_fn_t get_gps_write_fn(void) = 0; @@ -129,9 +78,6 @@ public: * Register map selected from USRP2/USRP2+. */ usrp2_regs_t regs; - - //motherboard eeprom map structure - uhd::usrp::mboard_eeprom_t mb_eeprom; }; #endif /* INCLUDED_USRP2_IFACE_HPP */ diff --git a/host/lib/usrp/usrp_e100/usrp_e100_iface.cpp b/host/lib/usrp/usrp_e100/usrp_e100_iface.cpp index 8ac00c2fe..912e4d48b 100644 --- a/host/lib/usrp/usrp_e100/usrp_e100_iface.cpp +++ b/host/lib/usrp/usrp_e100/usrp_e100_iface.cpp @@ -257,6 +257,14 @@ public: //unload the data return data.data; } + + void write_uart(boost::uint8_t dev, const std::string &buf) { + throw std::runtime_error("Unhandled command write_uart()"); + } + + std::string read_uart(boost::uint8_t dev) { + throw std::runtime_error("Unhandled command read_uart()"); + } private: int _node_fd; diff --git a/host/lib/usrp/usrp_e100/usrp_e100_iface.hpp b/host/lib/usrp/usrp_e100/usrp_e100_iface.hpp index 12283fb52..5e346519c 100644 --- a/host/lib/usrp/usrp_e100/usrp_e100_iface.hpp +++ b/host/lib/usrp/usrp_e100/usrp_e100_iface.hpp @@ -24,6 +24,7 @@ #include #include #include +#include //////////////////////////////////////////////////////////////////////// // I2C addresses @@ -39,7 +40,7 @@ * Provides a set of functions to implementation layer. * Including spi, peek, poke, control... */ -class usrp_e100_iface : boost::noncopyable, public uhd::i2c_iface{ +class usrp_e100_iface : boost::noncopyable, public uhd::usrp::mboard_iface{ public: typedef boost::shared_ptr sptr; @@ -66,54 +67,6 @@ public: //! Get the I2C interface for the I2C device node virtual uhd::i2c_iface &get_i2c_dev_iface(void) = 0; - - /*! - * 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; - - /*! - * Perform an 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 uhd::spi_config_t &config, - boost::uint32_t data, - size_t num_bits, - bool readback - ) = 0; - - //motherboard eeprom map structure - uhd::usrp::mboard_eeprom_t mb_eeprom; }; #endif /* INCLUDED_USRP_E100_IFACE_HPP */ -- cgit v1.2.3 From 1b63cd2560886d851f3e2ba98bfddf772c44df34 Mon Sep 17 00:00:00 2001 From: Nick Foster Date: Thu, 3 Mar 2011 10:50:45 -0800 Subject: Generalized mboard_iface and added a SPI convenience class a la I2C --- host/include/uhd/types/serial.hpp | 59 +++++++++++++++++++++++++++++ host/include/uhd/usrp/CMakeLists.txt | 1 + host/include/uhd/usrp/mboard_iface.hpp | 20 +--------- host/include/uhd/usrp/mboard_props.hpp | 3 +- host/include/uhd/usrp/multi_usrp.hpp | 7 ++++ host/lib/usrp/multi_usrp.cpp | 5 +++ host/lib/usrp/usrp1/codec_ctrl.cpp | 8 ++-- host/lib/usrp/usrp1/dboard_iface.cpp | 8 ++-- host/lib/usrp/usrp1/usrp1_iface.cpp | 8 ++-- host/lib/usrp/usrp2/clock_ctrl.cpp | 2 +- host/lib/usrp/usrp2/codec_ctrl.cpp | 8 ++-- host/lib/usrp/usrp2/dboard_iface.cpp | 16 ++++---- host/lib/usrp/usrp_e100/clock_ctrl.cpp | 8 ++-- host/lib/usrp/usrp_e100/codec_ctrl.cpp | 8 ++-- host/lib/usrp/usrp_e100/dboard_iface.cpp | 4 +- host/lib/usrp/usrp_e100/usrp_e100_iface.cpp | 4 +- 16 files changed, 113 insertions(+), 56 deletions(-) diff --git a/host/include/uhd/types/serial.hpp b/host/include/uhd/types/serial.hpp index c134725f5..9b203324b 100644 --- a/host/include/uhd/types/serial.hpp +++ b/host/include/uhd/types/serial.hpp @@ -116,6 +116,65 @@ 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 uhd::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 + */ + boost::uint32_t read_spi( + int which_slave, + const uhd::spi_config_t &config, + boost::uint16_t data, + size_t num_bits) { + return transact_spi( + which_slave, config, data, num_bits, true + ); + } + + /*! + * 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 + */ + void write_spi( + int which_slave, + const uhd::spi_config_t &config, + boost::uint16_t data, + size_t num_bits) { + transact_spi( + which_slave, config, data, num_bits, false + ); + } + }; } //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 index 4924bc99b..cfd273232 100644 --- a/host/include/uhd/usrp/mboard_iface.hpp +++ b/host/include/uhd/usrp/mboard_iface.hpp @@ -33,8 +33,9 @@ namespace uhd{ namespace usrp{ * Provides a set of functions to implementation layer. * Including spi, peek, poke, control... */ -class mboard_iface : public uhd::i2c_iface { +class mboard_iface : public uhd::i2c_iface, public uhd::spi_iface { public: + typedef boost::shared_ptr sptr; /*! * Write a register (32 bits) * \param addr the address @@ -63,23 +64,6 @@ public: */ virtual boost::uint16_t peek16(boost::uint32_t addr) = 0; - /*! - * Perform an 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 uhd::spi_config_t &config, - boost::uint32_t data, - size_t num_bits, - bool readback - ) = 0; - /*! * Write to a serial port. * \param dev which UART to write to 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 #include #include +#include #include #include #include @@ -250,6 +251,12 @@ public: * \return a vector of sensor names */ virtual std::vector 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 diff --git a/host/lib/usrp/multi_usrp.cpp b/host/lib/usrp/multi_usrp.cpp index 0acc53397..565d35d1c 100644 --- a/host/lib/usrp/multi_usrp.cpp +++ b/host/lib/usrp/multi_usrp.cpp @@ -18,6 +18,7 @@ #include "wrapper_utils.hpp" #include #include +#include #include #include #include @@ -218,6 +219,10 @@ public: std::vector get_mboard_sensor_names(size_t mboard){ return _mboard(mboard)[MBOARD_PROP_SENSOR_NAMES].as(); } + + mboard_iface::sptr get_mboard_iface(size_t mboard){ + return _mboard(mboard)[MBOARD_PROP_IFACE].as(); + } /******************************************************************* * RX methods diff --git a/host/lib/usrp/usrp1/codec_ctrl.cpp b/host/lib/usrp/usrp1/codec_ctrl.cpp index f9f923f38..1b4411002 100644 --- a/host/lib/usrp/usrp1/codec_ctrl.cpp +++ b/host/lib/usrp/usrp1/codec_ctrl.cpp @@ -303,8 +303,8 @@ 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_slave, - spi_config_t::EDGE_RISE, reg, 16, false); + _iface->write_spi(_spi_slave, + spi_config_t::EDGE_RISE, reg, 16); } void usrp1_codec_ctrl_impl::recv_reg(boost::uint8_t addr) @@ -317,8 +317,8 @@ 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_slave, - spi_config_t::EDGE_RISE, reg, 16, true); + boost::uint32_t ret = _iface->read_spi(_spi_slave, + spi_config_t::EDGE_RISE, reg, 16); if (codec_debug) { std::cout.fill('0'); diff --git a/host/lib/usrp/usrp1/dboard_iface.cpp b/host/lib/usrp/usrp1/dboard_iface.cpp index 53ccd4d55..3f3a98b7a 100644 --- a/host/lib/usrp/usrp1/dboard_iface.cpp +++ b/host/lib/usrp/usrp1/dboard_iface.cpp @@ -337,8 +337,8 @@ void usrp1_dboard_iface::write_spi(unit_t unit, boost::uint32_t data, size_t num_bits) { - _iface->transact_spi(unit_to_otw_spi_dev(unit, _dboard_slot), - config, data, num_bits, false); + _iface->write_spi(unit_to_otw_spi_dev(unit, _dboard_slot), + config, data, num_bits); } boost::uint32_t usrp1_dboard_iface::read_write_spi(unit_t unit, @@ -346,8 +346,8 @@ boost::uint32_t usrp1_dboard_iface::read_write_spi(unit_t unit, boost::uint32_t data, size_t num_bits) { - return _iface->transact_spi(unit_to_otw_spi_dev(unit, _dboard_slot), - config, data, num_bits, true); + return _iface->read_spi(unit_to_otw_spi_dev(unit, _dboard_slot), + config, data, num_bits); } /*********************************************************************** diff --git a/host/lib/usrp/usrp1/usrp1_iface.cpp b/host/lib/usrp/usrp1/usrp1_iface.cpp index 591bbda87..491f76cef 100644 --- a/host/lib/usrp/usrp1/usrp1_iface.cpp +++ b/host/lib/usrp/usrp1/usrp1_iface.cpp @@ -95,20 +95,20 @@ public: } void poke16(boost::uint32_t addr, boost::uint16_t value) { - throw std::runtime_error("Unhandled command poke16()"); + throw uhd::not_implemented_error("Unhandled command poke16()"); } boost::uint16_t peek16(boost::uint32_t addr) { - throw std::runtime_error("Unhandled command peek16()"); + throw uhd::not_implemented_error("Unhandled command peek16()"); return 0; } void write_uart(boost::uint8_t dev, const std::string &buf) { - throw std::runtime_error("Unhandled command write_uart()"); + throw uhd::not_implemented_error("Unhandled command write_uart()"); } std::string read_uart(boost::uint8_t dev) { - throw std::runtime_error("Unhandled command read_uart()"); + throw uhd::not_implemented_error("Unhandled command read_uart()"); } /******************************************************************* diff --git a/host/lib/usrp/usrp2/clock_ctrl.cpp b/host/lib/usrp/usrp2/clock_ctrl.cpp index aaafbae53..abda53bf2 100644 --- a/host/lib/usrp/usrp2/clock_ctrl.cpp +++ b/host/lib/usrp/usrp2/clock_ctrl.cpp @@ -305,7 +305,7 @@ private: */ void write_reg(boost::uint8_t addr){ boost::uint32_t data = _ad9510_regs.get_write_reg(addr); - _iface->transact_spi(SPI_SS_AD9510, spi_config_t::EDGE_RISE, data, 24, false /*no rb*/); + _iface->write_spi(SPI_SS_AD9510, spi_config_t::EDGE_RISE, data, 24); } /*! diff --git a/host/lib/usrp/usrp2/codec_ctrl.cpp b/host/lib/usrp/usrp2/codec_ctrl.cpp index be5c2c899..0fdcedf62 100644 --- a/host/lib/usrp/usrp2/codec_ctrl.cpp +++ b/host/lib/usrp/usrp2/codec_ctrl.cpp @@ -168,17 +168,17 @@ private: void send_ad9777_reg(boost::uint8_t addr){ boost::uint16_t reg = _ad9777_regs.get_write_reg(addr); if (codec_ctrl_debug) std::cout << "send_ad9777_reg: " << std::hex << reg << std::endl; - _iface->transact_spi( + _iface->write_spi( SPI_SS_AD9777, spi_config_t::EDGE_RISE, - reg, 16, false /*no rb*/ + reg, 16 ); } void send_ads62p44_reg(boost::uint8_t addr) { boost::uint16_t reg = _ads62p44_regs.get_write_reg(addr); - _iface->transact_spi( + _iface->write_spi( SPI_SS_ADS62P44, spi_config_t::EDGE_FALL, - reg, 16, false /*no rb*/ + reg, 16 ); } }; diff --git a/host/lib/usrp/usrp2/dboard_iface.cpp b/host/lib/usrp/usrp2/dboard_iface.cpp index 8b2df61d6..924a6e901 100644 --- a/host/lib/usrp/usrp2/dboard_iface.cpp +++ b/host/lib/usrp/usrp2/dboard_iface.cpp @@ -257,7 +257,7 @@ void usrp2_dboard_iface::write_spi( boost::uint32_t data, size_t num_bits ){ - _iface->transact_spi(unit_to_spi_dev[unit], config, data, num_bits, false /*no rb*/); + _iface->write_spi(unit_to_spi_dev[unit], config, data, num_bits); } boost::uint32_t usrp2_dboard_iface::read_write_spi( @@ -266,7 +266,7 @@ boost::uint32_t usrp2_dboard_iface::read_write_spi( boost::uint32_t data, size_t num_bits ){ - return _iface->transact_spi(unit_to_spi_dev[unit], config, data, num_bits, true /*rb*/); + return _iface->read_spi(unit_to_spi_dev[unit], config, data, num_bits); } /*********************************************************************** @@ -288,9 +288,9 @@ void usrp2_dboard_iface::_write_aux_dac(unit_t unit){ (UNIT_RX, SPI_SS_RX_DAC) (UNIT_TX, SPI_SS_TX_DAC) ; - _iface->transact_spi( + _iface->write_spi( unit_to_spi_dac[unit], spi_config_t::EDGE_FALL, - _dac_regs[unit].get_reg(), 24, false /*no rb*/ + _dac_regs[unit].get_reg(), 24 ); } @@ -336,13 +336,13 @@ double usrp2_dboard_iface::read_aux_adc(unit_t unit, aux_adc_t which){ } ad7922_regs.chn = ad7922_regs.mod; //normal mode: mod == chn //write and read spi - _iface->transact_spi( + _iface->write_spi( unit_to_spi_adc[unit], config, - ad7922_regs.get_reg(), 16, false /*no rb*/ + ad7922_regs.get_reg(), 16 ); - ad7922_regs.set_reg(boost::uint16_t(_iface->transact_spi( + ad7922_regs.set_reg(boost::uint16_t(_iface->read_spi( unit_to_spi_adc[unit], config, - ad7922_regs.get_reg(), 16, true /*rb*/ + ad7922_regs.get_reg(), 16 ))); //convert to voltage and return diff --git a/host/lib/usrp/usrp_e100/clock_ctrl.cpp b/host/lib/usrp/usrp_e100/clock_ctrl.cpp index b4ddcd271..bb6fb7e3b 100644 --- a/host/lib/usrp/usrp_e100/clock_ctrl.cpp +++ b/host/lib/usrp/usrp_e100/clock_ctrl.cpp @@ -409,10 +409,10 @@ private: void send_reg(boost::uint16_t addr){ boost::uint32_t reg = _ad9522_regs.get_write_reg(addr); //std::cout << "clock control write reg: " << std::hex << reg << std::endl; - _iface->transact_spi( + _iface->write_spi( UE_SPI_SS_AD9522, spi_config_t::EDGE_RISE, - reg, 24, false /*no rb*/ + reg, 24 ); } @@ -427,9 +427,9 @@ private: //wait for calibration done: static const boost::uint8_t addr = 0x01F; for (size_t ms10 = 0; ms10 < 100; ms10++){ - boost::uint32_t reg = _iface->transact_spi( + boost::uint32_t reg = _iface->read_spi( UE_SPI_SS_AD9522, spi_config_t::EDGE_RISE, - _ad9522_regs.get_read_reg(addr), 24, true /*rb*/ + _ad9522_regs.get_read_reg(addr), 24 ); _ad9522_regs.set_reg(addr, reg); if (_ad9522_regs.vco_calibration_finished) return; diff --git a/host/lib/usrp/usrp_e100/codec_ctrl.cpp b/host/lib/usrp/usrp_e100/codec_ctrl.cpp index 71a370f88..50442546a 100644 --- a/host/lib/usrp/usrp_e100/codec_ctrl.cpp +++ b/host/lib/usrp/usrp_e100/codec_ctrl.cpp @@ -269,20 +269,20 @@ void usrp_e100_codec_ctrl_impl::write_aux_dac(aux_dac_t which, double volts){ void usrp_e100_codec_ctrl_impl::send_reg(boost::uint8_t addr){ boost::uint32_t reg = _ad9862_regs.get_write_reg(addr); if (codec_debug) std::cout << "codec control write reg: " << std::hex << reg << std::endl; - _iface->transact_spi( + _iface->write_spi( UE_SPI_SS_AD9862, spi_config_t::EDGE_RISE, - reg, 16, false /*no rb*/ + reg, 16 ); } void usrp_e100_codec_ctrl_impl::recv_reg(boost::uint8_t addr){ boost::uint32_t reg = _ad9862_regs.get_read_reg(addr); if (codec_debug) std::cout << "codec control read reg: " << std::hex << reg << std::endl; - boost::uint32_t ret = _iface->transact_spi( + boost::uint32_t ret = _iface->read_spi( UE_SPI_SS_AD9862, spi_config_t::EDGE_RISE, - reg, 16, true /*rb*/ + reg, 16 ); if (codec_debug) std::cout << "codec control read ret: " << std::hex << ret << std::endl; _ad9862_regs.set_reg(addr, boost::uint16_t(ret)); diff --git a/host/lib/usrp/usrp_e100/dboard_iface.cpp b/host/lib/usrp/usrp_e100/dboard_iface.cpp index ee1b852bf..4ee354486 100644 --- a/host/lib/usrp/usrp_e100/dboard_iface.cpp +++ b/host/lib/usrp/usrp_e100/dboard_iface.cpp @@ -244,7 +244,7 @@ void usrp_e100_dboard_iface::write_spi( boost::uint32_t data, size_t num_bits ){ - _iface->transact_spi(unit_to_otw_spi_dev(unit), config, data, num_bits, false /*no rb*/); + _iface->write_spi(unit_to_otw_spi_dev(unit), config, data, num_bits); } boost::uint32_t usrp_e100_dboard_iface::read_write_spi( @@ -253,7 +253,7 @@ boost::uint32_t usrp_e100_dboard_iface::read_write_spi( boost::uint32_t data, size_t num_bits ){ - return _iface->transact_spi(unit_to_otw_spi_dev(unit), config, data, num_bits, true /*rb*/); + return _iface->read_spi(unit_to_otw_spi_dev(unit), config, data, num_bits); } /*********************************************************************** diff --git a/host/lib/usrp/usrp_e100/usrp_e100_iface.cpp b/host/lib/usrp/usrp_e100/usrp_e100_iface.cpp index 912e4d48b..6d3f41fab 100644 --- a/host/lib/usrp/usrp_e100/usrp_e100_iface.cpp +++ b/host/lib/usrp/usrp_e100/usrp_e100_iface.cpp @@ -259,11 +259,11 @@ public: } void write_uart(boost::uint8_t dev, const std::string &buf) { - throw std::runtime_error("Unhandled command write_uart()"); + throw uhd::not_implemented_error("Unhandled command write_uart()"); } std::string read_uart(boost::uint8_t dev) { - throw std::runtime_error("Unhandled command read_uart()"); + throw uhd::not_implemented_error("Unhandled command read_uart()"); } private: -- cgit v1.2.3