3 import Jetson.GPIO as GPIO
 
   4 GPIO.setmode(GPIO.TEGRA_SOC)
 
   5 GPIO.setwarnings(False)   # shh!
 
   7 # Pins dont exist in CPython so...lets make our own!
 
  21     def __init__(self, bcm_number):
 
  27     def __eq__(self, other):
 
  28         return self.id == other
 
  30     def init(self, mode=IN, pull=None):
 
  34                 GPIO.setup(self.id, GPIO.IN)
 
  35             elif mode == self.OUT:
 
  37                 GPIO.setup(self.id, GPIO.OUT)
 
  39                 raise RuntimeError("Invalid mode for pin: %s" % self.id)
 
  41             if self._mode != self.IN:
 
  42                 raise RuntimeError("Cannot set pull resistor on output")
 
  43             if pull == self.PULL_UP:
 
  44                 GPIO.setup(self.id, GPIO.IN, pull_up_down=GPIO.PUD_UP)
 
  45             elif pull == self.PULL_DOWN:
 
  46                 GPIO.setup(self.id, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
 
  48                 raise RuntimeError("Invalid pull for pin: %s" % self.id)
 
  50     def value(self, val=None):
 
  54                 GPIO.output(self.id, val)
 
  55             elif val == self.HIGH:
 
  57                 GPIO.output(self.id, val)
 
  59                 raise RuntimeError("Invalid value for pin")
 
  61             return GPIO.input(self.id)
 
  65         print("Exiting... \nCleaning up pins")
 
  68 # Cannot be used as GPIO
 
  69 SDA = Pin('DP_AUX_CH3_N')
 
  70 SCL = Pin('DP_AUX_CH3_P')
 
  71 SDA_1 = Pin('GEN2_I2C_SDA')
 
  72 SCL_1 = Pin('GEN2_I2C_SCL')
 
  75 Q06 = Pin('SOC_GPIO42')
 
  76 AA03 = Pin('CAN0_DIN')
 
  77 AA02 = Pin('CAN0_DOUT')
 
  79 AA00 = Pin('CAN1_DOUT')
 
  80 H07 = Pin('DAP2_SCLK')
 
  83 I00 = Pin('DAP2_DOUT')
 
  84 BB00 = Pin('CAN1_STB')
 
  85 H00 = Pin('SOC_GPIO12')
 
  86 Q01 = Pin('SOC_GPIO21')
 
  87 AA01 = Pin('CAN1_DIN')
 
  91 T05 = Pin('DAP5_SCLK')
 
  93 CC04 = Pin('TOUCH_CLK')
 
  94 Y04 = Pin('SPI3_CS1_N')
 
  95 Y03 = Pin('SPI3_CS0_N')
 
  96 Y01 = Pin('SPI3_MISO')
 
  97 Q05 = Pin('SOC_GPIO41')
 
  98 Q06 = Pin('SOC_GPIO42')
 
 100 Y02 = Pin('SPI3_MOSI')
 
 101 T07 = Pin('DAP5_DIN')
 
 102 T06 = Pin('DAP5_DOUT')
 
 105 N01 = Pin('SOC_GPIO54')
 
 106 R00 = Pin('SOC_GPIO44')
 
 107 R04 = Pin('UART1_RTS')
 
 108 R05 = Pin('UART1_CTS')
 
 109 Z03 = Pin('SPI1_SCK')
 
 110 Z04 = Pin('SPI1_MISO')
 
 111 Z05 = Pin('SPI1_MOSI')
 
 112 Z06 = Pin('SPI1_CS0_N')
 
 113 Z07 = Pin('SPI1_CS1_N')
 
 116     (8, SCL, SDA), (1, SCL_1, SDA_1),
 
 119 # ordered as spiId, sckId, mosiId, misoId
 
 120 spiPorts = ((0, Z03, Z05, Z04), )