diff options
author | Martin Braun <martin.braun@ettus.com> | 2019-11-13 15:46:33 -0800 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2019-11-26 12:21:34 -0800 |
commit | 8b929b2d4e02ccd6318dac9c7c0a633f0cf60511 (patch) | |
tree | 83fd44ef4eb3197c580b6c0d1d87e3bb77ae533c /host/lib | |
parent | 113b3262d3ac2995b5141180be70a0790fa553ed (diff) | |
download | uhd-8b929b2d4e02ccd6318dac9c7c0a633f0cf60511.tar.gz uhd-8b929b2d4e02ccd6318dac9c7c0a633f0cf60511.tar.bz2 uhd-8b929b2d4e02ccd6318dac9c7c0a633f0cf60511.zip |
gpio_atr_3000: Fix return value for pin control register
This fixes a bug where get_gpio_attr(bank, "CTRL") would return the
inverted value of what was written. Reason is that the underlying
register was an ATR disable register.
The fix is to invert the cached values of the register.
Now, the following Python code will work:
>>> U = uhd.usrp.MultiUSRP("type=x300")
>>> atr_enable = 0xF # Enable ATR on lower 4 pins, rest is GPIO
>>> U.set_gpio_attr("FP0A", "CTRL", atr_enable)
>>> U.get_gpio_attr("FP0A", "CTRL") == atr_enable
True
Diffstat (limited to 'host/lib')
-rw-r--r-- | host/lib/usrp/cores/gpio_atr_3000.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/host/lib/usrp/cores/gpio_atr_3000.cpp b/host/lib/usrp/cores/gpio_atr_3000.cpp index d48211fd4..14996f659 100644 --- a/host/lib/usrp/cores/gpio_atr_3000.cpp +++ b/host/lib/usrp/cores/gpio_atr_3000.cpp @@ -74,7 +74,9 @@ public: auto value = (mode == MODE_ATR) ? ~MASK_SET_ALL : MASK_SET_ALL; _atr_disable_reg.set_with_mask(value, mask); _atr_disable_reg.flush(); - _update_attr_state(GPIO_CTRL, value, mask); + // The attr state is inverted from _atr_disable_reg. In _atr_disable_reg, + // 1 == disable, whereas in CTRL, 1 means enable ATR. + _update_attr_state(GPIO_CTRL, ~value, mask); } virtual void set_gpio_ddr(const gpio_ddr_t dir, const uint32_t mask) |