diff options
author | Alex Williams <alex.williams@ni.com> | 2018-10-16 08:23:35 -0700 |
---|---|---|
committer | Brent Stapleton <bstapleton@g.hmc.edu> | 2018-10-19 10:17:08 -0700 |
commit | 5e548c1a08cc559e30507b6dbe5c408a9bf96f51 (patch) | |
tree | ed275e931d82712839aa589d1dada567fbc2dddf /mpm/lib | |
parent | a830fab2a00acd158f14d716e3493ef50afd8aeb (diff) | |
download | uhd-5e548c1a08cc559e30507b6dbe5c408a9bf96f51.tar.gz uhd-5e548c1a08cc559e30507b6dbe5c408a9bf96f51.tar.bz2 uhd-5e548c1a08cc559e30507b6dbe5c408a9bf96f51.zip |
mpm: i2c: Add vector-based transfer function
This could lead to a less-restricted implementation for use in Python.
Diffstat (limited to 'mpm/lib')
-rw-r--r-- | mpm/lib/i2c/i2cdev_iface.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/mpm/lib/i2c/i2cdev_iface.cpp b/mpm/lib/i2c/i2cdev_iface.cpp index 43aeea5e2..d47d0f788 100644 --- a/mpm/lib/i2c/i2cdev_iface.cpp +++ b/mpm/lib/i2c/i2cdev_iface.cpp @@ -72,6 +72,24 @@ public: return ret; } + int transfer(std::vector<uint8_t> *tx, std::vector<uint8_t> *rx) + { + uint8_t *tx_data = NULL, *rx_data = NULL; + size_t tx_len = 0, rx_len = 0; + + if (tx) { + tx_data = tx->data(); + tx_len = tx->size(); + } + + if (rx) { + rx_data = rx->data(); + rx_len = rx->size(); + } + int ret = transfer(tx_data, tx_len, rx_data, rx_len); + return ret; + } + private: int _fd; const uint16_t _addr; |