1 """Tegra T210 pin names"""
4 import Jetson.GPIO as GPIO
6 GPIO.setmode(GPIO.TEGRA_SOC)
7 GPIO.setwarnings(False) # shh!
11 """Pins dont exist in CPython so...lets make our own!"""
25 def __init__(self, bcm_number):
31 def __eq__(self, other):
32 return self.id == other
34 def init(self, mode=IN, pull=None):
35 """Initialize the Pin"""
39 GPIO.setup(self.id, GPIO.IN)
40 elif mode == self.OUT:
42 GPIO.setup(self.id, GPIO.OUT)
44 raise RuntimeError("Invalid mode for pin: %s" % self.id)
46 if self._mode != self.IN:
47 raise RuntimeError("Cannot set pull resistor on output")
48 if pull == self.PULL_UP:
49 GPIO.setup(self.id, GPIO.IN, pull_up_down=GPIO.PUD_UP)
50 elif pull == self.PULL_DOWN:
51 GPIO.setup(self.id, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
53 raise RuntimeError("Invalid pull for pin: %s" % self.id)
55 def value(self, val=None):
56 """Set or return the Pin Value"""
60 GPIO.output(self.id, val)
64 GPIO.output(self.id, val)
66 raise RuntimeError("Invalid value for pin")
67 return GPIO.input(self.id)
69 # pylint: disable=no-method-argument
73 print("Exiting... \nCleaning up pins")
76 # pylint: enable=no-method-argument
79 # Cannot be used as GPIO
80 SDA = Pin("GEN1_I2C_SDA")
81 SCL = Pin("GEN1_I2C_SCL")
82 SDA_1 = Pin("GEN2_I2C_SDA")
83 SCL_1 = Pin("GEN2_I2C_SCL")
85 # These pins are native to TX1
86 BB03 = Pin("GPIO_X1_AUD")
87 X02 = Pin("MOTION_INT")
88 H07 = Pin("AP_WAKE_NFC")
89 E04 = Pin("DMIC3_CLK")
90 U03 = Pin("UART1_CTS")
91 U02 = Pin("UART1_RTS")
92 B03 = Pin("DAP1_SCLK")
95 B02 = Pin("DAP1_DOUT")
96 P17 = Pin("GPIO_EXP_P17")
97 E05 = Pin("DMIC3_DAT")
98 X00 = Pin("MODEM_WAKE_AP")
99 P16 = Pin("GPIO_EXP_P16")
100 X03 = Pin("ALS_PROX_INT")
102 # These pins are native to NANO
103 S05 = Pin("CAM_AF_EN")
104 Z00 = Pin("GPIO_PZ0")
105 V00 = Pin("LCD_BL_PW")
106 G03 = Pin("UART2_CTS")
107 G02 = Pin("UART2_RTS")
108 J07 = Pin("DAP4_SCLK")
110 J05 = Pin("DAP4_DIN")
111 J06 = Pin("DAP4_DOUT")
113 DD00 = Pin("SPI2_CS1")
114 B07 = Pin("SPI2_CS0")
115 B05 = Pin("SPI2_MISO")
116 B04 = Pin("SPI2_MOSI")
117 B06 = Pin("SPI2_SCK")
119 # These pins are shared across T210
120 BB00 = Pin("AUD_MCLK")
121 C04 = Pin("SPI1_CS1")
122 C03 = Pin("SPI1_CS0")
123 C01 = Pin("SPI1_MISO")
124 C00 = Pin("SPI1_MOSI")
125 C02 = Pin("SPI1_SCK")
126 E06 = Pin("GPIO_PE6")
133 # ordered as spiId, sckId, mosiId, misoId
134 spiPorts = ((0, C02, C00, C01), (1, B06, B04, B05))