aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAshish Chaudhari <ashish@ettus.com>2015-09-30 17:29:08 -0700
committerAshish Chaudhari <ashish@ettus.com>2016-02-16 17:13:11 -0800
commit87d80f55cd5b39de02162bf278dae21fd79a9da9 (patch)
tree90b91e956482565d1a6fb9697c1a335c888aba99
parentb26380043719712ef55694076f66bb9429229ef4 (diff)
downloaduhd-87d80f55cd5b39de02162bf278dae21fd79a9da9.tar.gz
uhd-87d80f55cd5b39de02162bf278dae21fd79a9da9.tar.bz2
uhd-87d80f55cd5b39de02162bf278dae21fd79a9da9.zip
usrp: Refactored dboard_iface for all products
- Made dboard_iface an interface! Removed PIMPL - Added unit "BOTH" to dboard API and expanded GPIO API width to 32 - Removed gpio_debug_mux. No product ever used that - Refactored gpio_atr cores to work with new dboard_iface
-rw-r--r--host/include/uhd/usrp/dboard_iface.hpp58
-rw-r--r--host/lib/usrp/CMakeLists.txt1
-rw-r--r--host/lib/usrp/b100/dboard_iface.cpp58
-rw-r--r--host/lib/usrp/cores/gpio_atr_3000.cpp88
-rw-r--r--host/lib/usrp/cores/gpio_atr_3000.hpp18
-rw-r--r--host/lib/usrp/cores/gpio_core_200.cpp46
-rw-r--r--host/lib/usrp/cores/gpio_core_200.hpp24
-rw-r--r--host/lib/usrp/dboard_iface.cpp93
-rw-r--r--host/lib/usrp/e100/dboard_iface.cpp58
-rw-r--r--host/lib/usrp/usrp1/dboard_iface.cpp123
-rw-r--r--host/lib/usrp/usrp2/dboard_iface.cpp73
-rw-r--r--host/lib/usrp/x300/x300_dboard_iface.cpp93
12 files changed, 431 insertions, 302 deletions
diff --git a/host/include/uhd/usrp/dboard_iface.hpp b/host/include/uhd/usrp/dboard_iface.hpp
index c3a3a4e00..4a80908e0 100644
--- a/host/include/uhd/usrp/dboard_iface.hpp
+++ b/host/include/uhd/usrp/dboard_iface.hpp
@@ -64,8 +64,9 @@ public:
//! tells the host which unit to use
enum unit_t{
- UNIT_RX = int('r'),
- UNIT_TX = int('t')
+ UNIT_RX = int('r'),
+ UNIT_TX = int('t'),
+ UNIT_BOTH = int('b'),
};
//! aux dac selection enums (per unit)
@@ -84,6 +85,8 @@ public:
typedef uhd::usrp::gpio_atr::gpio_atr_reg_t atr_reg_t;
+ virtual ~dboard_iface(void) {};
+
/*!
* Get special properties information for this dboard slot.
* This call helps the dboard code to handle implementation
@@ -118,8 +121,8 @@ public:
* \param mask 16-bits, 0=do not change, 1=change value
*/
virtual void set_pin_ctrl(
- unit_t unit, boost::uint16_t value, boost::uint16_t mask = 0xffff
- );
+ unit_t unit, boost::uint32_t value, boost::uint32_t mask = 0xffff
+ ) = 0;
/*!
* Read back the pin control setting.
@@ -127,7 +130,7 @@ public:
* \param unit which unit rx or tx
* \return the 16-bit settings value
*/
- virtual boost::uint16_t get_pin_ctrl(unit_t unit);
+ virtual boost::uint32_t get_pin_ctrl(unit_t unit) = 0;
/*!
* Set a daughterboard ATR register.
@@ -138,8 +141,8 @@ public:
* \param mask 16-bits, 0=do not change, 1=change value
*/
virtual void set_atr_reg(
- unit_t unit, atr_reg_t reg, boost::uint16_t value, boost::uint16_t mask = 0xffff
- );
+ unit_t unit, atr_reg_t reg, boost::uint32_t value, boost::uint32_t mask = 0xffff
+ ) = 0;
/*!
* Read back an ATR register setting.
@@ -148,7 +151,7 @@ public:
* \param reg which ATR register
* \return the 16-bit settings value
*/
- virtual boost::uint16_t get_atr_reg(unit_t unit, atr_reg_t reg);
+ virtual boost::uint32_t get_atr_reg(unit_t unit, atr_reg_t reg) = 0;
/*!
* Set daughterboard GPIO data direction setting.
@@ -158,8 +161,8 @@ public:
* \param mask 16-bits, 0=do not change, 1=change value
*/
virtual void set_gpio_ddr(
- unit_t unit, boost::uint16_t value, boost::uint16_t mask = 0xffff
- );
+ unit_t unit, boost::uint32_t value, boost::uint32_t mask = 0xffff
+ ) = 0;
/*!
* Read back the GPIO data direction setting.
@@ -167,7 +170,7 @@ public:
* \param unit which unit rx or tx
* \return the 16-bit settings value
*/
- virtual boost::uint16_t get_gpio_ddr(unit_t unit);
+ virtual boost::uint32_t get_gpio_ddr(unit_t unit) = 0;
/*!
* Set daughterboard GPIO pin output setting.
@@ -177,8 +180,8 @@ public:
* \param mask 16-bits, 0=do not change, 1=change value
*/
virtual void set_gpio_out(
- unit_t unit, boost::uint16_t value, boost::uint16_t mask = 0xffff
- );
+ unit_t unit, boost::uint32_t value, boost::uint32_t mask = 0xffff
+ ) = 0;
/*!
* Read back the GPIO pin output setting.
@@ -186,15 +189,7 @@ public:
* \param unit which unit rx or tx
* \return the 16-bit settings value
*/
- virtual boost::uint16_t get_gpio_out(unit_t unit);
-
- /*!
- * Setup the GPIO debug mux.
- *
- * \param unit which unit rx or tx
- * \param which which debug: 0, 1
- */
- virtual void set_gpio_debug(unit_t unit, int which) = 0;
+ virtual boost::uint32_t get_gpio_out(unit_t unit) = 0;
/*!
* Read daughterboard GPIO pin values.
@@ -202,7 +197,7 @@ public:
* \param unit which unit rx or tx
* \return the value of the gpio unit
*/
- virtual boost::uint16_t read_gpio(unit_t unit) = 0;
+ virtual boost::uint32_t read_gpio(unit_t unit) = 0;
/*!
* Write data to SPI bus peripheral.
@@ -280,26 +275,13 @@ public:
* Get the command time.
* \return the command time
*/
- virtual uhd::time_spec_t get_command_time(void);
+ virtual uhd::time_spec_t get_command_time(void) = 0;
/*!
* Set the command time.
* \param t the time
*/
- virtual void set_command_time(const uhd::time_spec_t& t);
-
-private:
- UHD_PIMPL_DECL(impl) _impl;
-
- virtual void _set_pin_ctrl(unit_t unit, boost::uint16_t value) = 0;
- virtual void _set_atr_reg(unit_t unit, atr_reg_t reg, boost::uint16_t value) = 0;
- virtual void _set_gpio_ddr(unit_t unit, boost::uint16_t value) = 0;
- virtual void _set_gpio_out(unit_t unit, boost::uint16_t value) = 0;
-
-protected:
- dboard_iface(void);
-public:
- virtual ~dboard_iface(void);
+ virtual void set_command_time(const uhd::time_spec_t& t) = 0;
};
diff --git a/host/lib/usrp/CMakeLists.txt b/host/lib/usrp/CMakeLists.txt
index 695f7f83d..71e40395e 100644
--- a/host/lib/usrp/CMakeLists.txt
+++ b/host/lib/usrp/CMakeLists.txt
@@ -24,7 +24,6 @@ LIBUHD_APPEND_SOURCES(
${CMAKE_CURRENT_SOURCE_DIR}/dboard_base.cpp
${CMAKE_CURRENT_SOURCE_DIR}/dboard_eeprom.cpp
${CMAKE_CURRENT_SOURCE_DIR}/dboard_id.cpp
- ${CMAKE_CURRENT_SOURCE_DIR}/dboard_iface.cpp
${CMAKE_CURRENT_SOURCE_DIR}/dboard_manager.cpp
${CMAKE_CURRENT_SOURCE_DIR}/gps_ctrl.cpp
${CMAKE_CURRENT_SOURCE_DIR}/mboard_eeprom.cpp
diff --git a/host/lib/usrp/b100/dboard_iface.cpp b/host/lib/usrp/b100/dboard_iface.cpp
index 325efeec1..f8c5c0f26 100644
--- a/host/lib/usrp/b100/dboard_iface.cpp
+++ b/host/lib/usrp/b100/dboard_iface.cpp
@@ -66,12 +66,16 @@ 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, 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_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_command_time(const uhd::time_spec_t& t);
uhd::time_spec_t get_command_time(void);
@@ -127,6 +131,7 @@ void b100_dboard_iface::set_clock_rate(unit_t unit, double rate){
switch(unit){
case UNIT_RX: return _clock->set_rx_dboard_clock_rate(rate);
case UNIT_TX: return _clock->set_tx_dboard_clock_rate(rate);
+ case UNIT_BOTH: set_clock_rate(UNIT_RX, rate); set_clock_rate(UNIT_TX, rate); return;
}
}
@@ -142,14 +147,15 @@ double b100_dboard_iface::get_clock_rate(unit_t unit){
switch(unit){
case UNIT_RX: return _clock->get_rx_clock_rate();
case UNIT_TX: return _clock->get_tx_clock_rate();
+ default: UHD_THROW_INVALID_CODE_PATH();
}
- UHD_THROW_INVALID_CODE_PATH();
}
void b100_dboard_iface::set_clock_enabled(unit_t unit, bool enb){
switch(unit){
case UNIT_RX: return _clock->enable_rx_dboard_clock(enb);
case UNIT_TX: return _clock->enable_tx_dboard_clock(enb);
+ case UNIT_BOTH: set_clock_enabled(UNIT_RX, enb); set_clock_enabled(UNIT_TX, enb); return;
}
}
@@ -160,28 +166,40 @@ double b100_dboard_iface::get_codec_rate(unit_t){
/***********************************************************************
* GPIO
**********************************************************************/
-void b100_dboard_iface::_set_pin_ctrl(unit_t unit, boost::uint16_t value){
- return _gpio->set_pin_ctrl(unit, value);
+void b100_dboard_iface::set_pin_ctrl(unit_t unit, boost::uint32_t value, boost::uint32_t mask){
+ _gpio->set_pin_ctrl(unit, static_cast<boost::uint16_t>(value), static_cast<boost::uint16_t>(mask));
}
-void b100_dboard_iface::_set_gpio_ddr(unit_t unit, boost::uint16_t value){
- return _gpio->set_gpio_ddr(unit, value);
+boost::uint32_t b100_dboard_iface::get_pin_ctrl(unit_t unit){
+ return static_cast<boost::uint32_t>(_gpio->get_pin_ctrl(unit));
}
-void b100_dboard_iface::_set_gpio_out(unit_t unit, boost::uint16_t value){
- return _gpio->set_gpio_out(unit, value);
+void b100_dboard_iface::set_atr_reg(unit_t unit, atr_reg_t reg, boost::uint32_t value, boost::uint32_t mask){
+ _gpio->set_atr_reg(unit, reg, static_cast<boost::uint16_t>(value), static_cast<boost::uint16_t>(mask));
}
-boost::uint16_t b100_dboard_iface::read_gpio(unit_t unit){
- return _gpio->read_gpio(unit);
+boost::uint32_t b100_dboard_iface::get_atr_reg(unit_t unit, atr_reg_t reg){
+ return static_cast<boost::uint32_t>(_gpio->get_atr_reg(unit, reg));
}
-void b100_dboard_iface::_set_atr_reg(unit_t unit, atr_reg_t atr, boost::uint16_t value){
- return _gpio->set_atr_reg(unit, atr, value);
+void b100_dboard_iface::set_gpio_ddr(unit_t unit, boost::uint32_t value, boost::uint32_t mask){
+ _gpio->set_gpio_ddr(unit, static_cast<boost::uint16_t>(value), static_cast<boost::uint16_t>(mask));
}
-void b100_dboard_iface::set_gpio_debug(unit_t, int){
- throw uhd::not_implemented_error("no set_gpio_debug implemented");
+boost::uint32_t b100_dboard_iface::get_gpio_ddr(unit_t unit){
+ return static_cast<boost::uint32_t>(_gpio->get_gpio_ddr(unit));
+}
+
+void b100_dboard_iface::set_gpio_out(unit_t unit, boost::uint32_t value, boost::uint32_t mask){
+ _gpio->set_gpio_out(unit, static_cast<boost::uint16_t>(value), static_cast<boost::uint16_t>(mask));
+}
+
+boost::uint32_t b100_dboard_iface::get_gpio_out(unit_t unit){
+ return static_cast<boost::uint32_t>(_gpio->get_gpio_out(unit));
+}
+
+boost::uint32_t b100_dboard_iface::read_gpio(unit_t unit){
+ return _gpio->read_gpio(unit);
}
/***********************************************************************
@@ -196,8 +214,8 @@ static boost::uint32_t unit_to_otw_spi_dev(dboard_iface::unit_t unit){
switch(unit){
case dboard_iface::UNIT_TX: return B100_SPI_SS_TX_DB;
case dboard_iface::UNIT_RX: return B100_SPI_SS_RX_DB;
+ default: UHD_THROW_INVALID_CODE_PATH();
}
- UHD_THROW_INVALID_CODE_PATH();
}
void b100_dboard_iface::write_spi(
diff --git a/host/lib/usrp/cores/gpio_atr_3000.cpp b/host/lib/usrp/cores/gpio_atr_3000.cpp
index 3e0aa1f03..5844af601 100644
--- a/host/lib/usrp/cores/gpio_atr_3000.cpp
+++ b/host/lib/usrp/cores/gpio_atr_3000.cpp
@@ -164,7 +164,7 @@ public:
}
}
-private:
+protected:
//Special RB addr value to indicate no readback
//This value is invalid as a real address because it is not a multiple of 4
static const wb_iface::wb_addr_type READBACK_DISABLED = 0xFFFFFFFF;
@@ -172,11 +172,16 @@ private:
class masked_reg_t : public uhd::soft_reg32_wo_t {
public:
masked_reg_t(const wb_iface::wb_addr_type offset): uhd::soft_reg32_wo_t(offset) {
- set(REGISTER, 0);
+ uhd::soft_reg32_wo_t::set(REGISTER, 0);
}
virtual void set_with_mask(const boost::uint32_t value, const boost::uint32_t mask) {
- set(REGISTER, (value&mask)|(get(REGISTER)&(~mask)));
+ uhd::soft_reg32_wo_t::set(REGISTER,
+ (value&mask)|(uhd::soft_reg32_wo_t::get(REGISTER)&(~mask)));
+ }
+
+ virtual boost::uint32_t get() {
+ return uhd::soft_reg32_wo_t::get(uhd::soft_reg32_wo_t::REGISTER);
}
virtual void flush() {
@@ -196,14 +201,22 @@ private:
_atr_idle_cache = (value&mask)|(_atr_idle_cache&(~mask));
}
+ virtual boost::uint32_t get() {
+ return _atr_idle_cache;
+ }
+
void set_gpio_out_with_mask(const boost::uint32_t value, const boost::uint32_t mask) {
_gpio_out_cache = (value&mask)|(_gpio_out_cache&(~mask));
}
+ virtual boost::uint32_t get_gpio_out() {
+ return _gpio_out_cache;
+ }
+
virtual void flush() {
set(REGISTER,
- (_atr_idle_cache & (~_atr_disable_reg.get(REGISTER))) |
- (_gpio_out_cache & _atr_disable_reg.get(REGISTER))
+ (_atr_idle_cache & (~_atr_disable_reg.get())) |
+ (_gpio_out_cache & _atr_disable_reg.get())
);
masked_reg_t::flush();
}
@@ -247,44 +260,75 @@ public:
db_gpio_atr_3000_impl(wb_iface::sptr iface, const wb_iface::wb_addr_type base, const wb_iface::wb_addr_type rb_addr):
gpio_atr_3000_impl(iface, base, rb_addr) { /* NOP */ }
- inline void set_pin_ctrl(const db_unit_t unit, const boost::uint16_t value)
+ inline void set_pin_ctrl(const db_unit_t unit, const boost::uint32_t value, const boost::uint32_t mask)
{
- gpio_atr_3000_impl::set_atr_mode(MODE_ATR, compute_mask(unit, value));
- gpio_atr_3000_impl::set_atr_mode(MODE_GPIO, compute_mask(unit, ~value));
+ gpio_atr_3000_impl::set_atr_mode(MODE_ATR, compute_mask(unit, value&mask));
+ gpio_atr_3000_impl::set_atr_mode(MODE_GPIO, compute_mask(unit, (~value)&mask));
}
- inline void set_gpio_ddr(const db_unit_t unit, const boost::uint16_t value)
+ inline boost::uint32_t get_pin_ctrl(const db_unit_t unit)
{
- gpio_atr_3000_impl::set_gpio_ddr(DDR_OUTPUT, compute_mask(unit, value));
- gpio_atr_3000_impl::set_gpio_ddr(DDR_INPUT, compute_mask(unit, ~value));
+ return (~_atr_disable_reg.get()) >> compute_shift(unit);
}
- inline void set_atr_reg(const db_unit_t unit, const gpio_atr_reg_t atr, const boost::uint16_t value)
+ inline void set_gpio_ddr(const db_unit_t unit, const boost::uint32_t value, const boost::uint32_t mask)
{
- gpio_atr_3000_impl::set_atr_reg(atr,
- static_cast<boost::uint32_t>(value) << compute_shift(unit),
- compute_mask(unit, 0xFFFF));
+ gpio_atr_3000_impl::set_gpio_ddr(DDR_OUTPUT, compute_mask(unit, value&mask));
+ gpio_atr_3000_impl::set_gpio_ddr(DDR_INPUT, compute_mask(unit, (~value)&mask));
}
- inline void set_gpio_out(const db_unit_t unit, const boost::uint16_t value)
+ inline boost::uint32_t get_gpio_ddr(const db_unit_t unit)
+ {
+ return _ddr_reg.get() >> compute_shift(unit);
+ }
+
+ inline void set_atr_reg(const db_unit_t unit, const gpio_atr_reg_t atr, const boost::uint32_t value, const boost::uint32_t mask)
+ {
+ gpio_atr_3000_impl::set_atr_reg(atr, value << compute_shift(unit), compute_mask(unit, mask));
+ }
+
+ inline boost::uint32_t get_atr_reg(const db_unit_t unit, const gpio_atr_reg_t atr)
+ {
+ masked_reg_t* reg = NULL;
+ switch (atr) {
+ case ATR_REG_IDLE: reg = &_atr_idle_reg; break;
+ case ATR_REG_RX_ONLY: reg = &_atr_rx_reg; break;
+ case ATR_REG_TX_ONLY: reg = &_atr_tx_reg; break;
+ case ATR_REG_FULL_DUPLEX: reg = &_atr_fdx_reg; break;
+ default: reg = &_atr_idle_reg; break;
+ }
+ return (reg->get() & compute_mask(unit, MASK_SET_ALL)) >> compute_shift(unit);
+ }
+
+ inline void set_gpio_out(const db_unit_t unit, const boost::uint32_t value, const boost::uint32_t mask)
{
gpio_atr_3000_impl::set_gpio_out(
static_cast<boost::uint32_t>(value) << compute_shift(unit),
- compute_mask(unit, 0xFFFF));
+ compute_mask(unit, mask));
}
- inline boost::uint16_t read_gpio(const db_unit_t unit)
+ inline boost::uint32_t get_gpio_out(const db_unit_t unit)
{
- return boost::uint16_t(gpio_atr_3000_impl::read_gpio() >> compute_shift(unit));
+ return (_atr_idle_reg.get_gpio_out() & compute_mask(unit, MASK_SET_ALL)) >> compute_shift(unit);
+ }
+
+ inline boost::uint32_t read_gpio(const db_unit_t unit)
+ {
+ return (gpio_atr_3000_impl::read_gpio() & compute_mask(unit, MASK_SET_ALL)) >> compute_shift(unit);
}
private:
inline boost::uint32_t compute_shift(const db_unit_t unit) {
- return (unit == dboard_iface::UNIT_RX) ? 0 : 16;
+ switch (unit) {
+ case dboard_iface::UNIT_RX: return 0;
+ case dboard_iface::UNIT_TX: return 16;
+ default: return 0;
+ }
}
- inline boost::uint32_t compute_mask(const db_unit_t unit, const boost::uint16_t mask) {
- return static_cast<boost::uint32_t>(mask) << (compute_shift(unit));
+ inline boost::uint32_t compute_mask(const db_unit_t unit, const boost::uint32_t mask) {
+ boost::uint32_t tmp_mask = (unit == dboard_iface::UNIT_BOTH) ? mask : (mask & 0xFFFF);
+ return tmp_mask << (compute_shift(unit));
}
};
diff --git a/host/lib/usrp/cores/gpio_atr_3000.hpp b/host/lib/usrp/cores/gpio_atr_3000.hpp
index b30cd3b85..7b90429fe 100644
--- a/host/lib/usrp/cores/gpio_atr_3000.hpp
+++ b/host/lib/usrp/cores/gpio_atr_3000.hpp
@@ -132,7 +132,9 @@ public:
* \param unit the side of the daughterboard interface to configure (TX or RX)
* \param value if value[i] is 1, the i'th bit is in ATR mode otherwise it is in GPIO mode
*/
- virtual void set_pin_ctrl(const db_unit_t unit, const boost::uint16_t value) = 0;
+ virtual void set_pin_ctrl(const db_unit_t unit, const boost::uint32_t value, const boost::uint32_t mask) = 0;
+
+ virtual boost::uint32_t get_pin_ctrl(const db_unit_t unit) = 0;
/*!
* Configure the direction for all pins in the daughterboard connector
@@ -140,7 +142,9 @@ public:
* \param unit the side of the daughterboard interface to configure (TX or RX)
* \param value if value[i] is 1, the i'th bit is an output otherwise it is an input
*/
- virtual void set_gpio_ddr(const db_unit_t unit, const boost::uint16_t value) = 0;
+ virtual void set_gpio_ddr(const db_unit_t unit, const boost::uint32_t value, const boost::uint32_t mask) = 0;
+
+ virtual boost::uint32_t get_gpio_ddr(const db_unit_t unit) = 0;
/*!
* Write the specified value to the ATR register (all bits)
@@ -149,7 +153,9 @@ public:
* \param unit the side of the daughterboard interface to configure (TX or RX)
* \param value the value to write
*/
- virtual void set_atr_reg(const db_unit_t unit, const gpio_atr_reg_t atr, const boost::uint16_t value) = 0;
+ virtual void set_atr_reg(const db_unit_t unit, const gpio_atr_reg_t atr, const boost::uint32_t value, const boost::uint32_t mask) = 0;
+
+ virtual boost::uint32_t get_atr_reg(const db_unit_t unit, const gpio_atr_reg_t atr) = 0;
/*!
* Write the specified value to the GPIO register (all bits)
@@ -157,7 +163,9 @@ public:
* \param atr the type of ATR register to write to {IDLE, RX, TX, FDX}
* \param value the value to write
*/
- virtual void set_gpio_out(const db_unit_t unit, const boost::uint16_t value) = 0;
+ virtual void set_gpio_out(const db_unit_t unit, const boost::uint32_t value, const boost::uint32_t mask) = 0;
+
+ virtual boost::uint32_t get_gpio_out(const db_unit_t unit) = 0;
/*!
* Read the state of the GPIO pins
@@ -167,7 +175,7 @@ public:
* \param unit the side of the daughterboard interface to configure (TX or RX)
* \return the value read back
*/
- virtual boost::uint16_t read_gpio(const db_unit_t unit) = 0;
+ virtual boost::uint32_t read_gpio(const db_unit_t unit) = 0;
};
}}} //namespaces
diff --git a/host/lib/usrp/cores/gpio_core_200.cpp b/host/lib/usrp/cores/gpio_core_200.cpp
index 05a689845..8e00a881f 100644
--- a/host/lib/usrp/cores/gpio_core_200.cpp
+++ b/host/lib/usrp/cores/gpio_core_200.cpp
@@ -27,6 +27,11 @@
using namespace uhd;
using namespace usrp;
+template <typename T>
+static void shadow_it(T &shadow, const T &value, const T &mask){
+ shadow = (shadow & ~mask) | (value & mask);
+}
+
gpio_core_200::~gpio_core_200(void){
/* NOP */
}
@@ -36,30 +41,55 @@ public:
gpio_core_200_impl(wb_iface::sptr iface, const size_t base, const size_t rb_addr):
_iface(iface), _base(base), _rb_addr(rb_addr) { /* NOP */ }
- void set_pin_ctrl(const unit_t unit, const boost::uint16_t value){
- _pin_ctrl[unit] = value; //shadow
+ void set_pin_ctrl(const unit_t unit, const boost::uint16_t value, const boost::uint16_t mask){
+ if (unit == dboard_iface::UNIT_BOTH) throw uhd::runtime_error("UNIT_BOTH not supported in gpio_core_200");
+ shadow_it(_pin_ctrl[unit], value, mask);
this->update(); //full update
}
- void set_atr_reg(const unit_t unit, const atr_reg_t atr, const boost::uint16_t value){
- _atr_regs[unit][atr] = value; //shadow
+ boost::uint16_t get_pin_ctrl(unit_t unit){
+ if (unit == dboard_iface::UNIT_BOTH) throw uhd::runtime_error("UNIT_BOTH not supported in gpio_core_200");
+ return _pin_ctrl[unit];
+ }
+
+ void set_atr_reg(const unit_t unit, const atr_reg_t atr, const boost::uint16_t value, const boost::uint16_t mask){
+ if (unit == dboard_iface::UNIT_BOTH) throw uhd::runtime_error("UNIT_BOTH not supported in gpio_core_200");
+ shadow_it(_atr_regs[unit][atr], value, mask);
this->update(); //full update
}
- void set_gpio_ddr(const unit_t unit, const boost::uint16_t value){
- _gpio_ddr[unit] = value; //shadow
+ boost::uint16_t get_atr_reg(unit_t unit, atr_reg_t reg){
+ if (unit == dboard_iface::UNIT_BOTH) throw uhd::runtime_error("UNIT_BOTH not supported in gpio_core_200");
+ return _atr_regs[unit][reg];
+ }
+
+ void set_gpio_ddr(const unit_t unit, const boost::uint16_t value, const boost::uint16_t mask){
+ if (unit == dboard_iface::UNIT_BOTH) throw uhd::runtime_error("UNIT_BOTH not supported in gpio_core_200");
+ shadow_it(_gpio_ddr[unit], value, mask);
_iface->poke32(REG_GPIO_DDR, //update the 32 bit register
(boost::uint32_t(_gpio_ddr[dboard_iface::UNIT_RX]) << shift_by_unit(dboard_iface::UNIT_RX)) |
(boost::uint32_t(_gpio_ddr[dboard_iface::UNIT_TX]) << shift_by_unit(dboard_iface::UNIT_TX))
);
}
- void set_gpio_out(const unit_t unit, const boost::uint16_t value){
- _gpio_out[unit] = value; //shadow
+ boost::uint16_t get_gpio_ddr(unit_t unit){
+ if (unit == dboard_iface::UNIT_BOTH) throw uhd::runtime_error("UNIT_BOTH not supported in gpio_core_200");
+ return _gpio_ddr[unit];
+ }
+
+ void set_gpio_out(const unit_t unit, const boost::uint16_t value, const boost::uint16_t mask){
+ if (unit == dboard_iface::UNIT_BOTH) throw uhd::runtime_error("UNIT_BOTH not supported in gpio_core_200");
+ shadow_it(_gpio_out[unit], value, mask);
this->update(); //full update
}
+ boost::uint16_t get_gpio_out(unit_t unit){
+ if (unit == dboard_iface::UNIT_BOTH) throw uhd::runtime_error("UNIT_BOTH not supported in gpio_core_200");
+ return _gpio_out[unit];
+ }
+
boost::uint16_t read_gpio(const unit_t unit){
+ if (unit == dboard_iface::UNIT_BOTH) throw uhd::runtime_error("UNIT_BOTH not supported in gpio_core_200");
return boost::uint16_t(_iface->peek32(_rb_addr) >> shift_by_unit(unit));
}
diff --git a/host/lib/usrp/cores/gpio_core_200.hpp b/host/lib/usrp/cores/gpio_core_200.hpp
index c60507792..67aa8bde8 100644
--- a/host/lib/usrp/cores/gpio_core_200.hpp
+++ b/host/lib/usrp/cores/gpio_core_200.hpp
@@ -38,20 +38,32 @@ public:
virtual ~gpio_core_200(void) = 0;
//! makes a new GPIO core from iface and slave base
- static sptr make(uhd::wb_iface::sptr iface, const size_t base, const size_t rb_addr);
+ static sptr make(
+ uhd::wb_iface::sptr iface, const size_t base, const size_t rb_addr);
//! 1 = ATR
- virtual void set_pin_ctrl(const unit_t unit, const boost::uint16_t value) = 0;
+ virtual void set_pin_ctrl(
+ const unit_t unit, const boost::uint16_t value, const boost::uint16_t mask) = 0;
- virtual void set_atr_reg(const unit_t unit, const atr_reg_t atr, const boost::uint16_t value) = 0;
+ virtual boost::uint16_t get_pin_ctrl(unit_t unit) = 0;
+
+ virtual void set_atr_reg(
+ const unit_t unit, const atr_reg_t atr, const boost::uint16_t value, const boost::uint16_t mask) = 0;
+
+ virtual boost::uint16_t get_atr_reg(unit_t unit, atr_reg_t reg) = 0;
//! 1 = OUTPUT
- virtual void set_gpio_ddr(const unit_t unit, const boost::uint16_t value) = 0;
+ virtual void set_gpio_ddr(
+ const unit_t unit, const boost::uint16_t value, const boost::uint16_t mask) = 0;
- virtual void set_gpio_out(const unit_t unit, const boost::uint16_t value) = 0;
+ virtual boost::uint16_t get_gpio_ddr(unit_t unit) = 0;
- virtual boost::uint16_t read_gpio(const unit_t unit) = 0;
+ virtual void set_gpio_out(
+ const unit_t unit, const boost::uint16_t value, const boost::uint16_t mask) = 0;
+ virtual boost::uint16_t get_gpio_out(unit_t unit) = 0;
+
+ virtual boost::uint16_t read_gpio(const unit_t unit) = 0;
};
//! Simple wrapper for 32 bit write only
diff --git a/host/lib/usrp/dboard_iface.cpp b/host/lib/usrp/dboard_iface.cpp
deleted file mode 100644
index 092e005f0..000000000
--- a/host/lib/usrp/dboard_iface.cpp
+++ /dev/null
@@ -1,93 +0,0 @@
-//
-// Copyright 2010-2013,2015 Ettus Research LLC
-//
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program. If not, see <http://www.gnu.org/licenses/>.
-//
-
-#include <uhd/usrp/dboard_iface.hpp>
-#include <uhd/types/dict.hpp>
-
-using namespace uhd::usrp;
-
-struct dboard_iface::impl{
- uhd::dict<unit_t, boost::uint16_t> pin_ctrl_shadow;
- uhd::dict<unit_t, uhd::dict<atr_reg_t, boost::uint16_t> > atr_reg_shadow;
- uhd::dict<unit_t, boost::uint16_t> gpio_ddr_shadow;
- uhd::dict<unit_t, boost::uint16_t> gpio_out_shadow;
-};
-
-dboard_iface::dboard_iface(void){
- _impl = UHD_PIMPL_MAKE(impl, ());
-}
-
-dboard_iface::~dboard_iface(void)
-{
- //empty
-}
-
-template <typename T>
-static T shadow_it(T &shadow, const T &value, const T &mask){
- shadow = (shadow & ~mask) | (value & mask);
- return shadow;
-}
-
-void dboard_iface::set_pin_ctrl(
- unit_t unit, boost::uint16_t value, boost::uint16_t mask
-){
- _set_pin_ctrl(unit, shadow_it(_impl->pin_ctrl_shadow[unit], value, mask));
-}
-
-boost::uint16_t dboard_iface::get_pin_ctrl(unit_t unit){
- return _impl->pin_ctrl_shadow[unit];
-}
-
-void dboard_iface::set_atr_reg(
- unit_t unit, atr_reg_t reg, boost::uint16_t value, boost::uint16_t mask
-){
- _set_atr_reg(unit, reg, shadow_it(_impl->atr_reg_shadow[unit][reg], value, mask));
-}
-
-boost::uint16_t dboard_iface::get_atr_reg(unit_t unit, atr_reg_t reg){
- return _impl->atr_reg_shadow[unit][reg];
-}
-
-void dboard_iface::set_gpio_ddr(
- unit_t unit, boost::uint16_t value, boost::uint16_t mask
-){
- _set_gpio_ddr(unit, shadow_it(_impl->gpio_ddr_shadow[unit], value, mask));
-}
-
-boost::uint16_t dboard_iface::get_gpio_ddr(unit_t unit){
- return _impl->gpio_ddr_shadow[unit];
-}
-
-void dboard_iface::set_gpio_out(
- unit_t unit, boost::uint16_t value, boost::uint16_t mask
-){
- _set_gpio_out(unit, shadow_it(_impl->gpio_out_shadow[unit], value, mask));
-}
-
-boost::uint16_t dboard_iface::get_gpio_out(unit_t unit){
- return _impl->gpio_out_shadow[unit];
-}
-
-void dboard_iface::set_command_time(const uhd::time_spec_t&)
-{
- throw uhd::not_implemented_error("timed command feature not implemented on this hardware");
-}
-
-uhd::time_spec_t dboard_iface::get_command_time()
-{
- return uhd::time_spec_t(0.0);
-}
diff --git a/host/lib/usrp/e100/dboard_iface.cpp b/host/lib/usrp/e100/dboard_iface.cpp
index b5baf6c56..f1d41a034 100644
--- a/host/lib/usrp/e100/dboard_iface.cpp
+++ b/host/lib/usrp/e100/dboard_iface.cpp
@@ -66,12 +66,16 @@ 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, 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_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_command_time(const uhd::time_spec_t& t);
uhd::time_spec_t get_command_time(void);
@@ -127,6 +131,7 @@ void e100_dboard_iface::set_clock_rate(unit_t unit, double rate){
switch(unit){
case UNIT_RX: return _clock->set_rx_dboard_clock_rate(rate);
case UNIT_TX: return _clock->set_tx_dboard_clock_rate(rate);
+ case UNIT_BOTH: set_clock_rate(UNIT_RX, rate); set_clock_rate(UNIT_TX, rate); return;
}
}
@@ -142,14 +147,15 @@ double e100_dboard_iface::get_clock_rate(unit_t unit){
switch(unit){
case UNIT_RX: return _clock->get_rx_clock_rate();
case UNIT_TX: return _clock->get_tx_clock_rate();
+ default: UHD_THROW_INVALID_CODE_PATH();
}
- UHD_THROW_INVALID_CODE_PATH();
}
void e100_dboard_iface::set_clock_enabled(unit_t unit, bool enb){
switch(unit){
case UNIT_RX: return _clock->enable_rx_dboard_clock(enb);
case UNIT_TX: return _clock->enable_tx_dboard_clock(enb);
+ case UNIT_BOTH: set_clock_enabled(UNIT_RX, enb); set_clock_enabled(UNIT_TX, enb); return;
}
}
@@ -160,28 +166,40 @@ double e100_dboard_iface::get_codec_rate(unit_t){
/***********************************************************************
* GPIO
**********************************************************************/
-void e100_dboard_iface::_set_pin_ctrl(unit_t unit, boost::uint16_t value){
- return _gpio->set_pin_ctrl(unit, value);
+void e100_dboard_iface::set_pin_ctrl(unit_t unit, boost::uint32_t value, boost::uint32_t mask){
+ _gpio->set_pin_ctrl(unit, static_cast<boost::uint16_t>(value), static_cast<boost::uint16_t>(mask));
}
-void e100_dboard_iface::_set_gpio_ddr(unit_t unit, boost::uint16_t value){
- return _gpio->set_gpio_ddr(unit, value);
+boost::uint32_t e100_dboard_iface::get_pin_ctrl(unit_t unit){
+ return static_cast<boost::uint32_t>(_gpio->get_pin_ctrl(unit));
}
-void e100_dboard_iface::_set_gpio_out(unit_t unit, boost::uint16_t value){
- return _gpio->set_gpio_out(unit, value);
+void e100_dboard_iface::set_atr_reg(unit_t unit, atr_reg_t reg, boost::uint32_t value, boost::uint32_t mask){
+ _gpio->set_atr_reg(unit, reg, static_cast<boost::uint16_t>(value), static_cast<boost::uint16_t>(mask));
}
-boost::uint16_t e100_dboard_iface::read_gpio(unit_t unit){
- return _gpio->read_gpio(unit);
+boost::uint32_t e100_dboard_iface::get_atr_reg(unit_t unit, atr_reg_t reg){
+ return static_cast<boost::uint32_t>(_gpio->get_atr_reg(unit, reg));
}
-void e100_dboard_iface::_set_atr_reg(unit_t unit, atr_reg_t atr, boost::uint16_t value){
- return _gpio->set_atr_reg(unit, atr, value);
+void e100_dboard_iface::set_gpio_ddr(unit_t unit, boost::uint32_t value, boost::uint32_t mask){
+ _gpio->set_gpio_ddr(unit, static_cast<boost::uint16_t>(value), static_cast<boost::uint16_t>(mask));
}
-void e100_dboard_iface::set_gpio_debug(unit_t, int){
- throw uhd::not_implemented_error("no set_gpio_debug implemented");
+boost::uint32_t e100_dboard_iface::get_gpio_ddr(unit_t unit){
+ return static_cast<boost::uint32_t>(_gpio->get_gpio_ddr(unit));
+}
+
+void e100_dboard_iface::set_gpio_out(unit_t unit, boost::uint32_t value, boost::uint32_t mask){
+ _gpio->set_gpio_out(unit, static_cast<boost::uint16_t>(value), static_cast<boost::uint16_t>(mask));
+}
+
+boost::uint32_t e100_dboard_iface::get_gpio_out(unit_t unit){
+ return static_cast<boost::uint32_t>(_gpio->get_gpio_out(unit));
+}
+
+boost::uint32_t e100_dboard_iface::read_gpio(unit_t unit){
+ return _gpio->read_gpio(unit);
}
/***********************************************************************
@@ -196,8 +214,8 @@ static boost::uint32_t unit_to_otw_spi_dev(dboard_iface::unit_t unit){
switch(unit){
case dboard_iface::UNIT_TX: return UE_SPI_SS_TX_DB;
case dboard_iface::UNIT_RX: return UE_SPI_SS_RX_DB;
+ default: UHD_THROW_INVALID_CODE_PATH();
}
- UHD_THROW_INVALID_CODE_PATH();
}
void e100_dboard_iface::write_spi(
diff --git a/host/lib/usrp/usrp1/dboard_iface.cpp b/host/lib/usrp/usrp1/dboard_iface.cpp
index 502d0fbe3..cf6d97eb1 100644
--- a/host/lib/usrp/usrp1/dboard_iface.cpp
+++ b/host/lib/usrp/usrp1/dboard_iface.cpp
@@ -107,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);
@@ -140,6 +151,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;
};
/***********************************************************************
@@ -218,6 +231,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) {
@@ -233,6 +305,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();
}
}
@@ -251,6 +324,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();
}
}
@@ -269,34 +343,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)
{
@@ -317,6 +367,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) {
@@ -332,6 +383,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();
}
}
}
@@ -362,6 +414,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();
}
@@ -430,3 +484,18 @@ 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");
+}
+
diff --git a/host/lib/usrp/usrp2/dboard_iface.cpp b/host/lib/usrp/usrp2/dboard_iface.cpp
index 7bb69c7b7..0a45b4e48 100644
--- a/host/lib/usrp/usrp2/dboard_iface.cpp
+++ b/host/lib/usrp/usrp2/dboard_iface.cpp
@@ -54,12 +54,16 @@ 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, 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_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_command_time(const uhd::time_spec_t& t);
uhd::time_spec_t get_command_time(void);
@@ -149,18 +153,22 @@ usrp2_dboard_iface::~usrp2_dboard_iface(void){
* Clocks
**********************************************************************/
void usrp2_dboard_iface::set_clock_rate(unit_t unit, double rate){
+ if (unit == UNIT_BOTH) throw uhd::runtime_error("UNIT_BOTH not supported.");
_clock_rates[unit] = rate; //set to shadow
switch(unit){
case UNIT_RX: _clock_ctrl->set_rate_rx_dboard_clock(rate); return;
case UNIT_TX: _clock_ctrl->set_rate_tx_dboard_clock(rate); return;
+ default: UHD_THROW_INVALID_CODE_PATH();
}
}
double usrp2_dboard_iface::get_clock_rate(unit_t unit){
+ if (unit == UNIT_BOTH) throw uhd::runtime_error("UNIT_BOTH not supported.");
return _clock_rates[unit]; //get from shadow
}
std::vector<double> usrp2_dboard_iface::get_clock_rates(unit_t unit){
+ if (unit == UNIT_BOTH) throw uhd::runtime_error("UNIT_BOTH not supported.");
switch(unit){
case UNIT_RX: return _clock_ctrl->get_rates_rx_dboard_clock();
case UNIT_TX: return _clock_ctrl->get_rates_tx_dboard_clock();
@@ -169,40 +177,56 @@ std::vector<double> usrp2_dboard_iface::get_clock_rates(unit_t unit){
}
void usrp2_dboard_iface::set_clock_enabled(unit_t unit, bool enb){
+ if (unit == UNIT_BOTH) throw uhd::runtime_error("UNIT_BOTH not supported.");
switch(unit){
- case UNIT_RX: _clock_ctrl->enable_rx_dboard_clock(enb); return;
- case UNIT_TX: _clock_ctrl->enable_tx_dboard_clock(enb); return;
+ case UNIT_RX: _clock_ctrl->enable_rx_dboard_clock(enb); return;
+ case UNIT_TX: _clock_ctrl->enable_tx_dboard_clock(enb); return;
+ case UNIT_BOTH: set_clock_enabled(UNIT_RX, enb); set_clock_enabled(UNIT_TX, enb); return;
}
}
-double usrp2_dboard_iface::get_codec_rate(unit_t){
+double usrp2_dboard_iface::get_codec_rate(unit_t unit){
+ if (unit == UNIT_BOTH) throw uhd::runtime_error("UNIT_BOTH not supported.");
return _clock_ctrl->get_master_clock_rate();
}
+
/***********************************************************************
* GPIO
**********************************************************************/
-void usrp2_dboard_iface::_set_pin_ctrl(unit_t unit, boost::uint16_t value){
- return _gpio->set_pin_ctrl(unit, value);
+void usrp2_dboard_iface::set_pin_ctrl(unit_t unit, boost::uint32_t value, boost::uint32_t mask){
+ _gpio->set_pin_ctrl(unit, static_cast<boost::uint16_t>(value), static_cast<boost::uint16_t>(mask));
}
-void usrp2_dboard_iface::_set_gpio_ddr(unit_t unit, boost::uint16_t value){
- return _gpio->set_gpio_ddr(unit, value);
+boost::uint32_t usrp2_dboard_iface::get_pin_ctrl(unit_t unit){
+ return static_cast<boost::uint32_t>(_gpio->get_pin_ctrl(unit));
}
-void usrp2_dboard_iface::_set_gpio_out(unit_t unit, boost::uint16_t value){
- return _gpio->set_gpio_out(unit, value);
+void usrp2_dboard_iface::set_atr_reg(unit_t unit, atr_reg_t reg, boost::uint32_t value, boost::uint32_t mask){
+ _gpio->set_atr_reg(unit, reg, static_cast<boost::uint16_t>(value), static_cast<boost::uint16_t>(mask));
}
-boost::uint16_t usrp2_dboard_iface::read_gpio(unit_t unit){
- return _gpio->read_gpio(unit);
+boost::uint32_t usrp2_dboard_iface::get_atr_reg(unit_t unit, atr_reg_t reg){
+ return static_cast<boost::uint32_t>(_gpio->get_atr_reg(unit, reg));
}
-void usrp2_dboard_iface::_set_atr_reg(unit_t unit, atr_reg_t atr, boost::uint16_t value){
- return _gpio->set_atr_reg(unit, atr, value);
+void usrp2_dboard_iface::set_gpio_ddr(unit_t unit, boost::uint32_t value, boost::uint32_t mask){
+ _gpio->set_gpio_ddr(unit, static_cast<boost::uint16_t>(value), static_cast<boost::uint16_t>(mask));
}
-void usrp2_dboard_iface::set_gpio_debug(unit_t, int){
- throw uhd::not_implemented_error("no set_gpio_debug implemented");
+boost::uint32_t usrp2_dboard_iface::get_gpio_ddr(unit_t unit){
+ return static_cast<boost::uint32_t>(_gpio->get_gpio_ddr(unit));
+}
+
+void usrp2_dboard_iface::set_gpio_out(unit_t unit, boost::uint32_t value, boost::uint32_t mask){
+ _gpio->set_gpio_out(unit, static_cast<boost::uint16_t>(value), static_cast<boost::uint16_t>(mask));
+}
+
+boost::uint32_t usrp2_dboard_iface::get_gpio_out(unit_t unit){
+ return static_cast<boost::uint32_t>(_gpio->get_gpio_out(unit));
+}
+
+boost::uint32_t usrp2_dboard_iface::read_gpio(unit_t unit){
+ return _gpio->read_gpio(unit);
}
/***********************************************************************
@@ -219,6 +243,7 @@ void usrp2_dboard_iface::write_spi(
boost::uint32_t data,
size_t num_bits
){
+ if (unit == UNIT_BOTH) throw uhd::runtime_error("UNIT_BOTH not supported.");
_spi_iface->write_spi(unit_to_spi_dev[unit], config, data, num_bits);
}
@@ -228,6 +253,7 @@ boost::uint32_t usrp2_dboard_iface::read_write_spi(
boost::uint32_t data,
size_t num_bits
){
+ if (unit == UNIT_BOTH) throw uhd::runtime_error("UNIT_BOTH not supported.");
return _spi_iface->read_spi(unit_to_spi_dev[unit], config, data, num_bits);
}
@@ -250,6 +276,7 @@ void usrp2_dboard_iface::_write_aux_dac(unit_t unit){
(UNIT_RX, SPI_SS_RX_DAC)
(UNIT_TX, SPI_SS_TX_DAC)
;
+ if (unit == UNIT_BOTH) throw uhd::runtime_error("UNIT_BOTH not supported.");
_spi_iface->write_spi(
unit_to_spi_dac[unit], spi_config_t::EDGE_FALL,
_dac_regs[unit].get_reg(), 24
@@ -257,6 +284,8 @@ void usrp2_dboard_iface::_write_aux_dac(unit_t unit){
}
void usrp2_dboard_iface::write_aux_dac(unit_t unit, aux_dac_t which, double value){
+ if (unit == UNIT_BOTH) throw uhd::runtime_error("UNIT_BOTH not supported.");
+
_dac_regs[unit].data = boost::math::iround(4095*value/3.3);
_dac_regs[unit].cmd = ad5623_regs_t::CMD_WR_UP_DAC_CHAN_N;
@@ -285,6 +314,8 @@ double usrp2_dboard_iface::read_aux_adc(unit_t unit, aux_adc_t which){
(UNIT_TX, SPI_SS_TX_ADC)
;
+ if (unit == UNIT_BOTH) throw uhd::runtime_error("UNIT_BOTH not supported.");
+
//setup spi config args
spi_config_t config;
config.mosi_edge = spi_config_t::EDGE_FALL;
diff --git a/host/lib/usrp/x300/x300_dboard_iface.cpp b/host/lib/usrp/x300/x300_dboard_iface.cpp
index 502630109..981976867 100644
--- a/host/lib/usrp/x300/x300_dboard_iface.cpp
+++ b/host/lib/usrp/x300/x300_dboard_iface.cpp
@@ -45,17 +45,19 @@ 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, 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_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_command_time(const uhd::time_spec_t& t);
uhd::time_spec_t get_command_time(void);
- void set_gpio_debug(unit_t, int);
- boost::uint16_t read_gpio(unit_t);
-
void write_i2c(boost::uint16_t, const byte_vector_t &);
byte_vector_t read_i2c(boost::uint16_t, size_t);
@@ -116,27 +118,6 @@ x300_dboard_iface::x300_dboard_iface(const x300_dboard_iface_config_t &config):
this->set_clock_enabled(UNIT_RX, false);
this->set_clock_enabled(UNIT_TX, false);
-
-
- //some test code
- /*
- {
-
- this->write_aux_dac(UNIT_TX, AUX_DAC_A, .1);
- this->write_aux_dac(UNIT_TX, AUX_DAC_B, 1);
- this->write_aux_dac(UNIT_RX, AUX_DAC_A, 2);
- this->write_aux_dac(UNIT_RX, AUX_DAC_B, 3);
- while (1)
- {
- UHD_VAR(this->read_aux_adc(UNIT_TX, AUX_ADC_A));
- UHD_VAR(this->read_aux_adc(UNIT_TX, AUX_ADC_B));
- UHD_VAR(this->read_aux_adc(UNIT_RX, AUX_ADC_A));
- UHD_VAR(this->read_aux_adc(UNIT_RX, AUX_ADC_B));
- sleep(1);
- }
- }
- */
-
}
x300_dboard_iface::~x300_dboard_iface(void)
@@ -153,6 +134,8 @@ x300_dboard_iface::~x300_dboard_iface(void)
**********************************************************************/
void x300_dboard_iface::set_clock_rate(unit_t unit, double rate)
{
+ if (unit == UNIT_BOTH) throw uhd::runtime_error("UNIT_BOTH not supported.");
+
// Just return if the requested rate is already set
if (std::fabs(_clock_rates[unit] - rate) < std::numeric_limits<double>::epsilon())
return;
@@ -165,17 +148,21 @@ void x300_dboard_iface::set_clock_rate(unit_t unit, double rate)
case UNIT_TX:
_config.clock->set_dboard_rate(_config.which_tx_clk, rate);
break;
+ default:
+ UHD_THROW_INVALID_CODE_PATH();
}
_clock_rates[unit] = rate; //set to shadow
}
double x300_dboard_iface::get_clock_rate(unit_t unit)
{
+ if (unit == UNIT_BOTH) throw uhd::runtime_error("UNIT_BOTH not supported.");
return _clock_rates[unit]; //get from shadow
}
std::vector<double> x300_dboard_iface::get_clock_rates(unit_t unit)
{
+ if (unit == UNIT_BOTH) throw uhd::runtime_error("UNIT_BOTH not supported.");
switch(unit)
{
case UNIT_RX:
@@ -189,6 +176,7 @@ std::vector<double> x300_dboard_iface::get_clock_rates(unit_t unit)
void x300_dboard_iface::set_clock_enabled(unit_t unit, bool enb)
{
+ if (unit == UNIT_BOTH) throw uhd::runtime_error("UNIT_BOTH not supported.");
switch(unit)
{
case UNIT_RX:
@@ -200,42 +188,58 @@ void x300_dboard_iface::set_clock_enabled(unit_t unit, bool enb)
}
}
-double x300_dboard_iface::get_codec_rate(unit_t)
+double x300_dboard_iface::get_codec_rate(unit_t unit)
{
+ if (unit == UNIT_BOTH) throw uhd::runtime_error("UNIT_BOTH not supported.");
return _config.clock->get_master_clock_rate();
}
/***********************************************************************
* GPIO
**********************************************************************/
-void x300_dboard_iface::_set_pin_ctrl(unit_t unit, boost::uint16_t value)
+void x300_dboard_iface::set_pin_ctrl(unit_t unit, boost::uint32_t value, boost::uint32_t mask)
{
- return _config.gpio->set_pin_ctrl(unit, value);
+ _config.gpio->set_pin_ctrl(unit, value, mask);
}
-void x300_dboard_iface::_set_gpio_ddr(unit_t unit, boost::uint16_t value)
+boost::uint32_t x300_dboard_iface::get_pin_ctrl(unit_t unit)
{
- return _config.gpio->set_gpio_ddr(unit, value);
+ return _config.gpio->get_pin_ctrl(unit);
}
-void x300_dboard_iface::_set_gpio_out(unit_t unit, boost::uint16_t value)
+void x300_dboard_iface::set_atr_reg(unit_t unit, atr_reg_t reg, boost::uint32_t value, boost::uint32_t mask)
{
- return _config.gpio->set_gpio_out(unit, value);
+ _config.gpio->set_atr_reg(unit, reg, value, mask);
}
-boost::uint16_t x300_dboard_iface::read_gpio(unit_t unit)
+boost::uint32_t x300_dboard_iface::get_atr_reg(unit_t unit, atr_reg_t reg)
{
- return _config.gpio->read_gpio(unit);
+ return _config.gpio->get_atr_reg(unit, reg);
}
-void x300_dboard_iface::_set_atr_reg(unit_t unit, atr_reg_t atr, boost::uint16_t value)
+void x300_dboard_iface::set_gpio_ddr(unit_t unit, boost::uint32_t value, boost::uint32_t mask)
{
- return _config.gpio->set_atr_reg(unit, atr, value);
+ _config.gpio->set_gpio_ddr(unit, value, mask);
}
-void x300_dboard_iface::set_gpio_debug(unit_t, int)
+boost::uint32_t x300_dboard_iface::get_gpio_ddr(unit_t unit)
{
- throw uhd::not_implemented_error("no set_gpio_debug implemented");
+ return _config.gpio->get_gpio_ddr(unit);
+}
+
+void x300_dboard_iface::set_gpio_out(unit_t unit, boost::uint32_t value, boost::uint32_t mask)
+{
+ _config.gpio->set_gpio_out(unit, value, mask);
+}
+
+boost::uint32_t x300_dboard_iface::get_gpio_out(unit_t unit)
+{
+ return _config.gpio->get_gpio_out(unit);
+}
+
+boost::uint32_t x300_dboard_iface::read_gpio(unit_t unit)
+{
+ return _config.gpio->read_gpio(unit);
}
/***********************************************************************
@@ -250,6 +254,7 @@ void x300_dboard_iface::write_spi(
boost::uint32_t data,
size_t num_bits
){
+ if (unit == UNIT_BOTH) throw uhd::runtime_error("UNIT_BOTH not supported.");
_config.spi->write_spi(toslaveno(unit), config, data, num_bits);
}
@@ -259,6 +264,7 @@ boost::uint32_t x300_dboard_iface::read_write_spi(
boost::uint32_t data,
size_t num_bits
){
+ if (unit == UNIT_BOTH) throw uhd::runtime_error("UNIT_BOTH not supported.");
return _config.spi->read_spi(toslaveno(unit), config, data, num_bits);
}
@@ -284,6 +290,7 @@ void x300_dboard_iface::_write_aux_dac(unit_t unit)
(UNIT_RX, DB_RX_LSDAC_SEN)
(UNIT_TX, DB_TX_LSDAC_SEN)
;
+ if (unit == UNIT_BOTH) throw uhd::runtime_error("UNIT_BOTH not supported.");
_config.spi->write_spi(
unit_to_spi_dac[unit], spi_config_t::EDGE_FALL,
_dac_regs[unit].get_reg(), 24
@@ -292,6 +299,8 @@ void x300_dboard_iface::_write_aux_dac(unit_t unit)
void x300_dboard_iface::write_aux_dac(unit_t unit, aux_dac_t which, double value)
{
+ if (unit == UNIT_BOTH) throw uhd::runtime_error("UNIT_BOTH not supported.");
+
_dac_regs[unit].data = boost::math::iround(4095*value/3.3);
_dac_regs[unit].cmd = ad5623_regs_t::CMD_WR_UP_DAC_CHAN_N;
@@ -321,6 +330,8 @@ double x300_dboard_iface::read_aux_adc(unit_t unit, aux_adc_t which)
(UNIT_TX, DB_TX_LSADC_SEN)
;
+ if (unit == UNIT_BOTH) throw uhd::runtime_error("UNIT_BOTH not supported.");
+
//setup spi config args
spi_config_t config;
config.mosi_edge = spi_config_t::EDGE_FALL;