summaryrefslogtreecommitdiffstats
path: root/host/lib
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2010-03-31 19:25:22 -0700
committerJosh Blum <josh@joshknows.com>2010-03-31 19:25:22 -0700
commitf01b1a394fbf7304aefc0231f500a52db457767a (patch)
treeb7b420e9d30a2393540cd637482a7b365e070061 /host/lib
parentf15df8146cffb6cf42e0365396484af085be5df4 (diff)
downloaduhd-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')
-rw-r--r--host/lib/usrp/usrp2/dboard_interface.cpp25
-rw-r--r--host/lib/usrp/usrp2/usrp2_regs.hpp13
2 files changed, 22 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;
}
diff --git a/host/lib/usrp/usrp2/usrp2_regs.hpp b/host/lib/usrp/usrp2/usrp2_regs.hpp
index 7d868c264..b7fd239a6 100644
--- a/host/lib/usrp/usrp2/usrp2_regs.hpp
+++ b/host/lib/usrp/usrp2/usrp2_regs.hpp
@@ -49,6 +49,19 @@
#define _SR_ADDR(sr) (MISC_OUTPUT_BASE + (sr) * sizeof(uint32_t))
/////////////////////////////////////////////////
+// SPI Slave Constants
+////////////////////////////////////////////////
+// Masks for controlling different peripherals
+#define SPI_SS_AD9510 1
+#define SPI_SS_AD9777 2
+#define SPI_SS_RX_DAC 4
+#define SPI_SS_RX_ADC 8
+#define SPI_SS_RX_DB 16
+#define SPI_SS_TX_DAC 32
+#define SPI_SS_TX_ADC 64
+#define SPI_SS_TX_DB 128
+
+/////////////////////////////////////////////////
// VITA49 64 bit time (write only)
////////////////////////////////////////////////