aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/usrp/mboard/usrp2
diff options
context:
space:
mode:
Diffstat (limited to 'host/lib/usrp/mboard/usrp2')
-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
3 files changed, 57 insertions, 2 deletions
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;