diff options
author | Trung N Tran <trung.tran@ettus.com> | 2017-07-27 16:05:33 -0700 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2017-12-22 15:04:00 -0800 |
commit | a745877cc9e3962dedb3f6b7c5db3382568fadee (patch) | |
tree | 8dee0cd3c894459ed32a58ec6b5ba7e1c069ee81 /mpm/python/usrp_mpm | |
parent | 1db37316ebe81786671739e6e297b2d47c9f4807 (diff) | |
download | uhd-a745877cc9e3962dedb3f6b7c5db3382568fadee.tar.gz uhd-a745877cc9e3962dedb3f6b7c5db3382568fadee.tar.bz2 uhd-a745877cc9e3962dedb3f6b7c5db3382568fadee.zip |
n310: gpio bist
Diffstat (limited to 'mpm/python/usrp_mpm')
-rw-r--r-- | mpm/python/usrp_mpm/periph_manager/n310.py | 70 |
1 files changed, 69 insertions, 1 deletions
diff --git a/mpm/python/usrp_mpm/periph_manager/n310.py b/mpm/python/usrp_mpm/periph_manager/n310.py index f51762e52..26c6f2893 100644 --- a/mpm/python/usrp_mpm/periph_manager/n310.py +++ b/mpm/python/usrp_mpm/periph_manager/n310.py @@ -69,7 +69,7 @@ class TCA6424(object): ) def __init__(self): - self._gpios = SysFSGPIO('tca6424',0xFFE7FF, 0x86E7FF) + self._gpios = SysFSGPIO('tca6424', 0xFFE7FF, 0x86E7FF) def set(self, name): """ @@ -92,6 +92,74 @@ class TCA6424(object): assert name in self.pins self._gpios.get(self.pins.index(name)) +class FP_GPIO(object): + """ + Abstraction layer for the front panel GPIO + """ + EMIO_BASE = 54 + FP_GPIO_OFFSET = 32 # Bit offset within the ps_gpio_* pins + + def __init__(self, ddr): + self._gpiosize = 12 + self._offset = self.FP_GPIO_OFFSET + self.EMIO_BASE + self.usemask = 0xFFF + self.ddr = ddr + self._gpios = SysFSGPIO( + 'zynq_gpio', + self.usemask<<self._offset, + self.ddr<<self._offset + ) + + def set_all(self, value): + """ + Assert all pin to the value. + This method will convert value into binary and take the first 6 bits + assign to 6pins. + """ + bin_value = '{0:06b}'.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%6]) + + def set(self, index, value=None): + """ + Assert a pin by index + """ + assert index in range(self._gpiosize) + self._gpios.set(self._offset+index, value) + + def reset_all(self): + """ + Deassert all pins + """ + for i in range(self._gpiosize): + self._gpios.reset(self._offset+i) + + def reset(self, index): + """ + Deassert a pin by index + """ + assert index in range(self._gpiosize) + self._gpios.reset(self._offset+index) + + def get_all(self): + """ + Read back all pins + """ + result = 0 + for i in range(self._gpiosize): + if not (1<<i)&self.ddr: + value = self._gpios.get(self._offset+i) + result = (result<<1) | value + return result + + def get(self, index): + """ + Read back a pin by index + """ + assert index in range(self._gpiosize) + return self._gpios.get(self._offset+index) class n310(PeriphManagerBase): """ |