aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/include/uhdlib/usrp
diff options
context:
space:
mode:
authorLane Kolbly <lane.kolbly@ni.com>2021-10-14 13:15:48 -0500
committerAaron Rossetto <aaron.rossetto@ni.com>2021-10-27 07:56:33 -0700
commit62d467f3fc024f6a43abca9c3a2b194b5d3829bf (patch)
tree45e13cf7624f0539febb37478c305e05055d7cb5 /host/lib/include/uhdlib/usrp
parent4e6531f30648ede5be8f93fa49fdcd4973b73813 (diff)
downloaduhd-62d467f3fc024f6a43abca9c3a2b194b5d3829bf.tar.gz
uhd-62d467f3fc024f6a43abca9c3a2b194b5d3829bf.tar.bz2
uhd-62d467f3fc024f6a43abca9c3a2b194b5d3829bf.zip
host: gpio: Create gpio_atr_offsets to store GPIO registers
Refactors register addresses into a gpio_atr_offsets structure which contains the various register addresses. This allows creating other devices with different GPIO register layouts with greater ease, and eliminates the use of macros (yay!)
Diffstat (limited to 'host/lib/include/uhdlib/usrp')
-rw-r--r--host/lib/include/uhdlib/usrp/cores/gpio_atr_3000.hpp71
1 files changed, 47 insertions, 24 deletions
diff --git a/host/lib/include/uhdlib/usrp/cores/gpio_atr_3000.hpp b/host/lib/include/uhdlib/usrp/cores/gpio_atr_3000.hpp
index aa266cbcb..85f22d967 100644
--- a/host/lib/include/uhdlib/usrp/cores/gpio_atr_3000.hpp
+++ b/host/lib/include/uhdlib/usrp/cores/gpio_atr_3000.hpp
@@ -17,38 +17,66 @@
namespace uhd { namespace usrp { namespace gpio_atr {
-class gpio_atr_3000 : uhd::noncopyable
+struct gpio_atr_offsets
{
-public:
- typedef std::shared_ptr<gpio_atr_3000> sptr;
-
- static const uint32_t MASK_SET_ALL = 0xFFFFFFFF;
+ uhd::wb_iface::wb_addr_type idle;
+ uhd::wb_iface::wb_addr_type rx;
+ uhd::wb_iface::wb_addr_type tx;
+ uhd::wb_iface::wb_addr_type duplex;
+ uhd::wb_iface::wb_addr_type ddr;
+ uhd::wb_iface::wb_addr_type disable;
+ uhd::wb_iface::wb_addr_type readback;
- virtual ~gpio_atr_3000(void) {}
+ /*!
+ * Returns whether this GPIO regmap is write-only.
+ *
+ * \return whether the readback register is valid
+ */
+ bool is_writeonly() const;
/*!
- * Create a read-write GPIO ATR interface object
+ * Create a GPIO regmap according to the typical "defaults": Four
+ * sequential ATR registers followed immediately by, in order, duplex,
+ * direction, disable, and an explicitly specified readback address.
*
- * \param iface register iface to GPIO ATR registers
* \param base base settings offset for GPIO ATR registers
* \param rb_addr readback offset for GPIO ATR registers
- * \param reg_offset Delta between the register addresses
+ * \param stride Delta between the register addresses
*/
- static sptr make(uhd::wb_iface::sptr iface,
+ static gpio_atr_offsets make_default(
const uhd::wb_iface::wb_addr_type base,
const uhd::wb_iface::wb_addr_type rb_addr,
- const size_t reg_offset = 4);
+ const size_t stride = 4);
/*!
- * Create a write-only GPIO ATR interface object
+ * Create a GPIO regmap according to the typical "defaults" (see
+ * make_default), with the readback register disabled.
*
- * \param iface register iface to GPIO ATR registers
* \param base base settings offset for GPIO ATR registers
- * \param reg_offset Delta between the register addresses
+ * \param rb_addr readback offset for GPIO ATR registers
+ * \param stride Delta between the register addresses
*/
- static sptr make_write_only(uhd::wb_iface::sptr iface,
+ static gpio_atr_offsets make_write_only(
const uhd::wb_iface::wb_addr_type base,
- const size_t reg_offset = 4);
+ const size_t stride = 4);
+};
+
+class gpio_atr_3000 : uhd::noncopyable
+{
+public:
+ typedef std::shared_ptr<gpio_atr_3000> sptr;
+
+ static const uint32_t MASK_SET_ALL = 0xFFFFFFFF;
+
+ virtual ~gpio_atr_3000(void) {}
+
+ /*!
+ * Create a GPIO ATR interface object using the given registers
+ *
+ * \param iface register iface to GPIO ATR registers
+ * \param registers Register offsets
+ */
+ static sptr make(uhd::wb_iface::sptr iface, gpio_atr_offsets registers);
/*!
* Select the ATR mode for all bits in the mask
@@ -124,17 +152,12 @@ public:
virtual ~db_gpio_atr_3000(void) {}
/*!
- * Create a read-write GPIO ATR interface object for a daughterboard connector
+ * Create a GPIO ATR interface object for a daughterboard connector
*
* \param iface register iface to GPIO ATR registers
- * \param base base settings offset for GPIO ATR registers
- * \param rb_addr readback offset for GPIO ATR registers
- * \param reg_offset Delta between the register addresses
+ * \param registers Register offsets
*/
- static sptr make(uhd::wb_iface::sptr iface,
- const uhd::wb_iface::wb_addr_type base,
- const uhd::wb_iface::wb_addr_type rb_addr,
- const size_t reg_offset = 4);
+ static sptr make(uhd::wb_iface::sptr iface, gpio_atr_offsets registers);
/*!
* Configure the GPIO mode for all pins in the daughterboard connector