1 """Tegra T194 pin names"""
 
   3 import Jetson.GPIO as GPIO
 
   5 GPIO.setmode(GPIO.TEGRA_SOC)
 
   6 GPIO.setwarnings(False)  # shh!
 
  10     """Pins dont exist in CPython so...lets make our own!"""
 
  24     def __init__(self, bcm_number):
 
  30     def __eq__(self, other):
 
  31         return self.id == other
 
  33     def init(self, mode=IN, pull=None):
 
  34         """Initialize the Pin"""
 
  38                 GPIO.setup(self.id, GPIO.IN)
 
  39             elif mode == self.OUT:
 
  41                 GPIO.setup(self.id, GPIO.OUT)
 
  43                 raise RuntimeError("Invalid mode for pin: %s" % self.id)
 
  45             if self._mode != self.IN:
 
  46                 raise RuntimeError("Cannot set pull resistor on output")
 
  47             if pull == self.PULL_UP:
 
  48                 GPIO.setup(self.id, GPIO.IN, pull_up_down=GPIO.PUD_UP)
 
  49             elif pull == self.PULL_DOWN:
 
  50                 GPIO.setup(self.id, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
 
  52                 raise RuntimeError("Invalid pull for pin: %s" % self.id)
 
  54     def value(self, val=None):
 
  55         """Set or return the Pin Value"""
 
  59                 GPIO.output(self.id, val)
 
  63                 GPIO.output(self.id, val)
 
  65             raise RuntimeError("Invalid value for pin")
 
  66         return GPIO.input(self.id)
 
  68     # pylint: disable=no-method-argument
 
  72         print("Exiting... \nCleaning up pins")
 
  75     # pylint: enable=no-method-argument
 
  78 # Cannot be used as GPIO
 
  79 SDA = Pin("DP_AUX_CH3_N")
 
  80 SCL = Pin("DP_AUX_CH3_P")
 
  81 SDA_1 = Pin("GEN2_I2C_SDA")
 
  82 SCL_1 = Pin("GEN2_I2C_SCL")
 
  85 Q06 = Pin("SOC_GPIO42")
 
  86 AA03 = Pin("CAN0_DIN")
 
  87 AA02 = Pin("CAN0_DOUT")
 
  89 AA00 = Pin("CAN1_DOUT")
 
  90 H07 = Pin("DAP2_SCLK")
 
  93 I00 = Pin("DAP2_DOUT")
 
  94 BB00 = Pin("CAN1_STB")
 
  95 H00 = Pin("SOC_GPIO12")
 
  96 Q01 = Pin("SOC_GPIO21")
 
  97 AA01 = Pin("CAN1_DIN")
 
 100 S04 = Pin("AUD_MCLK")
 
 101 T05 = Pin("DAP5_SCLK")
 
 102 Y00 = Pin("SPI3_SCK")
 
 103 CC04 = Pin("TOUCH_CLK")
 
 104 Y04 = Pin("SPI3_CS1_N")
 
 105 Y03 = Pin("SPI3_CS0_N")
 
 106 Y01 = Pin("SPI3_MISO")
 
 107 Q05 = Pin("SOC_GPIO41")
 
 108 Q06 = Pin("SOC_GPIO42")
 
 110 Y02 = Pin("SPI3_MOSI")
 
 111 T07 = Pin("DAP5_DIN")
 
 112 T06 = Pin("DAP5_DOUT")
 
 114 # Clara AGX Xavier only
 
 115 P04 = Pin("SOC_GPIO04")
 
 118 N01 = Pin("SOC_GPIO54")
 
 119 R00 = Pin("SOC_GPIO44")
 
 120 R04 = Pin("UART1_RTS")
 
 121 R05 = Pin("UART1_CTS")
 
 122 Z03 = Pin("SPI1_SCK")
 
 123 Z04 = Pin("SPI1_MISO")
 
 124 Z05 = Pin("SPI1_MOSI")
 
 125 Z06 = Pin("SPI1_CS0_N")
 
 126 Z07 = Pin("SPI1_CS1_N")
 
 133 # ordered as spiId, sckId, mosiId, misoId
 
 134 spiPorts = ((0, Z03, Z05, Z04),)