aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--firmware/microblaze/apps/txrx.c2
-rw-r--r--host/lib/usrp/usrp2/dboard_interface.cpp25
-rw-r--r--host/lib/usrp/usrp2/usrp2_regs.hpp13
3 files changed, 23 insertions, 17 deletions
diff --git a/firmware/microblaze/apps/txrx.c b/firmware/microblaze/apps/txrx.c
index 430ae2fac..39a503091 100644
--- a/firmware/microblaze/apps/txrx.c
+++ b/firmware/microblaze/apps/txrx.c
@@ -264,7 +264,7 @@ void handle_udp_ctrl_packet(
//transact
uint32_t result = spi_transact(
(ctrl_data_in->data.spi_args.readback == 0)? SPI_TXONLY : SPI_TXRX,
- (ctrl_data_in->data.spi_args.dev == USRP2_DIR_RX)? SPI_SS_RX_DB : SPI_SS_TX_DB,
+ ctrl_data_in->data.spi_args.dev,
data, num_bytes*8, //length in bits
(ctrl_data_in->data.spi_args.edge == USRP2_CLK_EDGE_RISE)? SPIF_PUSH_RISE : SPIF_PUSH_FALL |
(ctrl_data_in->data.spi_args.edge == USRP2_CLK_EDGE_RISE)? SPIF_LATCH_RISE : SPIF_LATCH_FALL
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)
////////////////////////////////////////////////