1 # SPDX-FileCopyrightText: 2021 Melissa LeBlanc-Williams for Adafruit Industries
3 # SPDX-License-Identifier: MIT
4 """Tegra T210 pin names"""
7 from Jetson import GPIO
9 GPIO.setmode(GPIO.TEGRA_SOC)
10 GPIO.setwarnings(False) # shh!
14 """Pins dont exist in CPython so...lets make our own!"""
28 def __init__(self, bcm_number):
34 def __eq__(self, other):
35 return self.id == other
37 def init(self, mode=IN, pull=None):
38 """Initialize the Pin"""
42 GPIO.setup(self.id, GPIO.IN)
43 elif mode == self.OUT:
45 GPIO.setup(self.id, GPIO.OUT)
47 raise RuntimeError("Invalid mode for pin: %s" % self.id)
49 if self._mode != self.IN:
50 raise RuntimeError("Cannot set pull resistor on output")
51 if pull == self.PULL_UP:
52 GPIO.setup(self.id, GPIO.IN, pull_up_down=GPIO.PUD_UP)
53 elif pull == self.PULL_DOWN:
54 GPIO.setup(self.id, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
56 raise RuntimeError("Invalid pull for pin: %s" % self.id)
58 def value(self, val=None):
59 """Set or return the Pin Value"""
63 GPIO.output(self.id, val)
67 GPIO.output(self.id, val)
69 raise RuntimeError("Invalid value for pin")
70 return GPIO.input(self.id)
72 # pylint: disable=no-method-argument
76 print("Exiting... \nCleaning up pins")
79 # pylint: enable=no-method-argument
82 # Cannot be used as GPIO
83 SDA = Pin("GEN1_I2C_SDA")
84 SCL = Pin("GEN1_I2C_SCL")
85 SDA_1 = Pin("GEN2_I2C_SDA")
86 SCL_1 = Pin("GEN2_I2C_SCL")
88 # These pins are native to TX1
89 BB03 = Pin("GPIO_X1_AUD")
90 X02 = Pin("MOTION_INT")
91 H07 = Pin("AP_WAKE_NFC")
92 E04 = Pin("DMIC3_CLK")
93 U03 = Pin("UART1_CTS")
94 U02 = Pin("UART1_RTS")
95 B03 = Pin("DAP1_SCLK")
98 B02 = Pin("DAP1_DOUT")
99 P17 = Pin("GPIO_EXP_P17")
100 E05 = Pin("DMIC3_DAT")
101 X00 = Pin("MODEM_WAKE_AP")
102 P16 = Pin("GPIO_EXP_P16")
103 X03 = Pin("ALS_PROX_INT")
105 # These pins are native to NANO
106 S05 = Pin("CAM_AF_EN")
107 Z00 = Pin("GPIO_PZ0")
108 V00 = Pin("LCD_BL_PW")
109 G03 = Pin("UART2_CTS")
110 G02 = Pin("UART2_RTS")
111 J07 = Pin("DAP4_SCLK")
113 J05 = Pin("DAP4_DIN")
114 J06 = Pin("DAP4_DOUT")
116 DD00 = Pin("SPI2_CS1")
117 B07 = Pin("SPI2_CS0")
118 B05 = Pin("SPI2_MISO")
119 B04 = Pin("SPI2_MOSI")
120 B06 = Pin("SPI2_SCK")
122 # These pins are shared across T210
123 BB00 = Pin("AUD_MCLK")
124 C04 = Pin("SPI1_CS1")
125 C03 = Pin("SPI1_CS0")
126 C01 = Pin("SPI1_MISO")
127 C00 = Pin("SPI1_MOSI")
128 C02 = Pin("SPI1_SCK")
129 E06 = Pin("GPIO_PE6")
136 # ordered as spiId, sckId, mosiId, misoId
137 spiPorts = ((0, C02, C00, C01), (1, B06, B04, B05))