aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2012-07-03 17:40:52 -0700
committerJosh Blum <josh@joshknows.com>2012-07-06 11:52:09 -0700
commit7c8fef85c070ad582d16d5782e7421700b714918 (patch)
treeb3b1054ace0444c5044bca17e7b1f2ff895d16f3
parentb3deb2528aaba1c7e00e5c27b136def2bd48a292 (diff)
downloaduhd-7c8fef85c070ad582d16d5782e7421700b714918.tar.gz
uhd-7c8fef85c070ad582d16d5782e7421700b714918.tar.bz2
uhd-7c8fef85c070ad582d16d5782e7421700b714918.zip
usrp: cache writes to gpio pins (avoids overhead)
-rw-r--r--host/lib/usrp/cores/gpio_core_200.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/host/lib/usrp/cores/gpio_core_200.cpp b/host/lib/usrp/cores/gpio_core_200.cpp
index d756097ff..cdab70b8d 100644
--- a/host/lib/usrp/cores/gpio_core_200.cpp
+++ b/host/lib/usrp/cores/gpio_core_200.cpp
@@ -63,6 +63,7 @@ private:
wb_iface::sptr _iface;
const size_t _base;
const size_t _rb_addr;
+ uhd::dict<size_t, boost::uint32_t> _update_cache;
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;
@@ -90,7 +91,12 @@ private:
const boost::uint32_t ctrl =
(boost::uint32_t(_pin_ctrl[dboard_iface::UNIT_RX]) << unit2shit(dboard_iface::UNIT_RX)) |
(boost::uint32_t(_pin_ctrl[dboard_iface::UNIT_TX]) << unit2shit(dboard_iface::UNIT_TX));
- _iface->poke32(addr, (ctrl & atr_val) | ((~ctrl) & gpio_val));
+ const boost::uint32_t val = (ctrl & atr_val) | ((~ctrl) & gpio_val);
+ if (not _update_cache.has_key(addr) or _update_cache[addr] != val)
+ {
+ _iface->poke32(addr, val);
+ }
+ _update_cache[addr] = val;
}
};