diff options
author | Dhiren Wijesinghe <dhiren.wijesinghe@ni.com> | 2021-06-18 14:07:18 -0500 |
---|---|---|
committer | Aaron Rossetto <aaron.rossetto@ni.com> | 2021-11-03 06:04:50 -0700 |
commit | c36fc5f6c088efe00eac1f0de32c4377c81fc883 (patch) | |
tree | bc83ae588edd852d9a5ced2f0a00c4c4fc630140 /mpm/python/usrp_mpm/periph_manager/x4xx.py | |
parent | 426f078ba015f1b0a1521ad447a5a5f79f9fc2a1 (diff) | |
download | uhd-c36fc5f6c088efe00eac1f0de32c4377c81fc883.tar.gz uhd-c36fc5f6c088efe00eac1f0de32c4377c81fc883.tar.bz2 uhd-c36fc5f6c088efe00eac1f0de32c4377c81fc883.zip |
mpm: x4xx: add DIO GPIO API configuration methods
These methods allow for reconfiguration of GPIO masters for x4xx.
The method names are get_gpio_banks, get_gpio_srcs, get_gpio_src,
and set_gpio_src.
Diffstat (limited to 'mpm/python/usrp_mpm/periph_manager/x4xx.py')
-rw-r--r-- | mpm/python/usrp_mpm/periph_manager/x4xx.py | 56 |
1 files changed, 49 insertions, 7 deletions
diff --git a/mpm/python/usrp_mpm/periph_manager/x4xx.py b/mpm/python/usrp_mpm/periph_manager/x4xx.py index 30938a6b2..ad8f2fdcc 100644 --- a/mpm/python/usrp_mpm/periph_manager/x4xx.py +++ b/mpm/python/usrp_mpm/periph_manager/x4xx.py @@ -302,6 +302,9 @@ class x4xx(ZynqComponents, PeriphManagerBase): try: self._init_peripherals(args) self.init_dboards(args) + # We need to init dio_control separately from peripherals + # since it needs information about available dboards + self._init_dio_control(args) self._clk_mgr.set_dboard_reset_cb( lambda enable: [db.reset_clock(enable) for db in self.dboards]) except Exception as ex: @@ -535,13 +538,6 @@ class x4xx(ZynqComponents, PeriphManagerBase): # is possible to always enable the iPass cable present forwarding. self.ctrlport_regs.enable_cable_present_forwarding(True) - # Init DIO - if self._check_compat_aux_board(DIOAUX_EEPROM, DIOAUX_PID): - self.dio_control = DioControl(self.mboard_regs_control, - self.cpld_control, self.log) - # add dio_control public methods to MPM API - self._add_public_methods(self.dio_control, "dio") - # Init QSFP modules for idx, config in enumerate(X400_QSFP_I2C_CONFIGS): attr = QSFPModule( @@ -566,6 +562,18 @@ class x4xx(ZynqComponents, PeriphManagerBase): self._status_monitor_thread.start() # Init complete. self.log.debug("Device info: {}".format(self.device_info)) + + def _init_dio_control(self, _): + """ + Turn on gpio peripherals. This may throw an error on failure, so make + sure to catch it. + """ + if self._check_compat_aux_board(DIOAUX_EEPROM, DIOAUX_PID): + self.dio_control = DioControl(self.mboard_regs_control, + self.cpld_control, self.log, + self.dboards) + # add dio_control public methods to MPM API + self._add_public_methods(self.dio_control, "dio") def _check_compat_aux_board(self, name, pid): """ @@ -1018,6 +1026,40 @@ class x4xx(ZynqComponents, PeriphManagerBase): } ] + ########################################################################### + # GPIO API + ########################################################################### + + def get_gpio_banks(self): + """ + Returns a list of GPIO banks over which MPM has any control + """ + return self.dio_control.get_gpio_banks() + + def get_gpio_srcs(self, bank: str): + """ + Return a list of valid GPIO sources for a given bank + """ + return self.dio_control.get_gpio_srcs(bank) + + def get_gpio_src(self, bank: str): + """ + Return the currently selected GPIO source for a given bank. The return + value is a list of strings. The length of the vector is identical to + the number of controllable GPIO pins on this bank. CUSTOM is for + miscellaneous pin source, and USER_APP is for LabView pin source. + """ + return self.dio_control.get_gpio_src(bank) + + def set_gpio_src(self, bank: str, *src): + """ + Set the GPIO source for a given bank. + src input is big-endian + Usage: + > set_gpio_src <bank> <srcs> + > set_gpio_src GPIO0 PS DB1_RF1 PS PS MPM PS PS PS MPM USER_APP PS + """ + self.dio_control.set_gpio_src(bank, *src) ########################################################################### # Utility for validating RPU core number |