3 sys.path.append("/opt/nvidia/jetson-gpio/lib/python")
4 sys.path.append("/opt/nvidia/jetson-gpio/lib/python/Jetson/GPIO")
5 import Jetson.GPIO as GPIO
6 GPIO.setmode(GPIO.TEGRA_SOC)
7 GPIO.setwarnings(False) # shh!
9 # Pins dont exist in CPython so...lets make our own!
23 def __init__(self, bcm_number):
29 def __eq__(self, other):
30 return self.id == other
32 def init(self, mode=IN, pull=None):
36 GPIO.setup(self.id, GPIO.IN)
37 elif mode == self.OUT:
39 GPIO.setup(self.id, GPIO.OUT)
41 raise RuntimeError("Invalid mode for pin: %s" % self.id)
43 if self._mode != self.IN:
44 raise RuntimeError("Cannot set pull resistor on output")
45 if pull == self.PULL_UP:
46 GPIO.setup(self.id, GPIO.IN, pull_up_down=GPIO.PUD_UP)
47 elif pull == self.PULL_DOWN:
48 GPIO.setup(self.id, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
50 raise RuntimeError("Invalid pull for pin: %s" % self.id)
52 def value(self, val=None):
56 GPIO.output(self.id, val)
57 elif val == self.HIGH:
59 GPIO.output(self.id, val)
61 raise RuntimeError("Invalid value for pin")
63 return GPIO.input(self.id)
67 print("Exiting... \nCleaning up pins")
70 # Cannot be used as GPIO
71 SDA = Pin('GEN1_I2C_SDA')
72 SCL = Pin('GEN1_I2C_SCL')
73 SDA_1 = Pin('GEN2_I2C_SDA')
74 SCL_1 = Pin('GEN2_I2C_SCL')
76 # These pins are native to TX1
77 BB03 = Pin('GPIO_X1_AUD')
78 X02 = Pin('MOTION_INT')
79 H07 = Pin('AP_WAKE_NFC')
80 E04 = Pin('DMIC3_CLK')
81 U03 = Pin('UART1_CTS')
82 U02 = Pin('UART1_RTS')
83 B03 = Pin('DAP1_SCLK')
86 B02 = Pin('DAP1_DOUT')
87 P17 = Pin('GPIO_EXP_P17')
88 E05 = Pin('DMIC3_DAT')
89 X00 = Pin('MODEM_WAKE_AP')
90 P16 = Pin('GPIO_EXP_P16')
91 X03 = Pin('ALS_PROX_INT')
93 # These pins are native to NANO
94 S05 = Pin('CAM_AF_EN')
96 V00 = Pin('LCD_BL_PW')
97 G03 = Pin('UART2_CTS')
98 G02 = Pin('UART2_RTS')
99 J07 = Pin('DAP4_SCLK')
101 J05 = Pin('DAP4_DIN')
102 J06 = Pin('DAP4_DOUT')
104 DD00 = Pin('SPI2_CS1')
105 B07 = Pin('SPI2_CS0')
106 B05 = Pin('SPI2_MISO')
107 B04 = Pin('SPI2_MOSI')
108 B06 = Pin('SPI2_SCK')
110 # These pins are shared across T210
111 BB00 = Pin('AUD_MCLK')
112 C04 = Pin('SPI1_CS1')
113 C03 = Pin('SPI1_CS0')
114 C01 = Pin('SPI1_MISO')
115 C00 = Pin('SPI1_MOSI')
116 C02 = Pin('SPI1_SCK')
117 E06 = Pin('GPIO_PE6')
120 (0, SCL, SDA), (1, SCL_1, SDA_1),
123 # ordered as spiId, sckId, mosiId, misoId
124 spiPorts = ((0, C02, C00, C01), (1, B06, B04, B05))