diff options
Diffstat (limited to 'host')
-rw-r--r-- | host/include/uhd/types/CMakeLists.txt | 1 | ||||
-rw-r--r-- | host/include/uhd/types/io_type.hpp | 1 | ||||
-rw-r--r-- | host/include/uhd/types/serial.hpp | 61 | ||||
-rw-r--r-- | host/include/uhd/usrp/dboard_iface.hpp | 30 | ||||
-rw-r--r-- | host/lib/types.cpp | 9 | ||||
-rw-r--r-- | host/lib/usrp/usrp2/clock_control.cpp | 1 | ||||
-rw-r--r-- | host/lib/usrp/usrp2/dboard_iface.cpp | 6 | ||||
-rw-r--r-- | host/lib/usrp/usrp2/usrp2_iface.cpp | 1 | ||||
-rw-r--r-- | host/lib/usrp/usrp2/usrp2_iface.hpp | 4 |
9 files changed, 80 insertions, 34 deletions
diff --git a/host/include/uhd/types/CMakeLists.txt b/host/include/uhd/types/CMakeLists.txt index e4cdf2cef..dbce21c98 100644 --- a/host/include/uhd/types/CMakeLists.txt +++ b/host/include/uhd/types/CMakeLists.txt @@ -25,6 +25,7 @@ INSTALL(FILES metadata.hpp otw_type.hpp ranges.hpp + serial.hpp stream_cmd.hpp time_spec.hpp tune_result.hpp diff --git a/host/include/uhd/types/io_type.hpp b/host/include/uhd/types/io_type.hpp index 930394d1b..5176374d6 100644 --- a/host/include/uhd/types/io_type.hpp +++ b/host/include/uhd/types/io_type.hpp @@ -23,6 +23,7 @@ namespace uhd{ /*! + * The Input/Output configuration struct: * Used to specify the IO type with device send/recv. */ class UHD_API io_type_t{ diff --git a/host/include/uhd/types/serial.hpp b/host/include/uhd/types/serial.hpp new file mode 100644 index 000000000..b0fe5d7bd --- /dev/null +++ b/host/include/uhd/types/serial.hpp @@ -0,0 +1,61 @@ +// +// 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_TYPES_SERIAL_HPP +#define INCLUDED_UHD_TYPES_SERIAL_HPP + +#include <uhd/config.hpp> +#include <boost/cstdint.hpp> +#include <vector> + +namespace uhd{ + + /*! + * Byte vector typedef for passing data in and out of I2C interfaces. + */ + typedef std::vector<boost::uint8_t> byte_vector_t; + + /*! + * The SPI configuration struct: + * Used to configure a SPI transaction interface. + */ + struct UHD_API spi_config_t{ + /*! + * The edge type specifies when data is valid + * relative to the edge of the serial clock. + */ + enum edge_t{ + EDGE_RISE = 'r', + EDGE_FALL = 'f' + }; + + //! on what edge is the mosi data valid? + edge_t mosi_edge; + + //! on what edge is the miso data valid? + edge_t miso_edge; + + /*! + * Create a new spi config. + * \param edge the default edge for mosi and miso + */ + spi_config_t(edge_t edge = EDGE_RISE); + }; + +} //namespace uhd + +#endif /* INCLUDED_UHD_TYPES_SERIAL_HPP */ diff --git a/host/include/uhd/usrp/dboard_iface.hpp b/host/include/uhd/usrp/dboard_iface.hpp index 71c7be200..79b8ee664 100644 --- a/host/include/uhd/usrp/dboard_iface.hpp +++ b/host/include/uhd/usrp/dboard_iface.hpp @@ -19,39 +19,12 @@ #define INCLUDED_UHD_USRP_DBOARD_IFACE_HPP #include <uhd/config.hpp> +#include <uhd/types/serial.hpp> #include <boost/shared_ptr.hpp> #include <boost/cstdint.hpp> -#include <vector> namespace uhd{ namespace usrp{ -//spi configuration struct -struct UHD_API spi_config_t{ - /*! - * The edge type specifies when data is valid - * relative to the edge of the serial clock. - */ - enum edge_t{ - EDGE_RISE = 'r', - EDGE_FALL = 'f' - }; - - //! on what edge is the mosi data valid? - edge_t mosi_edge; - - //! on what edge is the miso data valid? - edge_t miso_edge; - - /*! - * Create a new spi config. - * \param edge the default edge for mosi and miso - */ - spi_config_t(edge_t edge = EDGE_RISE){ - mosi_edge = edge; - miso_edge = edge; - } -}; - /*! * The daughter board dboard interface to be subclassed. * A dboard instance interfaces with the mboard though this api. @@ -61,7 +34,6 @@ struct UHD_API spi_config_t{ class UHD_API dboard_iface{ public: typedef boost::shared_ptr<dboard_iface> sptr; - typedef std::vector<boost::uint8_t> byte_vector_t; //tells the host which unit to use enum unit_t{ diff --git a/host/lib/types.cpp b/host/lib/types.cpp index 0fd2522cf..2a687f34f 100644 --- a/host/lib/types.cpp +++ b/host/lib/types.cpp @@ -25,6 +25,7 @@ #include <uhd/types/mac_addr.hpp> #include <uhd/types/otw_type.hpp> #include <uhd/types/io_type.hpp> +#include <uhd/types/serial.hpp> #include <boost/algorithm/string.hpp> #include <boost/math/special_functions/round.hpp> #include <boost/foreach.hpp> @@ -243,3 +244,11 @@ io_type_t::io_type_t(size_t size) : size(size), tid(CUSTOM_TYPE){ /* NOP */ } + +/*********************************************************************** + * serial + **********************************************************************/ +spi_config_t::spi_config_t(edge_t edge){ + mosi_edge = edge; + miso_edge = edge; +} diff --git a/host/lib/usrp/usrp2/clock_control.cpp b/host/lib/usrp/usrp2/clock_control.cpp index dcd7ce9da..72f1f1c7a 100644 --- a/host/lib/usrp/usrp2/clock_control.cpp +++ b/host/lib/usrp/usrp2/clock_control.cpp @@ -21,6 +21,7 @@ #include "usrp2_regs.hpp" //spi slave constants #include <boost/cstdint.hpp> +using namespace uhd; using namespace uhd::usrp; /*! diff --git a/host/lib/usrp/usrp2/dboard_iface.cpp b/host/lib/usrp/usrp2/dboard_iface.cpp index 2859a7981..5ccb6fa47 100644 --- a/host/lib/usrp/usrp2/dboard_iface.cpp +++ b/host/lib/usrp/usrp2/dboard_iface.cpp @@ -17,7 +17,8 @@ #include "usrp2_iface.hpp" #include "clock_control.hpp" -#include "usrp2_regs.hpp" +#include "usrp2_regs.hpp" //wishbone address constants +#include <uhd/usrp/dboard_iface.hpp> #include <uhd/types/dict.hpp> #include <uhd/utils/assert.hpp> #include <boost/assign/list_of.hpp> @@ -25,6 +26,7 @@ #include <boost/math/special_functions/round.hpp> #include <algorithm> +using namespace uhd; using namespace uhd::usrp; class usrp2_dboard_iface : public dboard_iface{ @@ -214,7 +216,7 @@ void usrp2_dboard_iface::write_i2c(int i2c_addr, const byte_vector_t &buf){ ASSERT_THROW(htonl(in_data.id) == USRP2_CTRL_ID_COOL_IM_DONE_I2C_WRITE_DUDE); } -dboard_iface::byte_vector_t usrp2_dboard_iface::read_i2c(int i2c_addr, size_t num_bytes){ +byte_vector_t usrp2_dboard_iface::read_i2c(int i2c_addr, size_t num_bytes){ //setup the out data usrp2_ctrl_data_t out_data; out_data.id = htonl(USRP2_CTRL_ID_DO_AN_I2C_READ_FOR_ME_BRO); diff --git a/host/lib/usrp/usrp2/usrp2_iface.cpp b/host/lib/usrp/usrp2/usrp2_iface.cpp index 5c84fd8d3..742c53a14 100644 --- a/host/lib/usrp/usrp2/usrp2_iface.cpp +++ b/host/lib/usrp/usrp2/usrp2_iface.cpp @@ -24,7 +24,6 @@ #include <stdexcept> using namespace uhd; -using namespace uhd::usrp; class usrp2_iface_impl : public usrp2_iface{ public: diff --git a/host/lib/usrp/usrp2/usrp2_iface.hpp b/host/lib/usrp/usrp2/usrp2_iface.hpp index 1298d87f1..6667c8998 100644 --- a/host/lib/usrp/usrp2/usrp2_iface.hpp +++ b/host/lib/usrp/usrp2/usrp2_iface.hpp @@ -19,7 +19,7 @@ #define INCLUDED_USRP2_IFACE_HPP #include <uhd/transport/udp_simple.hpp> -#include <uhd/usrp/dboard_iface.hpp> //spi config +#include <uhd/types/serial.hpp> #include <boost/shared_ptr.hpp> #include <boost/utility.hpp> #include <boost/cstdint.hpp> @@ -87,7 +87,7 @@ public: */ virtual boost::uint32_t transact_spi( int which_slave, - const uhd::usrp::spi_config_t &config, + const uhd::spi_config_t &config, boost::uint32_t data, size_t num_bits, bool readback |