diff options
author | Lars Amsel <lars.amsel@ni.com> | 2021-06-04 08:27:50 +0200 |
---|---|---|
committer | Aaron Rossetto <aaron.rossetto@ni.com> | 2021-06-10 12:01:53 -0500 |
commit | 2a575bf9b5a4942f60e979161764b9e942699e1e (patch) | |
tree | 2f0535625c30025559ebd7494a4b9e7122550a73 /mpm/lib/i2c | |
parent | e17916220cc955fa219ae37f607626ba88c4afe3 (diff) | |
download | uhd-2a575bf9b5a4942f60e979161764b9e942699e1e.tar.gz uhd-2a575bf9b5a4942f60e979161764b9e942699e1e.tar.bz2 uhd-2a575bf9b5a4942f60e979161764b9e942699e1e.zip |
uhd: Add support for the USRP X410
Co-authored-by: Lars Amsel <lars.amsel@ni.com>
Co-authored-by: Michael Auchter <michael.auchter@ni.com>
Co-authored-by: Martin Braun <martin.braun@ettus.com>
Co-authored-by: Paul Butler <paul.butler@ni.com>
Co-authored-by: Cristina Fuentes <cristina.fuentes-curiel@ni.com>
Co-authored-by: Humberto Jimenez <humberto.jimenez@ni.com>
Co-authored-by: Virendra Kakade <virendra.kakade@ni.com>
Co-authored-by: Lane Kolbly <lane.kolbly@ni.com>
Co-authored-by: Max Köhler <max.koehler@ni.com>
Co-authored-by: Andrew Lynch <andrew.lynch@ni.com>
Co-authored-by: Grant Meyerhoff <grant.meyerhoff@ni.com>
Co-authored-by: Ciro Nishiguchi <ciro.nishiguchi@ni.com>
Co-authored-by: Thomas Vogel <thomas.vogel@ni.com>
Diffstat (limited to 'mpm/lib/i2c')
-rw-r--r-- | mpm/lib/i2c/i2cdev_iface.cpp | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/mpm/lib/i2c/i2cdev_iface.cpp b/mpm/lib/i2c/i2cdev_iface.cpp index 9d2c6b4b2..b723dea06 100644 --- a/mpm/lib/i2c/i2cdev_iface.cpp +++ b/mpm/lib/i2c/i2cdev_iface.cpp @@ -64,23 +64,29 @@ public: return ret; } - int transfer(std::vector<uint8_t>* tx, std::vector<uint8_t>* rx, bool do_close) + std::vector<uint8_t> transfer( + std::vector<uint8_t>& tx, size_t num_rx_bytes, bool do_close) { uint8_t *tx_data = NULL, *rx_data = NULL; size_t tx_len = 0, rx_len = 0; + std::vector<uint8_t> rx(num_rx_bytes); - if (tx) { - tx_data = tx->data(); - tx_len = tx->size(); + if (!tx.empty()) { + tx_data = tx.data(); + tx_len = tx.size(); } - if (rx) { - rx_data = rx->data(); - rx_len = rx->size(); + if (num_rx_bytes) { + rx_data = rx.data(); + rx_len = rx.size(); } - int ret = transfer(tx_data, tx_len, rx_data, rx_len, do_close); - return ret; + const int err = transfer(tx_data, tx_len, rx_data, num_rx_bytes, do_close); + if (err) { + throw mpm::runtime_error("I2C Transaction failed!"); + } + + return rx; } private: |