summaryrefslogtreecommitdiffstats
path: root/host/include
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2010-04-26 00:17:08 -0700
committerJosh Blum <josh@joshknows.com>2010-04-26 00:17:08 -0700
commit0c609b96574095affe12d9aaa53bead98faba4f3 (patch)
tree9e10b9d6ddabca60b33898514df5948f8ed02b18 /host/include
parent61ec6711bb4bbae7a8a26cc631eeb88fb3e7d688 (diff)
downloaduhd-0c609b96574095affe12d9aaa53bead98faba4f3.tar.gz
uhd-0c609b96574095affe12d9aaa53bead98faba4f3.tar.bz2
uhd-0c609b96574095affe12d9aaa53bead98faba4f3.zip
Added i2c interface to serial.hpp, using in usrp2_iface for i2c and eeprom.
Diffstat (limited to 'host/include')
-rw-r--r--host/include/uhd/types/serial.hpp61
1 files changed, 61 insertions, 0 deletions
diff --git a/host/include/uhd/types/serial.hpp b/host/include/uhd/types/serial.hpp
index b0fe5d7bd..c134725f5 100644
--- a/host/include/uhd/types/serial.hpp
+++ b/host/include/uhd/types/serial.hpp
@@ -30,6 +30,67 @@ namespace uhd{
typedef std::vector<boost::uint8_t> byte_vector_t;
/*!
+ * The i2c interface class:
+ * Provides i2c and eeprom functionality.
+ * A subclass should only have to implement the i2c routines.
+ * An eeprom implementation comes for free with the interface.
+ *
+ * The eeprom routines are implemented on top of i2c.
+ * The built in eeprom implementation only does single
+ * byte reads and byte writes over the i2c interface,
+ * so it should be portable across multiple eeproms.
+ * Override the eeprom routines if this is not acceptable.
+ */
+ class UHD_API i2c_iface{
+ public:
+ /*!
+ * Write bytes over the i2c.
+ * \param addr the address
+ * \param buf the vector of bytes
+ */
+ virtual void write_i2c(
+ boost::uint8_t addr,
+ const byte_vector_t &buf
+ ) = 0;
+
+ /*!
+ * Read bytes over the i2c.
+ * \param addr the address
+ * \param num_bytes number of bytes to read
+ * \return a vector of bytes
+ */
+ virtual byte_vector_t read_i2c(
+ boost::uint8_t addr,
+ size_t num_bytes
+ ) = 0;
+
+ /*!
+ * Write bytes to an eeprom.
+ * \param addr the address
+ * \param offset byte offset
+ * \param buf the vector of bytes
+ */
+ virtual void write_eeprom(
+ boost::uint8_t addr,
+ boost::uint8_t offset,
+ const byte_vector_t &buf
+ );
+
+ /*!
+ * Read bytes from an eeprom.
+ * \param addr the address
+ * \param offset byte offset
+ * \param num_bytes number of bytes to read
+ * \return a vector of bytes
+ */
+ virtual byte_vector_t read_eeprom(
+ boost::uint8_t addr,
+ boost::uint8_t offset,
+ size_t num_bytes
+ );
+ };
+
+ /*!
* The SPI configuration struct:
* Used to configure a SPI transaction interface.
*/