From 8b929b2d4e02ccd6318dac9c7c0a633f0cf60511 Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Wed, 13 Nov 2019 15:46:33 -0800 Subject: 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 --- host/lib/usrp/cores/gpio_atr_3000.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'host/lib/usrp/cores') 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) -- cgit v1.2.3