aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/usrp/multi_usrp.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'host/lib/usrp/multi_usrp.cpp')
-rw-r--r--host/lib/usrp/multi_usrp.cpp108
1 files changed, 108 insertions, 0 deletions
diff --git a/host/lib/usrp/multi_usrp.cpp b/host/lib/usrp/multi_usrp.cpp
index 4bd7d1bfe..182e774fc 100644
--- a/host/lib/usrp/multi_usrp.cpp
+++ b/host/lib/usrp/multi_usrp.cpp
@@ -517,6 +517,46 @@ public:
return _tree->access<std::vector<std::string> >(mb_root(mboard) / "clock_source" / "options").get();
}
+ void set_clock_source_out(const bool enb, const size_t mboard)
+ {
+ if (mboard != ALL_MBOARDS)
+ {
+ if (_tree->exists(mb_root(mboard) / "clock_source" / "output"))
+ {
+ _tree->access<bool>(mb_root(mboard) / "clock_source" / "output").set(enb);
+ }
+ else
+ {
+ throw uhd::runtime_error("multi_usrp::set_clock_source_out - not supported on this device");
+ }
+ return;
+ }
+ for (size_t m = 0; m < get_num_mboards(); m++)
+ {
+ this->set_clock_source_out(enb, m);
+ }
+ }
+
+ void set_time_source_out(const bool enb, const size_t mboard)
+ {
+ if (mboard != ALL_MBOARDS)
+ {
+ if (_tree->exists(mb_root(mboard) / "time_source" / "output"))
+ {
+ _tree->access<bool>(mb_root(mboard) / "time_source" / "output").set(enb);
+ }
+ else
+ {
+ throw uhd::runtime_error("multi_usrp::set_time_source_out - not supported on this device");
+ }
+ return;
+ }
+ for (size_t m = 0; m < get_num_mboards(); m++)
+ {
+ this->set_time_source_out(enb, m);
+ }
+ }
+
size_t get_num_mboards(void){
return _tree->list("/mboards").size();
}
@@ -910,6 +950,74 @@ public:
}
}
+ /*******************************************************************
+ * GPIO methods
+ ******************************************************************/
+ std::vector<std::string> get_gpio_banks(const size_t mboard)
+ {
+ std::vector<std::string> banks;
+ if (_tree->exists(mb_root(mboard) / "gpio"))
+ {
+ BOOST_FOREACH(const std::string &name, _tree->list(mb_root(mboard) / "gpio"))
+ {
+ banks.push_back(name);
+ }
+ }
+ BOOST_FOREACH(const std::string &name, _tree->list(mb_root(mboard) / "dboards"))
+ {
+ banks.push_back("RX"+name);
+ banks.push_back("TX"+name);
+ }
+ return banks;
+ }
+
+ void set_gpio_attr(const std::string &bank, const std::string &attr, const boost::uint32_t value, const boost::uint32_t mask, const size_t mboard)
+ {
+ if (_tree->exists(mb_root(mboard) / "gpio" / bank))
+ {
+ const boost::uint32_t current = _tree->access<boost::uint32_t>(mb_root(mboard) / "gpio" / bank / attr).get();
+ const boost::uint32_t new_value = (current & ~mask) | (value & mask);
+ _tree->access<boost::uint32_t>(mb_root(mboard) / "gpio" / bank / attr).set(new_value);
+ return;
+ }
+ if (bank.size() > 2 and bank[1] == 'X')
+ {
+ const std::string name = bank.substr(2);
+ const dboard_iface::unit_t unit = (bank[0] == 'R')? dboard_iface::UNIT_RX : dboard_iface::UNIT_TX;
+ dboard_iface::sptr iface = _tree->access<dboard_iface::sptr>(mb_root(mboard) / "dboards" / name / "iface").get();
+ if (attr == "CTRL") iface->set_pin_ctrl(unit, boost::uint16_t(value), boost::uint16_t(mask));
+ if (attr == "DDR") iface->set_gpio_ddr(unit, boost::uint16_t(value), boost::uint16_t(mask));
+ if (attr == "OUT") iface->set_gpio_out(unit, boost::uint16_t(value), boost::uint16_t(mask));
+ if (attr == "ATR_0X") iface->set_atr_reg(unit, dboard_iface::ATR_REG_IDLE, boost::uint16_t(value), boost::uint16_t(mask));
+ if (attr == "ATR_RX") iface->set_atr_reg(unit, dboard_iface::ATR_REG_RX_ONLY, boost::uint16_t(value), boost::uint16_t(mask));
+ if (attr == "ATR_TX") iface->set_atr_reg(unit, dboard_iface::ATR_REG_TX_ONLY, boost::uint16_t(value), boost::uint16_t(mask));
+ if (attr == "ATR_XX") iface->set_atr_reg(unit, dboard_iface::ATR_REG_FULL_DUPLEX, boost::uint16_t(value), boost::uint16_t(mask));
+ }
+ }
+
+ boost::uint32_t get_gpio_attr(const std::string &bank, const std::string &attr, const size_t mboard)
+ {
+ if (_tree->exists(mb_root(mboard) / "gpio" / bank))
+ {
+ return _tree->access<boost::uint64_t>(mb_root(mboard) / "gpio" / bank / attr).get();
+ }
+ if (bank.size() > 2 and bank[1] == 'X')
+ {
+ const std::string name = bank.substr(2);
+ const dboard_iface::unit_t unit = (bank[0] == 'R')? dboard_iface::UNIT_RX : dboard_iface::UNIT_TX;
+ dboard_iface::sptr iface = _tree->access<dboard_iface::sptr>(mb_root(mboard) / "dboards" / name / "iface").get();
+ if (attr == "CTRL") return iface->get_pin_ctrl(unit);
+ if (attr == "DDR") return iface->get_gpio_ddr(unit);
+ if (attr == "OUT") return iface->get_gpio_out(unit);
+ if (attr == "ATR_0X") return iface->get_atr_reg(unit, dboard_iface::ATR_REG_IDLE);
+ if (attr == "ATR_RX") return iface->get_atr_reg(unit, dboard_iface::ATR_REG_RX_ONLY);
+ if (attr == "ATR_TX") return iface->get_atr_reg(unit, dboard_iface::ATR_REG_TX_ONLY);
+ if (attr == "ATR_XX") return iface->get_atr_reg(unit, dboard_iface::ATR_REG_FULL_DUPLEX);
+ if (attr == "READBACK") return iface->read_gpio(unit);
+ }
+ return 0;
+ }
+
private:
device::sptr _dev;
property_tree::sptr _tree;