aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/usrp/usrp1/dboard_iface.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'host/lib/usrp/usrp1/dboard_iface.cpp')
-rw-r--r--host/lib/usrp/usrp1/dboard_iface.cpp130
1 files changed, 103 insertions, 27 deletions
diff --git a/host/lib/usrp/usrp1/dboard_iface.cpp b/host/lib/usrp/usrp1/dboard_iface.cpp
index 4c3141d9e..b8d651694 100644
--- a/host/lib/usrp/usrp1/dboard_iface.cpp
+++ b/host/lib/usrp/usrp1/dboard_iface.cpp
@@ -63,6 +63,7 @@
using namespace uhd;
using namespace uhd::usrp;
+using namespace uhd::usrp::gpio_atr;
using namespace boost::assign;
static const dboard_id_t tvrx_id(0x0040);
@@ -106,12 +107,23 @@ public:
void write_aux_dac(unit_t, aux_dac_t, double);
double read_aux_adc(unit_t, aux_adc_t);
+ void set_pin_ctrl(unit_t unit, boost::uint32_t value, boost::uint32_t mask = 0xffffffff);
+ boost::uint32_t get_pin_ctrl(unit_t unit);
+ void set_atr_reg(unit_t unit, atr_reg_t reg, boost::uint32_t value, boost::uint32_t mask = 0xffffffff);
+ boost::uint32_t get_atr_reg(unit_t unit, atr_reg_t reg);
+ void set_gpio_ddr(unit_t unit, boost::uint32_t value, boost::uint32_t mask = 0xffffffff);
+ boost::uint32_t get_gpio_ddr(unit_t unit);
+ void set_gpio_out(unit_t unit, boost::uint32_t value, boost::uint32_t mask = 0xffffffff);
+ boost::uint32_t get_gpio_out(unit_t unit);
+ boost::uint32_t read_gpio(unit_t unit);
+
void _set_pin_ctrl(unit_t, boost::uint16_t);
void _set_atr_reg(unit_t, atr_reg_t, boost::uint16_t);
void _set_gpio_ddr(unit_t, boost::uint16_t);
void _set_gpio_out(unit_t, boost::uint16_t);
- void set_gpio_debug(unit_t, int);
- boost::uint16_t read_gpio(unit_t);
+
+ void set_command_time(const uhd::time_spec_t& t);
+ uhd::time_spec_t get_command_time(void);
void write_i2c(boost::uint16_t, const byte_vector_t &);
byte_vector_t read_i2c(boost::uint16_t, size_t);
@@ -131,6 +143,7 @@ public:
double get_clock_rate(unit_t);
void set_clock_enabled(unit_t, bool);
double get_codec_rate(unit_t);
+ void set_fe_connection(unit_t unit, const fe_connection_t& fe_conn);
private:
usrp1_iface::sptr _iface;
@@ -139,6 +152,8 @@ private:
const usrp1_impl::dboard_slot_t _dboard_slot;
const double &_master_clock_rate;
const dboard_id_t _rx_dboard_id;
+ uhd::dict<unit_t, boost::uint16_t> _pin_ctrl, _gpio_out, _gpio_ddr;
+ uhd::dict<unit_t, uhd::dict<atr_reg_t, boost::uint16_t> > _atr_regs;
};
/***********************************************************************
@@ -217,6 +232,65 @@ double usrp1_dboard_iface::get_codec_rate(unit_t){
/***********************************************************************
* GPIO
**********************************************************************/
+template <typename T>
+static T shadow_it(T &shadow, const T &value, const T &mask){
+ shadow = (shadow & ~mask) | (value & mask);
+ return shadow;
+}
+
+void usrp1_dboard_iface::set_pin_ctrl(unit_t unit, boost::uint32_t value, boost::uint32_t mask){
+ _set_pin_ctrl(unit, shadow_it(_pin_ctrl[unit], static_cast<boost::uint16_t>(value), static_cast<boost::uint16_t>(mask)));
+}
+
+boost::uint32_t usrp1_dboard_iface::get_pin_ctrl(unit_t unit){
+ return _pin_ctrl[unit];
+}
+
+void usrp1_dboard_iface::set_atr_reg(unit_t unit, atr_reg_t reg, boost::uint32_t value, boost::uint32_t mask){
+ _set_atr_reg(unit, reg, shadow_it(_atr_regs[unit][reg], static_cast<boost::uint16_t>(value), static_cast<boost::uint16_t>(mask)));
+}
+
+boost::uint32_t usrp1_dboard_iface::get_atr_reg(unit_t unit, atr_reg_t reg){
+ return _atr_regs[unit][reg];
+}
+
+void usrp1_dboard_iface::set_gpio_ddr(unit_t unit, boost::uint32_t value, boost::uint32_t mask){
+ _set_gpio_ddr(unit, shadow_it(_gpio_ddr[unit], static_cast<boost::uint16_t>(value), static_cast<boost::uint16_t>(mask)));
+}
+
+boost::uint32_t usrp1_dboard_iface::get_gpio_ddr(unit_t unit){
+ return _gpio_ddr[unit];
+}
+
+void usrp1_dboard_iface::set_gpio_out(unit_t unit, boost::uint32_t value, boost::uint32_t mask){
+ _set_gpio_out(unit, shadow_it(_gpio_out[unit], static_cast<boost::uint16_t>(value), static_cast<boost::uint16_t>(mask)));
+}
+
+boost::uint32_t usrp1_dboard_iface::get_gpio_out(unit_t unit){
+ return _gpio_out[unit];
+}
+
+boost::uint32_t usrp1_dboard_iface::read_gpio(unit_t unit)
+{
+ boost::uint32_t out_value;
+
+ if (_dboard_slot == usrp1_impl::DBOARD_SLOT_A)
+ out_value = _iface->peek32(1);
+ else if (_dboard_slot == usrp1_impl::DBOARD_SLOT_B)
+ out_value = _iface->peek32(2);
+ else
+ UHD_THROW_INVALID_CODE_PATH();
+
+ switch(unit) {
+ case UNIT_RX:
+ return (boost::uint32_t)((out_value >> 16) & 0x0000ffff);
+ case UNIT_TX:
+ return (boost::uint32_t)((out_value >> 0) & 0x0000ffff);
+ default: UHD_THROW_INVALID_CODE_PATH();
+ }
+ UHD_ASSERT_THROW(false);
+}
+
void usrp1_dboard_iface::_set_pin_ctrl(unit_t unit, boost::uint16_t value)
{
switch(unit) {
@@ -232,6 +306,7 @@ void usrp1_dboard_iface::_set_pin_ctrl(unit_t unit, boost::uint16_t value)
else if (_dboard_slot == usrp1_impl::DBOARD_SLOT_B)
_iface->poke32(FR_ATR_MASK_2, value);
break;
+ default: UHD_THROW_INVALID_CODE_PATH();
}
}
@@ -250,6 +325,7 @@ void usrp1_dboard_iface::_set_gpio_ddr(unit_t unit, boost::uint16_t value)
else if (_dboard_slot == usrp1_impl::DBOARD_SLOT_B)
_iface->poke32(FR_OE_2, 0xffff0000 | value);
break;
+ default: UHD_THROW_INVALID_CODE_PATH();
}
}
@@ -268,34 +344,10 @@ void usrp1_dboard_iface::_set_gpio_out(unit_t unit, boost::uint16_t value)
else if (_dboard_slot == usrp1_impl::DBOARD_SLOT_B)
_iface->poke32(FR_IO_2, 0xffff0000 | value);
break;
+ default: UHD_THROW_INVALID_CODE_PATH();
}
}
-void usrp1_dboard_iface::set_gpio_debug(unit_t, int)
-{
- /* NOP */
-}
-
-boost::uint16_t usrp1_dboard_iface::read_gpio(unit_t unit)
-{
- boost::uint32_t out_value;
-
- if (_dboard_slot == usrp1_impl::DBOARD_SLOT_A)
- out_value = _iface->peek32(1);
- else if (_dboard_slot == usrp1_impl::DBOARD_SLOT_B)
- out_value = _iface->peek32(2);
- else
- UHD_THROW_INVALID_CODE_PATH();
-
- switch(unit) {
- case UNIT_RX:
- return (boost::uint16_t)((out_value >> 16) & 0x0000ffff);
- case UNIT_TX:
- return (boost::uint16_t)((out_value >> 0) & 0x0000ffff);
- }
- UHD_ASSERT_THROW(false);
-}
-
void usrp1_dboard_iface::_set_atr_reg(unit_t unit,
atr_reg_t atr, boost::uint16_t value)
{
@@ -316,6 +368,7 @@ void usrp1_dboard_iface::_set_atr_reg(unit_t unit,
else if (_dboard_slot == usrp1_impl::DBOARD_SLOT_B)
_iface->poke32(FR_ATR_RXVAL_2, value);
break;
+ default: UHD_THROW_INVALID_CODE_PATH();
}
} else if (atr == ATR_REG_FULL_DUPLEX) {
switch(unit) {
@@ -331,6 +384,7 @@ void usrp1_dboard_iface::_set_atr_reg(unit_t unit,
else if (_dboard_slot == usrp1_impl::DBOARD_SLOT_B)
_iface->poke32(FR_ATR_TXVAL_2, value);
break;
+ default: UHD_THROW_INVALID_CODE_PATH();
}
}
}
@@ -361,6 +415,8 @@ static boost::uint32_t unit_to_otw_spi_dev(dboard_iface::unit_t unit,
return SPI_ENABLE_RX_B;
else
break;
+ default:
+ break;
}
UHD_THROW_INVALID_CODE_PATH();
}
@@ -429,3 +485,23 @@ double usrp1_dboard_iface::read_aux_adc(dboard_iface::unit_t unit,
return _codec->read_aux_adc(unit_to_which_to_aux_adc[unit][which]);
}
+
+/***********************************************************************
+ * Unsupported
+ **********************************************************************/
+
+void usrp1_dboard_iface::set_command_time(const uhd::time_spec_t&)
+{
+ throw uhd::not_implemented_error("timed command support not implemented");
+}
+
+uhd::time_spec_t usrp1_dboard_iface::get_command_time()
+{
+ throw uhd::not_implemented_error("timed command support not implemented");
+}
+
+void usrp1_dboard_iface::set_fe_connection(unit_t, const fe_connection_t&)
+{
+ throw uhd::not_implemented_error("fe connection configuration support not implemented");
+}
+