aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/usrp/usrp1
diff options
context:
space:
mode:
Diffstat (limited to 'host/lib/usrp/usrp1')
-rw-r--r--host/lib/usrp/usrp1/CMakeLists.txt2
-rw-r--r--host/lib/usrp/usrp1/dboard_iface.cpp130
-rw-r--r--host/lib/usrp/usrp1/usrp1_impl.cpp57
-rw-r--r--host/lib/usrp/usrp1/usrp1_impl.hpp1
4 files changed, 131 insertions, 59 deletions
diff --git a/host/lib/usrp/usrp1/CMakeLists.txt b/host/lib/usrp/usrp1/CMakeLists.txt
index 47344e841..6924ba3b0 100644
--- a/host/lib/usrp/usrp1/CMakeLists.txt
+++ b/host/lib/usrp/usrp1/CMakeLists.txt
@@ -22,8 +22,6 @@
########################################################################
# Conditionally configure the USRP1 support
########################################################################
-LIBUHD_REGISTER_COMPONENT("USRP1" ENABLE_USRP1 ON "ENABLE_LIBUHD;ENABLE_USB" OFF OFF)
-
IF(ENABLE_USRP1)
LIBUHD_APPEND_SOURCES(
${CMAKE_CURRENT_SOURCE_DIR}/codec_ctrl.cpp
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");
+}
+
diff --git a/host/lib/usrp/usrp1/usrp1_impl.cpp b/host/lib/usrp/usrp1/usrp1_impl.cpp
index dbd5408e8..5e1a70a8f 100644
--- a/host/lib/usrp/usrp1/usrp1_impl.cpp
+++ b/host/lib/usrp/usrp1/usrp1_impl.cpp
@@ -209,13 +209,13 @@ usrp1_impl::usrp1_impl(const device_addr_t &device_addr){
const fs_path mb_path = "/mboards/0";
_tree->create<std::string>(mb_path / "name").set("USRP1");
_tree->create<std::string>(mb_path / "load_eeprom")
- .subscribe(boost::bind(&fx2_ctrl::usrp_load_eeprom, _fx2_ctrl, _1));
+ .add_coerced_subscriber(boost::bind(&fx2_ctrl::usrp_load_eeprom, _fx2_ctrl, _1));
////////////////////////////////////////////////////////////////////
// create user-defined control objects
////////////////////////////////////////////////////////////////////
_tree->create<std::pair<boost::uint8_t, boost::uint32_t> >(mb_path / "user" / "regs")
- .subscribe(boost::bind(&usrp1_impl::set_reg, this, _1));
+ .add_coerced_subscriber(boost::bind(&usrp1_impl::set_reg, this, _1));
////////////////////////////////////////////////////////////////////
// setup the mboard eeprom
@@ -223,7 +223,7 @@ usrp1_impl::usrp1_impl(const device_addr_t &device_addr){
const mboard_eeprom_t mb_eeprom(*_fx2_ctrl, USRP1_EEPROM_MAP_KEY);
_tree->create<mboard_eeprom_t>(mb_path / "eeprom")
.set(mb_eeprom)
- .subscribe(boost::bind(&usrp1_impl::set_mb_eeprom, this, _1));
+ .add_coerced_subscriber(boost::bind(&usrp1_impl::set_mb_eeprom, this, _1));
////////////////////////////////////////////////////////////////////
// create clock control objects
@@ -247,7 +247,7 @@ usrp1_impl::usrp1_impl(const device_addr_t &device_addr){
}
UHD_MSG(status) << boost::format("Using FPGA clock rate of %fMHz...") % (_master_clock_rate/1e6) << std::endl;
_tree->create<double>(mb_path / "tick_rate")
- .subscribe(boost::bind(&usrp1_impl::update_tick_rate, this, _1))
+ .add_coerced_subscriber(boost::bind(&usrp1_impl::update_tick_rate, this, _1))
.set(_master_clock_rate);
////////////////////////////////////////////////////////////////////
@@ -260,13 +260,13 @@ usrp1_impl::usrp1_impl(const device_addr_t &device_addr){
_tree->create<std::string>(rx_codec_path / "name").set("ad9522");
_tree->create<meta_range_t>(rx_codec_path / "gains/pga/range").set(usrp1_codec_ctrl::rx_pga_gain_range);
_tree->create<double>(rx_codec_path / "gains/pga/value")
- .coerce(boost::bind(&usrp1_impl::update_rx_codec_gain, this, db, _1))
+ .set_coercer(boost::bind(&usrp1_impl::update_rx_codec_gain, this, db, _1))
.set(0.0);
_tree->create<std::string>(tx_codec_path / "name").set("ad9522");
_tree->create<meta_range_t>(tx_codec_path / "gains/pga/range").set(usrp1_codec_ctrl::tx_pga_gain_range);
_tree->create<double>(tx_codec_path / "gains/pga/value")
- .subscribe(boost::bind(&usrp1_codec_ctrl::set_tx_pga_gain, _dbc[db].codec, _1))
- .publish(boost::bind(&usrp1_codec_ctrl::get_tx_pga_gain, _dbc[db].codec))
+ .add_coerced_subscriber(boost::bind(&usrp1_codec_ctrl::set_tx_pga_gain, _dbc[db].codec, _1))
+ .set_publisher(boost::bind(&usrp1_codec_ctrl::get_tx_pga_gain, _dbc[db].codec))
.set(0.0);
}
@@ -281,18 +281,18 @@ usrp1_impl::usrp1_impl(const device_addr_t &device_addr){
////////////////////////////////////////////////////////////////////
_tree->create<subdev_spec_t>(mb_path / "rx_subdev_spec")
.set(subdev_spec_t())
- .subscribe(boost::bind(&usrp1_impl::update_rx_subdev_spec, this, _1));
+ .add_coerced_subscriber(boost::bind(&usrp1_impl::update_rx_subdev_spec, this, _1));
_tree->create<subdev_spec_t>(mb_path / "tx_subdev_spec")
.set(subdev_spec_t())
- .subscribe(boost::bind(&usrp1_impl::update_tx_subdev_spec, this, _1));
+ .add_coerced_subscriber(boost::bind(&usrp1_impl::update_tx_subdev_spec, this, _1));
BOOST_FOREACH(const std::string &db, _dbc.keys()){
const fs_path rx_fe_path = mb_path / "rx_frontends" / db;
_tree->create<std::complex<double> >(rx_fe_path / "dc_offset" / "value")
- .coerce(boost::bind(&usrp1_impl::set_rx_dc_offset, this, db, _1))
+ .set_coercer(boost::bind(&usrp1_impl::set_rx_dc_offset, this, db, _1))
.set(std::complex<double>(0.0, 0.0));
_tree->create<bool>(rx_fe_path / "dc_offset" / "enable")
- .subscribe(boost::bind(&usrp1_impl::set_enb_rx_dc_offset, this, db, _1))
+ .add_coerced_subscriber(boost::bind(&usrp1_impl::set_enb_rx_dc_offset, this, db, _1))
.set(true);
}
@@ -303,19 +303,19 @@ usrp1_impl::usrp1_impl(const device_addr_t &device_addr){
for (size_t dspno = 0; dspno < get_num_ddcs(); dspno++){
fs_path rx_dsp_path = mb_path / str(boost::format("rx_dsps/%u") % dspno);
_tree->create<meta_range_t>(rx_dsp_path / "rate/range")
- .publish(boost::bind(&usrp1_impl::get_rx_dsp_host_rates, this));
+ .set_publisher(boost::bind(&usrp1_impl::get_rx_dsp_host_rates, this));
_tree->create<double>(rx_dsp_path / "rate/value")
.set(1e6) //some default rate
- .coerce(boost::bind(&usrp1_impl::update_rx_samp_rate, this, dspno, _1));
+ .set_coercer(boost::bind(&usrp1_impl::update_rx_samp_rate, this, dspno, _1));
_tree->create<double>(rx_dsp_path / "freq/value")
- .coerce(boost::bind(&usrp1_impl::update_rx_dsp_freq, this, dspno, _1));
+ .set_coercer(boost::bind(&usrp1_impl::update_rx_dsp_freq, this, dspno, _1));
_tree->create<meta_range_t>(rx_dsp_path / "freq/range")
- .publish(boost::bind(&usrp1_impl::get_rx_dsp_freq_range, this));
+ .set_publisher(boost::bind(&usrp1_impl::get_rx_dsp_freq_range, this));
_tree->create<stream_cmd_t>(rx_dsp_path / "stream_cmd");
if (dspno == 0){
- //only subscribe the callback for dspno 0 since it will stream all dsps
+ //only add_coerced_subscriber the callback for dspno 0 since it will stream all dsps
_tree->access<stream_cmd_t>(rx_dsp_path / "stream_cmd")
- .subscribe(boost::bind(&soft_time_ctrl::issue_stream_cmd, _soft_time_ctrl, _1));
+ .add_coerced_subscriber(boost::bind(&soft_time_ctrl::issue_stream_cmd, _soft_time_ctrl, _1));
}
}
@@ -326,22 +326,22 @@ usrp1_impl::usrp1_impl(const device_addr_t &device_addr){
for (size_t dspno = 0; dspno < get_num_ducs(); dspno++){
fs_path tx_dsp_path = mb_path / str(boost::format("tx_dsps/%u") % dspno);
_tree->create<meta_range_t>(tx_dsp_path / "rate/range")
- .publish(boost::bind(&usrp1_impl::get_tx_dsp_host_rates, this));
+ .set_publisher(boost::bind(&usrp1_impl::get_tx_dsp_host_rates, this));
_tree->create<double>(tx_dsp_path / "rate/value")
.set(1e6) //some default rate
- .coerce(boost::bind(&usrp1_impl::update_tx_samp_rate, this, dspno, _1));
+ .set_coercer(boost::bind(&usrp1_impl::update_tx_samp_rate, this, dspno, _1));
_tree->create<double>(tx_dsp_path / "freq/value")
- .coerce(boost::bind(&usrp1_impl::update_tx_dsp_freq, this, dspno, _1));
+ .set_coercer(boost::bind(&usrp1_impl::update_tx_dsp_freq, this, dspno, _1));
_tree->create<meta_range_t>(tx_dsp_path / "freq/range")
- .publish(boost::bind(&usrp1_impl::get_tx_dsp_freq_range, this));
+ .set_publisher(boost::bind(&usrp1_impl::get_tx_dsp_freq_range, this));
}
////////////////////////////////////////////////////////////////////
// create time control objects
////////////////////////////////////////////////////////////////////
_tree->create<time_spec_t>(mb_path / "time/now")
- .publish(boost::bind(&soft_time_ctrl::get_time, _soft_time_ctrl))
- .subscribe(boost::bind(&soft_time_ctrl::set_time, _soft_time_ctrl, _1));
+ .set_publisher(boost::bind(&soft_time_ctrl::get_time, _soft_time_ctrl))
+ .add_coerced_subscriber(boost::bind(&soft_time_ctrl::set_time, _soft_time_ctrl, _1));
_tree->create<std::vector<std::string> >(mb_path / "clock_source/options").set(std::vector<std::string>(1, "internal"));
_tree->create<std::vector<std::string> >(mb_path / "time_source/options").set(std::vector<std::string>(1, "none"));
@@ -365,24 +365,23 @@ usrp1_impl::usrp1_impl(const device_addr_t &device_addr){
//create the properties and register subscribers
_tree->create<dboard_eeprom_t>(mb_path / "dboards" / db/ "rx_eeprom")
.set(rx_db_eeprom)
- .subscribe(boost::bind(&usrp1_impl::set_db_eeprom, this, db, "rx", _1));
+ .add_coerced_subscriber(boost::bind(&usrp1_impl::set_db_eeprom, this, db, "rx", _1));
_tree->create<dboard_eeprom_t>(mb_path / "dboards" / db/ "tx_eeprom")
.set(tx_db_eeprom)
- .subscribe(boost::bind(&usrp1_impl::set_db_eeprom, this, db, "tx", _1));
+ .add_coerced_subscriber(boost::bind(&usrp1_impl::set_db_eeprom, this, db, "tx", _1));
_tree->create<dboard_eeprom_t>(mb_path / "dboards" / db/ "gdb_eeprom")
.set(gdb_eeprom)
- .subscribe(boost::bind(&usrp1_impl::set_db_eeprom, this, db, "gdb", _1));
+ .add_coerced_subscriber(boost::bind(&usrp1_impl::set_db_eeprom, this, db, "gdb", _1));
//create a new dboard interface and manager
- _dbc[db].dboard_iface = make_dboard_iface(
+ dboard_iface::sptr dboard_iface = make_dboard_iface(
_iface, _dbc[db].codec,
(db == "A")? DBOARD_SLOT_A : DBOARD_SLOT_B,
_master_clock_rate, rx_db_eeprom.id
);
- _tree->create<dboard_iface::sptr>(mb_path / "dboards" / db/ "iface").set(_dbc[db].dboard_iface);
_dbc[db].dboard_manager = dboard_manager::make(
rx_db_eeprom.id, tx_db_eeprom.id, gdb_eeprom.id,
- _dbc[db].dboard_iface, _tree->subtree(mb_path / "dboards" / db)
+ dboard_iface, _tree->subtree(mb_path / "dboards" / db)
);
//init the subdev specs if we have a dboard (wont leave this loop empty)
diff --git a/host/lib/usrp/usrp1/usrp1_impl.hpp b/host/lib/usrp/usrp1/usrp1_impl.hpp
index 012bc0794..da901bd6c 100644
--- a/host/lib/usrp/usrp1/usrp1_impl.hpp
+++ b/host/lib/usrp/usrp1/usrp1_impl.hpp
@@ -92,7 +92,6 @@ private:
uhd::transport::usb_zero_copy::sptr _data_transport;
struct db_container_type{
usrp1_codec_ctrl::sptr codec;
- uhd::usrp::dboard_iface::sptr dboard_iface;
uhd::usrp::dboard_manager::sptr dboard_manager;
};
uhd::dict<std::string, db_container_type> _dbc;