diff options
author | Josh Blum <josh@joshknows.com> | 2010-03-31 19:25:22 -0700 |
---|---|---|
committer | Josh Blum <josh@joshknows.com> | 2010-03-31 19:25:22 -0700 |
commit | f01b1a394fbf7304aefc0231f500a52db457767a (patch) | |
tree | b7b420e9d30a2393540cd637482a7b365e070061 /host/lib/usrp/usrp2/dboard_interface.cpp | |
parent | f15df8146cffb6cf42e0365396484af085be5df4 (diff) | |
download | uhd-f01b1a394fbf7304aefc0231f500a52db457767a.tar.gz uhd-f01b1a394fbf7304aefc0231f500a52db457767a.tar.bz2 uhd-f01b1a394fbf7304aefc0231f500a52db457767a.zip |
added spi slaves to regs, use std copy for buffs
Diffstat (limited to 'host/lib/usrp/usrp2/dboard_interface.cpp')
-rw-r--r-- | host/lib/usrp/usrp2/dboard_interface.cpp | 25 |
1 files changed, 9 insertions, 16 deletions
diff --git a/host/lib/usrp/usrp2/dboard_interface.cpp b/host/lib/usrp/usrp2/dboard_interface.cpp index 0bf4fa2e6..f5fe68152 100644 --- a/host/lib/usrp/usrp2/dboard_interface.cpp +++ b/host/lib/usrp/usrp2/dboard_interface.cpp @@ -20,6 +20,7 @@ #include <uhd/types/dict.hpp> #include <uhd/utils/assert.hpp> #include <boost/assign/list_of.hpp> +#include <algorithm> #include <cstddef> using namespace uhd::usrp; @@ -144,8 +145,8 @@ void usrp2_dboard_interface::set_atr_reg(gpio_bank_t bank, atr_reg_t reg, boost: */ static boost::uint8_t spi_dev_to_otw(dboard_interface::spi_dev_t dev){ switch(dev){ - case uhd::usrp::dboard_interface::SPI_DEV_TX: return USRP2_DIR_TX; - case uhd::usrp::dboard_interface::SPI_DEV_RX: return USRP2_DIR_RX; + case uhd::usrp::dboard_interface::SPI_DEV_TX: return SPI_SS_TX_DB; + case uhd::usrp::dboard_interface::SPI_DEV_RX: return SPI_SS_RX_DB; } throw std::invalid_argument("unknown spi device type"); } @@ -182,9 +183,7 @@ dboard_interface::byte_vector_t usrp2_dboard_interface::transact_spi( ASSERT_THROW(buf.size() <= sizeof(out_data.data.spi_args.data)); //copy in the data - for (size_t i = 0; i < buf.size(); i++){ - out_data.data.spi_args.data[i] = buf[i]; - } + std::copy(buf.begin(), buf.end(), out_data.data.spi_args.data); //send and recv usrp2_ctrl_data_t in_data = _impl->ctrl_send_and_recv(out_data); @@ -192,10 +191,8 @@ dboard_interface::byte_vector_t usrp2_dboard_interface::transact_spi( ASSERT_THROW(in_data.data.spi_args.bytes == buf.size()); //copy out the data - byte_vector_t result; - for (size_t i = 0; i < buf.size(); i++){ - result.push_back(in_data.data.spi_args.data[i]); - } + byte_vector_t result(buf.size()); + std::copy(in_data.data.spi_args.data, in_data.data.spi_args.data + buf.size(), result.begin()); return result; } @@ -213,9 +210,7 @@ void usrp2_dboard_interface::write_i2c(int i2c_addr, const byte_vector_t &buf){ ASSERT_THROW(buf.size() <= sizeof(out_data.data.i2c_args.data)); //copy in the data - for (size_t i = 0; i < buf.size(); i++){ - out_data.data.i2c_args.data[i] = buf[i]; - } + std::copy(buf.begin(), buf.end(), out_data.data.i2c_args.data); //send and recv usrp2_ctrl_data_t in_data = _impl->ctrl_send_and_recv(out_data); @@ -238,10 +233,8 @@ dboard_interface::byte_vector_t usrp2_dboard_interface::read_i2c(int i2c_addr, s ASSERT_THROW(in_data.data.i2c_args.addr = num_bytes); //copy out the data - byte_vector_t result; - for (size_t i = 0; i < num_bytes; i++){ - result.push_back(in_data.data.i2c_args.data[i]); - } + byte_vector_t result(num_bytes); + std::copy(in_data.data.i2c_args.data, in_data.data.i2c_args.data + num_bytes, result.begin()); return result; } |