aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTrung N Tran <trung.tran@ettus.com>2018-02-21 13:39:17 -0800
committerMartin Braun <martin.braun@ettus.com>2018-02-21 16:59:46 -0800
commitc208452c81685d8bb865202f3ab4f5461023a22e (patch)
tree159dda4605cf483f930079e3f9b4b50e4c1e4eeb
parent21cc92016c4d5c3ae99e8fb49c04793feb51c21e (diff)
downloaduhd-c208452c81685d8bb865202f3ab4f5461023a22e.tar.gz
uhd-c208452c81685d8bb865202f3ab4f5461023a22e.tar.bz2
uhd-c208452c81685d8bb865202f3ab4f5461023a22e.zip
x300,n230,e300: changes to adapt to new usrp API
-rw-r--r--host/lib/usrp/e300/e300_impl.cpp37
-rw-r--r--host/lib/usrp/n230/n230_impl.cpp65
-rw-r--r--host/lib/usrp/x300/x300_radio_ctrl_impl.cpp35
3 files changed, 111 insertions, 26 deletions
diff --git a/host/lib/usrp/e300/e300_impl.cpp b/host/lib/usrp/e300/e300_impl.cpp
index 7006994cc..24e9c6f82 100644
--- a/host/lib/usrp/e300/e300_impl.cpp
+++ b/host/lib/usrp/e300/e300_impl.cpp
@@ -521,14 +521,39 @@ e300_impl::e300_impl(const uhd::device_addr_t &device_addr)
// internal gpios
////////////////////////////////////////////////////////////////////
gpio_atr_3000::sptr fp_gpio = gpio_atr_3000::make(_radio_perifs[0].ctrl, radio::sr_addr(radio::FP_GPIO), radio::RB32_FP_GPIO);
- for(const gpio_attr_map_t::value_type attr: gpio_attr_map)
- {
- _tree->create<uint32_t>(mb_path / "gpio" / "INT0" / attr.second)
- .add_coerced_subscriber(boost::bind(&gpio_atr_3000::set_gpio_attr, fp_gpio, attr.first, _1))
- .set(0);
+ for(const auto& attr: gpio_attr_map){
+ switch (attr.first){
+ case usrp::gpio_atr::GPIO_SRC:
+ _tree->create<std::vector<std::string>>(mb_path / "gpio" / "INT0" / attr.second)
+ .set(std::vector<std::string>(32, usrp::gpio_atr::default_attr_value_map.at(attr.first)))
+ .add_coerced_subscriber([this](const std::vector<std::string> str_val){
+ throw uhd::runtime_error("This device does not support set SRC attribute.");
+ });
+ break;
+ case usrp::gpio_atr::GPIO_CTRL:
+ case usrp::gpio_atr::GPIO_DDR:
+ _tree->create<std::vector<std::string>>(mb_path / "gpio" / "INT0" / attr.second)
+ .set(std::vector<std::string>(32, usrp::gpio_atr::default_attr_value_map.at(attr.first)))
+ .add_coerced_subscriber([this, fp_gpio, attr](const std::vector<std::string> str_val){
+ uint32_t val = 0;
+ for(size_t i = 0 ; i < str_val.size() ; i++){
+ val += usrp::gpio_atr::gpio_attr_value_pair.at(attr.second).at(str_val[i])<<i;
+ }
+ fp_gpio->set_gpio_attr(attr.first, val);
+ });
+ break;
+ default:
+ _tree->create<uint32_t>(mb_path / "gpio" / "INT0" / attr.second)
+ .set(0)
+ .add_coerced_subscriber([this, fp_gpio, attr](const uint32_t val){
+ fp_gpio->set_gpio_attr(attr.first, val);
+ });
+ }
}
_tree->create<uint8_t>(mb_path / "gpio" / "INT0" / "READBACK")
- .set_publisher(boost::bind(&gpio_atr_3000::read_gpio, fp_gpio));
+ .set_publisher([this, fp_gpio](){
+ return fp_gpio->read_gpio();
+ });
////////////////////////////////////////////////////////////////////
diff --git a/host/lib/usrp/n230/n230_impl.cpp b/host/lib/usrp/n230/n230_impl.cpp
index fd3d33ef5..1b59793b8 100644
--- a/host/lib/usrp/n230/n230_impl.cpp
+++ b/host/lib/usrp/n230/n230_impl.cpp
@@ -399,22 +399,55 @@ void n230_impl::_initialize_property_tree(const fs_path& mb_path)
//------------------------------------------------------------------
// MiniSAS GPIO
//------------------------------------------------------------------
- _tree->create<uint32_t>(mb_path / "gpio" / "FP0" / "DDR")
- .set(0)
- .add_coerced_subscriber(boost::bind(&gpio_atr::gpio_atr_3000::set_gpio_attr,
- _resource_mgr->get_minisas_gpio_ctrl_sptr(0), gpio_atr::GPIO_DDR, _1));
- _tree->create<uint32_t>(mb_path / "gpio" / "FP1" / "DDR")
- .set(0)
- .add_coerced_subscriber(boost::bind(&gpio_atr::gpio_atr_3000::set_gpio_attr,
- _resource_mgr->get_minisas_gpio_ctrl_sptr(1), gpio_atr::GPIO_DDR, _1));
- _tree->create<uint32_t>(mb_path / "gpio" / "FP0" / "OUT")
- .set(0)
- .add_coerced_subscriber(boost::bind(&gpio_atr::gpio_atr_3000::set_gpio_attr,
- _resource_mgr->get_minisas_gpio_ctrl_sptr(0), gpio_atr::GPIO_OUT, _1));
- _tree->create<uint32_t>(mb_path / "gpio" / "FP1" / "OUT")
- .set(0)
- .add_coerced_subscriber(boost::bind(&gpio_atr::gpio_atr_3000::set_gpio_attr,
- _resource_mgr->get_minisas_gpio_ctrl_sptr(1), gpio_atr::GPIO_OUT, _1));
+ for(const usrp::gpio_atr::gpio_attr_map_t::value_type attr: usrp::gpio_atr::gpio_attr_map) {
+ switch (attr.first){
+ case usrp::gpio_atr::GPIO_SRC:
+ case usrp::gpio_atr::GPIO_CTRL:
+ _tree->create<std::vector<std::string>>(mb_path / "gpio" / "FP0" / attr.second)
+ .set(std::vector<std::string>(32, usrp::gpio_atr::default_attr_value_map.at(attr.first)));
+ _tree->create<std::vector<std::string>>(mb_path / "gpio" / "FP1" / attr.second)
+ .set(std::vector<std::string>(32, usrp::gpio_atr::default_attr_value_map.at(attr.first)));
+ break;
+ case usrp::gpio_atr::GPIO_DDR:
+ _tree->create<std::vector<std::string>>(mb_path / "gpio" / "FP0" / attr.second)
+ .set(std::vector<std::string>(32, usrp::gpio_atr::default_attr_value_map.at(attr.first)))
+ .add_coerced_subscriber([this, attr](const std::vector<std::string> str_val){
+ uint32_t val = 0;
+ for(size_t i = 0 ; i < str_val.size() ; i++){
+ val += usrp::gpio_atr::gpio_attr_value_pair.at(attr.second).at(str_val[i])<<i;
+ }
+ _resource_mgr->get_minisas_gpio_ctrl_sptr(0)->set_gpio_attr(attr.first, val);
+ });
+ _tree->create<std::vector<std::string>>(mb_path / "gpio" / "FP1" / attr.second)
+ .set(std::vector<std::string>(32, usrp::gpio_atr::default_attr_value_map.at(attr.first)))
+ .add_coerced_subscriber([this, attr](const std::vector<std::string> str_val){
+ uint32_t val = 0;
+ for(size_t i = 0 ; i < str_val.size() ; i++){
+ val += usrp::gpio_atr::gpio_attr_value_pair.at(attr.second).at(str_val[i])<<i;
+ }
+ _resource_mgr->get_minisas_gpio_ctrl_sptr(1)->set_gpio_attr(attr.first, val);
+ });
+ break;
+ case usrp::gpio_atr::GPIO_OUT:
+ _tree->create<uint32_t>(mb_path / "gpio" / "FP0" / attr.second)
+ .set(0)
+ .add_coerced_subscriber([this, attr](const uint32_t val){
+ _resource_mgr->get_minisas_gpio_ctrl_sptr(0)->set_gpio_attr(attr.first, val);
+ });
+ _tree->create<uint32_t>(mb_path / "gpio" / "FP1" / attr.second)
+ .set(0)
+ .add_coerced_subscriber([this, attr](const uint32_t val){
+ _resource_mgr->get_minisas_gpio_ctrl_sptr(1)->set_gpio_attr(attr.first, val);
+ });
+ break;
+ default:
+ _tree->create<uint32_t>(mb_path / "gpio" / "FP0" / attr.second)
+ .set(0);
+ _tree->create<uint32_t>(mb_path / "gpio" / "FP1" / attr.second)
+ .set(0);
+ break;
+ }
+ }
_tree->create<uint32_t>(mb_path / "gpio" / "FP0" / "READBACK")
.set_publisher(boost::bind(&gpio_atr::gpio_atr_3000::read_gpio, _resource_mgr->get_minisas_gpio_ctrl_sptr(0)));
_tree->create<uint32_t>(mb_path / "gpio" / "FP1" / "READBACK")
diff --git a/host/lib/usrp/x300/x300_radio_ctrl_impl.cpp b/host/lib/usrp/x300/x300_radio_ctrl_impl.cpp
index 06a4c955d..b6b6e1824 100644
--- a/host/lib/usrp/x300/x300_radio_ctrl_impl.cpp
+++ b/host/lib/usrp/x300/x300_radio_ctrl_impl.cpp
@@ -73,12 +73,39 @@ UHD_RFNOC_RADIO_BLOCK_CONSTRUCTOR(x300_radio_ctrl)
if (_radio_type==PRIMARY) {
_fp_gpio = gpio_atr::gpio_atr_3000::make(ctrl, regs::sr_addr(regs::FP_GPIO), regs::RB_FP_GPIO);
for(const gpio_atr::gpio_attr_map_t::value_type attr: gpio_atr::gpio_attr_map) {
- _tree->create<uint32_t>(fs_path("gpio") / "FP0" / attr.second)
- .set(0)
- .add_coerced_subscriber(boost::bind(&gpio_atr::gpio_atr_3000::set_gpio_attr, _fp_gpio, attr.first, _1));
+ switch (attr.first){
+ case usrp::gpio_atr::GPIO_SRC:
+ _tree->create<std::vector<std::string>>(fs_path("gpio") / "FP0" / attr.second)
+ .set(std::vector<std::string>(32, usrp::gpio_atr::default_attr_value_map.at(attr.first)))
+ .add_coerced_subscriber([this](const std::vector<std::string> str_val){
+ throw uhd::runtime_error("This device does not support set SRC attribute.");
+ });
+ break;
+ case usrp::gpio_atr::GPIO_CTRL:
+ case usrp::gpio_atr::GPIO_DDR:
+ _tree->create<std::vector<std::string>>(fs_path("gpio") / "FP0" / attr.second)
+ .set(std::vector<std::string>(32, usrp::gpio_atr::default_attr_value_map.at(attr.first)))
+ .add_coerced_subscriber([this, attr](const std::vector<std::string> str_val){
+ uint32_t val = 0;
+ for(size_t i = 0 ; i < str_val.size() ; i++){
+ val += usrp::gpio_atr::gpio_attr_value_pair.at(attr.second).at(str_val[i])<<i;
+ }
+ _fp_gpio->set_gpio_attr(attr.first, val);
+ });
+ break;
+ default:
+ _tree->create<uint32_t>(fs_path("gpio") / "FP0" / attr.second)
+ .set(0)
+ .add_coerced_subscriber([this, attr](const uint32_t val){
+ _fp_gpio->set_gpio_attr(attr.first, val);
+ });
+ }
+
}
_tree->create<uint32_t>(fs_path("gpio") / "FP0" / "READBACK")
- .set_publisher(boost::bind(&gpio_atr::gpio_atr_3000::read_gpio, _fp_gpio));
+ .set_publisher([this](){
+ return _fp_gpio->read_gpio();
+ });
}
////////////////////////////////////////////////////////////////