summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--firmware/microblaze/apps/txrx.c39
-rw-r--r--host/include/uhd/usrp/dboard/interface.hpp12
-rw-r--r--host/lib/usrp/mboard/usrp2/dboard_interface.cpp43
-rw-r--r--host/lib/usrp/mboard/usrp2/dboard_interface.hpp4
-rw-r--r--host/lib/usrp/mboard/usrp2/fw_common.h12
5 files changed, 106 insertions, 4 deletions
diff --git a/firmware/microblaze/apps/txrx.c b/firmware/microblaze/apps/txrx.c
index 2cf3c46ed..bc8598768 100644
--- a/firmware/microblaze/apps/txrx.c
+++ b/firmware/microblaze/apps/txrx.c
@@ -45,6 +45,8 @@
#include "usrp2/fw_common.h"
#include <db.h>
#include <i2c.h>
+#include <lsdac.h>
+#include <lsadc.h>
#define FW_SETS_SEQNO 1 // define to 0 or 1 (FIXME must be 1 for now)
@@ -347,6 +349,43 @@ void handle_udp_ctrl_packet(
}
break;
+ /*******************************************************************
+ * AUX DAC/ADC
+ ******************************************************************/
+ case USRP2_CTRL_ID_WRITE_THIS_TO_THE_AUX_DAC_BRO:
+ if (ctrl_data_in->data.aux_args.dir == USRP2_DIR_RX){
+ lsdac_write_rx(
+ ctrl_data_in->data.aux_args.which,
+ ctrl_data_in->data.aux_args.value
+ );
+ }
+
+ if (ctrl_data_in->data.aux_args.dir == USRP2_DIR_TX){
+ lsdac_write_tx(
+ ctrl_data_in->data.aux_args.which,
+ ctrl_data_in->data.aux_args.value
+ );
+ }
+
+ ctrl_data_out.id = USRP2_CTRL_ID_DONE_WITH_THAT_AUX_DAC_DUDE;
+ break;
+
+ case USRP2_CTRL_ID_READ_FROM_THIS_AUX_ADC_BRO:
+ if (ctrl_data_in->data.aux_args.dir == USRP2_DIR_RX){
+ ctrl_data_out.data.aux_args.value = lsadc_read_rx(
+ ctrl_data_in->data.aux_args.which
+ );
+ }
+
+ if (ctrl_data_in->data.aux_args.dir == USRP2_DIR_TX){
+ ctrl_data_out.data.aux_args.value = lsadc_read_tx(
+ ctrl_data_in->data.aux_args.which
+ );
+ }
+
+ ctrl_data_out.id = USRP2_CTRL_ID_DONE_WITH_THAT_AUX_ADC_DUDE;
+ break;
+
default:
ctrl_data_out.id = USRP2_CTRL_ID_HUH_WHAT;
diff --git a/host/include/uhd/usrp/dboard/interface.hpp b/host/include/uhd/usrp/dboard/interface.hpp
index 495304338..7c48f4d2b 100644
--- a/host/include/uhd/usrp/dboard/interface.hpp
+++ b/host/include/uhd/usrp/dboard/interface.hpp
@@ -35,6 +35,12 @@ public:
typedef boost::shared_ptr<interface> sptr;
typedef std::vector<uint8_t> byte_vector_t;
+ //tells the host which unit to use
+ enum unit_type_t{
+ UNIT_TYPE_RX,
+ UNIT_TYPE_TX
+ };
+
//tells the host which device to use
enum spi_dev_t{
SPI_TX_DEV,
@@ -65,17 +71,19 @@ public:
/*!
* Write to an aux dac.
+ * \param unit which unit rx or tx
* \param which_dac the dac index 0, 1, 2, 3...
* \param value the value to write
*/
- virtual void write_aux_dac(int which_dac, int value) = 0;
+ virtual void write_aux_dac(unit_type_t unit, int which_dac, int value) = 0;
/*!
* Read from an aux adc.
+ * \param unit which unit rx or tx
* \param which_adc the adc index 0, 1, 2, 3...
* \return the value that was read
*/
- virtual int read_aux_adc(int which_adc) = 0;
+ virtual int read_aux_adc(unit_type_t unit, int which_adc) = 0;
/*!
* Set daughterboard ATR register.
diff --git a/host/lib/usrp/mboard/usrp2/dboard_interface.cpp b/host/lib/usrp/mboard/usrp2/dboard_interface.cpp
index fd51558f2..597654b3c 100644
--- a/host/lib/usrp/mboard/usrp2/dboard_interface.cpp
+++ b/host/lib/usrp/mboard/usrp2/dboard_interface.cpp
@@ -239,3 +239,46 @@ interface::byte_vector_t dboard_interface::read_i2c(int i2c_addr, size_t num_byt
}
return result;
}
+
+/***********************************************************************
+ * Aux DAX/ADC
+ **********************************************************************/
+/*!
+ * Static function to convert a unit type enum
+ * to an over-the-wire value for the usrp2 control.
+ * \param unit the dboard interface unit type enum
+ * \return an over the wire representation
+ */
+static uint8_t spi_dev_to_otw(interface::unit_type_t unit){
+ switch(unit){
+ case uhd::usrp::dboard::interface::UNIT_TYPE_TX: return USRP2_DIR_TX;
+ case uhd::usrp::dboard::interface::UNIT_TYPE_RX: return USRP2_DIR_RX;
+ }
+ throw std::invalid_argument("unknown unit type type");
+}
+
+void dboard_interface::write_aux_dac(interface::unit_type_t unit, int which, int value){
+ //setup the out data
+ usrp2_ctrl_data_t out_data;
+ out_data.id = htonl(USRP2_CTRL_ID_WRITE_THIS_TO_THE_AUX_DAC_BRO);
+ out_data.data.aux_args.dir = spi_dev_to_otw(unit);
+ out_data.data.aux_args.which = which;
+ out_data.data.aux_args.dir = htonl(value);
+
+ //send and recv
+ usrp2_ctrl_data_t in_data = _impl->ctrl_send_and_recv(out_data);
+ ASSERT_THROW(htonl(in_data.id) == USRP2_CTRL_ID_DONE_WITH_THAT_AUX_DAC_DUDE);
+}
+
+int dboard_interface::read_aux_adc(interface::unit_type_t unit, int which){
+ //setup the out data
+ usrp2_ctrl_data_t out_data;
+ out_data.id = htonl(USRP2_CTRL_ID_READ_FROM_THIS_AUX_ADC_BRO);
+ out_data.data.aux_args.dir = spi_dev_to_otw(unit);
+ out_data.data.aux_args.which = which;
+
+ //send and recv
+ usrp2_ctrl_data_t in_data = _impl->ctrl_send_and_recv(out_data);
+ ASSERT_THROW(htonl(in_data.id) == USRP2_CTRL_ID_DONE_WITH_THAT_AUX_ADC_DUDE);
+ return ntohl(in_data.data.aux_args.value);
+}
diff --git a/host/lib/usrp/mboard/usrp2/dboard_interface.hpp b/host/lib/usrp/mboard/usrp2/dboard_interface.hpp
index fb197a87a..0f78dec17 100644
--- a/host/lib/usrp/mboard/usrp2/dboard_interface.hpp
+++ b/host/lib/usrp/mboard/usrp2/dboard_interface.hpp
@@ -27,9 +27,9 @@ public:
~dboard_interface(void);
- void write_aux_dac(int, int){}
+ void write_aux_dac(unit_type_t, int, int);
- int read_aux_adc(int){return 0;}
+ int read_aux_adc(unit_type_t, int);
void set_atr_reg(gpio_bank_t, uint16_t, uint16_t, uint16_t);
diff --git a/host/lib/usrp/mboard/usrp2/fw_common.h b/host/lib/usrp/mboard/usrp2/fw_common.h
index 91cb88c53..ede19d45f 100644
--- a/host/lib/usrp/mboard/usrp2/fw_common.h
+++ b/host/lib/usrp/mboard/usrp2/fw_common.h
@@ -72,6 +72,12 @@ typedef enum{
USRP2_CTRL_ID_WRITE_THESE_I2C_VALUES_BRO,
USRP2_CTRL_ID_COOL_IM_DONE_I2C_WRITE_DUDE,
+ USRP2_CTRL_ID_WRITE_THIS_TO_THE_AUX_DAC_BRO,
+ USRP2_CTRL_ID_DONE_WITH_THAT_AUX_DAC_DUDE,
+
+ USRP2_CTRL_ID_READ_FROM_THIS_AUX_ADC_BRO,
+ USRP2_CTRL_ID_DONE_WITH_THAT_AUX_ADC_DUDE,
+
USRP2_CTRL_ID_PEACE_OUT
} usrp2_ctrl_id_t;
@@ -144,6 +150,12 @@ typedef struct{
uint8_t bytes;
uint8_t data[sizeof(uint32_t)];
} i2c_args;
+ struct {
+ uint8_t dir;
+ uint8_t which;
+ uint8_t _pad[2];
+ uint32_t value;
+ } aux_args;
} data;
} usrp2_ctrl_data_t;