aboutsummaryrefslogtreecommitdiffstats
path: root/mpm/python/usrp_mpm
diff options
context:
space:
mode:
authorLane Kolbly <lane.kolbly@ni.com>2022-02-07 13:17:42 -0600
committerAaron Rossetto <aaron.rossetto@ni.com>2022-02-11 07:57:37 -0600
commit6c8e9700d3458f1d1c9a14823598c0cb236f0307 (patch)
treeac7edb9a335aee7917bdd3e1440d2fa432e68d46 /mpm/python/usrp_mpm
parentdc96d6507e1fdd1b13a21301ef37aa6838ed793d (diff)
downloaduhd-6c8e9700d3458f1d1c9a14823598c0cb236f0307.tar.gz
uhd-6c8e9700d3458f1d1c9a14823598c0cb236f0307.tar.bz2
uhd-6c8e9700d3458f1d1c9a14823598c0cb236f0307.zip
mpm: x4xx: Add function to map from gpio src list indices
set_gpio_src takes a list of twelve sources to apply to the pins. For the DIO mapping, this is fine, because the twelve pins are zero through eleven. However, for the HDMI mapping, the pin indices range from one to nineteen. This commit adds a function to convert from the set_gpio_src list indices into the pin number.
Diffstat (limited to 'mpm/python/usrp_mpm')
-rw-r--r--mpm/python/usrp_mpm/periph_manager/x4xx_dio_control.py31
1 files changed, 29 insertions, 2 deletions
diff --git a/mpm/python/usrp_mpm/periph_manager/x4xx_dio_control.py b/mpm/python/usrp_mpm/periph_manager/x4xx_dio_control.py
index 1ad6bfeb2..0c283f8c0 100644
--- a/mpm/python/usrp_mpm/periph_manager/x4xx_dio_control.py
+++ b/mpm/python/usrp_mpm/periph_manager/x4xx_dio_control.py
@@ -314,6 +314,20 @@ class DioControl:
# --------------------------------------------------------------------------
# Helper methods
# --------------------------------------------------------------------------
+ def _delinearize_pin(self, port, pin):
+ """
+ Converts a pin from the compacted range [0-11] to the expanded range
+ given by the current mapping (0-19 for HDMI, 0-11 for DIO). Note that
+ this does not perform the mapping to the register bit, that is
+ handled by _map_to_register_bit.
+ :param port: port to delinearize
+ :param pin: pin (in compacted [0-11] form)
+ :return: pin in appropriate range for the current mapping
+ """
+ port = self._normalize_port_name(port)
+ pins = sorted(self.mapping.map[port])
+ return pins[pin]
+
def _map_to_register_bit(self, port, pin, lift_portb = True):
"""
Maps a pin denoted in current mapping scheme to a corresponding bit in
@@ -565,7 +579,16 @@ class DioControl:
else:
return self.X4XX_GPIO_SRC_USER_APP
- return [get_gpio_src_i(self._map_to_register_bit(bank, i, False)) for i in range(self.X4XX_GPIO_WIDTH)]
+ return [
+ get_gpio_src_i(
+ self._map_to_register_bit(
+ bank,
+ self._delinearize_pin(bank, i),
+ False
+ )
+ )
+ for i in range(self.X4XX_GPIO_WIDTH)
+ ]
def set_gpio_src(self, bank: str, src):
"""
@@ -606,7 +629,11 @@ class DioControl:
self, bank, self.RADIO_DIO_CLASSIC_ATR_CONFIG_REGISTER)
for pin_index, src_name in enumerate(src):
- pin_index = self._map_to_register_bit(bank, pin_index, False)
+ pin_index = self._map_to_register_bit(
+ bank,
+ self._delinearize_pin(bank, pin_index),
+ False
+ )
radio_srcs = [
item for sublist in self.X4XX_GPIO_SRC_RADIO for item in sublist]
if src_name in radio_srcs: