diff options
author | Trung N Tran <trung.tran@ettus.com> | 2018-02-08 17:37:21 -0800 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2018-02-09 18:02:44 +0100 |
commit | 43969f4758ed00198de96c39e161128e00eb20ff (patch) | |
tree | 7d8668a3f77075667d771692faed8806f5010f8c /mpm/python/n3xx_bist | |
parent | ca81898889ae7fa3c2b7b2cdd67213a45dc82282 (diff) | |
download | uhd-43969f4758ed00198de96c39e161128e00eb20ff.tar.gz uhd-43969f4758ed00198de96c39e161128e00eb20ff.tar.bz2 uhd-43969f4758ed00198de96c39e161128e00eb20ff.zip |
mpm: remove GPIOBank.set_all function
-set_all function doesn't fit well with the GPIO api. It is rather
a test sepecific function.
-Add gpio_set_all helper to n3xx_bist.
Reviewed-by: Martin Braun <martin.braun@ettus.com>
Diffstat (limited to 'mpm/python/n3xx_bist')
-rwxr-xr-x | mpm/python/n3xx_bist | 21 |
1 files changed, 20 insertions, 1 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 ############################################################################## |