diff options
author | Josh Blum <josh@joshknows.com> | 2010-01-12 16:23:54 -0800 |
---|---|---|
committer | Josh Blum <josh@joshknows.com> | 2010-01-12 16:23:54 -0800 |
commit | 087b97e0fc28793ea39d81e60b3fddae51c5929e (patch) | |
tree | 7098f93d0a39ab50a0eea43356ac0857c584ee25 | |
parent | cbb8e474bb5592753a340ba31d3afbab7226f7c6 (diff) | |
download | uhd-087b97e0fc28793ea39d81e60b3fddae51c5929e.tar.gz uhd-087b97e0fc28793ea39d81e60b3fddae51c5929e.tar.bz2 uhd-087b97e0fc28793ea39d81e60b3fddae51c5929e.zip |
added interface for usrp dboards to communicate to mboards
-rw-r--r-- | Makefile.common | 2 | ||||
-rw-r--r-- | include/usrp_uhd/usrp/dboard/Makefile.am | 4 | ||||
-rw-r--r-- | include/usrp_uhd/usrp/dboard/interface.hpp | 147 | ||||
-rw-r--r-- | lib/Makefile.am | 7 | ||||
-rw-r--r-- | lib/usrp/Makefile.am | 2 | ||||
-rw-r--r-- | lib/usrp/dboard/Makefile.am | 11 | ||||
-rw-r--r-- | lib/usrp/dboard/interface.cpp | 15 | ||||
-rw-r--r-- | test/Makefile.am | 2 |
8 files changed, 185 insertions, 5 deletions
diff --git a/Makefile.common b/Makefile.common index 3b1464439..91958e393 100644 --- a/Makefile.common +++ b/Makefile.common @@ -4,6 +4,8 @@ USRP_UHD_LA = $(top_srcdir)/lib/libusrp_uhd.la +USRP_UHD_USRP_DBOARD_LA = $(top_srcdir)/lib/usrp/dboard/lib.la + GENERAL_CPPFLAGS = \ -I$(top_srcdir)/include \ $(BOOST_CPPFLAGS) diff --git a/include/usrp_uhd/usrp/dboard/Makefile.am b/include/usrp_uhd/usrp/dboard/Makefile.am index 66fc4dd71..19777b11a 100644 --- a/include/usrp_uhd/usrp/dboard/Makefile.am +++ b/include/usrp_uhd/usrp/dboard/Makefile.am @@ -5,3 +5,7 @@ include $(top_srcdir)/Makefile.common SUBDIRS = + +this_includedir = $(includedir)/usrp_uhd/usrp/dboard +this_include_HEADERS = \ + interface.hpp diff --git a/include/usrp_uhd/usrp/dboard/interface.hpp b/include/usrp_uhd/usrp/dboard/interface.hpp new file mode 100644 index 000000000..f9e4c96b4 --- /dev/null +++ b/include/usrp_uhd/usrp/dboard/interface.hpp @@ -0,0 +1,147 @@ +// +// Copyright 2010 Ettus Research LLC +// + +#ifndef INCLUDED_USRP_UHD_USRP_DBOARD_INTERFACE_H +#define INCLUDED_USRP_UHD_USRP_DBOARD_INTERFACE_H + +#include <boost/shared_ptr.hpp> +#include <stdint.h> + +namespace usrp_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<interface> sptr; + + //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 which_dac the dac index 0, 1, 2, 3... + * \param value the value to write + */ + virtual void write_aux_dac(int which_dac, int value) = 0; + + /*! + * Read from an aux adc. + * \param which_adc the adc index 0, 1, 2, 3... + * \return the value that was read + */ + virtual int read_aux_adc(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 input, 1=FPGA output + * \param rx_value 16-bits, 0=FPGA input, 1=FPGA output + * \param mask 16-bits, 0=ignore, 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 + * Writes are limited to a maximum of of 64 bytes. + */ + virtual void write_i2c (int i2c_addr, const std::string &buf) = 0; + + /*! + * \brief Read from I2C peripheral + * \param i2c_addr I2C bus address (7-bits) + * \param len number of bytes to read + * \return the data read if successful, else a zero length string. + * Reads are limited to a maximum of 64 bytes. + */ + virtual std::string read_i2c (int i2c_addr, size_t len) = 0; + + /*! + * \brief Write data to SPI bus peripheral. + * + * \param dev which spi device + * \param push args for writing + * \param buf the data to write + * + * Writes are limited to a maximum of 64 bytes. + */ + virtual void write_spi (spi_dev_t dev, spi_push_t push, const std::string &buf) = 0; + + /*! + * \brief Read data from SPI bus peripheral. + * + * \param dev which spi device + * \param push args for reading + * \param len number of bytes to read. Must be in [0,64]. + * \return the data read if sucessful, else a zero length string. + * + * Reads are limited to a maximum of 64 bytes. + */ + virtual std::string read_spi (spi_dev_t dev, spi_latch_t latch, size_t len) = 0; +}; + +}}} //namespace + +#endif /* INCLUDED_USRP_UHD_USRP_DBOARD_INTERFACE_H */ diff --git a/lib/Makefile.am b/lib/Makefile.am index efb655640..6146f4025 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -8,14 +8,15 @@ SUBDIRS = usrp quadradio AM_CPPFLAGS = $(GENERAL_CPPFLAGS) -lib_LTLIBRARIES = \ - libusrp_uhd.la +lib_LTLIBRARIES = libusrp_uhd.la libusrp_uhd_la_SOURCES = \ device_addr.cpp \ usrp_uhd.cpp \ wax.cpp -libusrp_uhd_la_LIBADD = $(GENERAL_LDDFLAGS) +libusrp_uhd_la_LIBADD = \ + $(GENERAL_LDDFLAGS) \ + $(USRP_UHD_USRP_DBOARD_LA) noinst_HEADERS = diff --git a/lib/usrp/Makefile.am b/lib/usrp/Makefile.am index 913f80a6d..ac06d5b5b 100644 --- a/lib/usrp/Makefile.am +++ b/lib/usrp/Makefile.am @@ -4,4 +4,4 @@ include $(top_srcdir)/Makefile.common -SUBDIRS = mboard dboard +SUBDIRS = dboard mboard diff --git a/lib/usrp/dboard/Makefile.am b/lib/usrp/dboard/Makefile.am index 66fc4dd71..8d77dcc42 100644 --- a/lib/usrp/dboard/Makefile.am +++ b/lib/usrp/dboard/Makefile.am @@ -5,3 +5,14 @@ include $(top_srcdir)/Makefile.common SUBDIRS = + +AM_CPPFLAGS = $(GENERAL_CPPFLAGS) + +noinst_LTLIBRARIES = lib.la + +lib_la_SOURCES = \ + interface.cpp + +lib_la_LIBADD = $(GENERAL_LDDFLAGS) + +noinst_HEADERS = diff --git a/lib/usrp/dboard/interface.cpp b/lib/usrp/dboard/interface.cpp new file mode 100644 index 000000000..5575568c6 --- /dev/null +++ b/lib/usrp/dboard/interface.cpp @@ -0,0 +1,15 @@ +// +// Copyright 2010 Ettus Research LLC +// + +#include <usrp_uhd/usrp/dboard/interface.hpp> + +using namespace usrp_uhd::usrp::dboard; + +interface::interface(void){ + /* NOP */ +} + +interface::~interface(void){ + /* NOP */ +} diff --git a/test/Makefile.am b/test/Makefile.am index 3373d838c..e5b1bc1e1 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -9,7 +9,7 @@ SUBDIRS = AM_CPPFLAGS = $(GENERAL_CPPFLAGS) LDADD = \ - $(GENERAL_LDDFLAGS) + $(GENERAL_LDDFLAGS) \ $(USRP_UHD_LA) noinst_PROGRAMS = \ |