aboutsummaryrefslogtreecommitdiffstats
path: root/mpm
diff options
context:
space:
mode:
Diffstat (limited to 'mpm')
-rwxr-xr-xmpm/python/n3xx_bist21
-rw-r--r--mpm/python/usrp_mpm/sys_utils/sysfs_gpio.py12
2 files changed, 20 insertions, 13 deletions
diff --git a/mpm/python/n3xx_bist b/mpm/python/n3xx_bist
index ba3a104e8..032297090 100755
--- a/mpm/python/n3xx_bist
+++ b/mpm/python/n3xx_bist
@@ -669,6 +669,7 @@ class N310BIST(object):
"""
assert 'gpio' in self.tests_to_run
# patterns = list(range(64))
+ GPIO_WIDTH = 12
patterns = range(64)
if self.args.dry_run:
return True, {
@@ -686,7 +687,7 @@ class N310BIST(object):
" Run a GPIO test for a given set of patterns "
gpio_ctrl = n310.FrontpanelGPIO(ddr)
for pattern in patterns:
- gpio_ctrl.set_all(pattern)
+ gpio_set_all(gpio_ctrl, pattern, GPIO_WIDTH, ddr)
time.sleep(0.1)
gpio_rb = gpio_ctrl.get_all()
if pattern != gpio_rb:
@@ -748,6 +749,24 @@ class N310BIST(object):
}
return len(result) == 2, result
+
+def gpio_set_all(gpio_bank, value, gpio_size, ddr_mask):
+ """Helper function for set gpio.
+ What this function do is take decimal value and convert to a binary string
+ then try to set those individual bits to the gpio_bank.
+ Arguments:
+ gpio_bank -- gpio bank type.
+ value -- value to set onto gpio bank.
+ gpio_size -- size of the gpio bank
+ ddr_mask -- data direction register bit mask. 0 is input; 1 is output.
+ """
+ ddr_size = bin(ddr_mask).count("1")
+ value_bitstring = ('{0:0' + str(ddr_size) + 'b}').format(value)[-(gpio_size):]
+ ddr_bitstring = ('{0:0' + str(gpio_size) + 'b}').format(ddr_mask)[-(gpio_size):]
+ for i in range(gpio_size):
+ if ddr_bitstring[gpio_size - 1 - i] == "1":
+ gpio_bank.set(i, value_bitstring[i % ddr_size])
+
##############################################################################
# main
##############################################################################
diff --git a/mpm/python/usrp_mpm/sys_utils/sysfs_gpio.py b/mpm/python/usrp_mpm/sys_utils/sysfs_gpio.py
index 10c8ad06a..286b8e54a 100644
--- a/mpm/python/usrp_mpm/sys_utils/sysfs_gpio.py
+++ b/mpm/python/usrp_mpm/sys_utils/sysfs_gpio.py
@@ -201,18 +201,6 @@ class GPIOBank(object):
self._ddr << self._offset
)
- def set_all(self, value):
- """
- Set all pins to 'value'.
- This method will convert value into binary and assign all the bits in
- the use mask.
- """
- bin_value = ('{0:0'+str(self._gpiosize)+'b}').format(value)
- wr_value = bin_value[-(self._gpiosize):]
- for i in range(self._gpiosize):
- if (1 << i) & self._ddr:
- self._gpios.set(self._offset + i, wr_value[i % self._gpiosize])
-
def set(self, index, value=None):
"""
Set a pin by index