From: Ryan L Date: Sat, 17 Sep 2022 19:05:57 +0000 (+0100) Subject: Merge remote-tracking branch 'adafruit/main' X-Git-Tag: 8.23.0~1^2~27 X-Git-Url: https://git.ayoreis.com/Adafruit_Blinka-hackapet.git/commitdiff_plain/c0ed69170cfb86a1aca87bac22d449f30947dd60?hp=18cdaa23d86c471c1e205ef5a80fa8312be52c18 Merge remote-tracking branch 'adafruit/main' --- diff --git a/setup.py b/setup.py index 67ef7ee..51df791 100755 --- a/setup.py +++ b/setup.py @@ -52,7 +52,7 @@ setup( python_requires=">=3.7.0", url="https://github.com/adafruit/Adafruit_Blinka", package_dir={"": "src"}, - packages=find_packages("src"), + packages=find_packages("src") + ["micropython-stubs"], # py_modules lists top-level single file packages to include. # find_packages only finds packages in directories with __init__.py files. py_modules=[ @@ -74,8 +74,10 @@ setup( "adafruit_blinka.microcontroller.bcm283x.pulseio": [ "libgpiod_pulsein", "libgpiod_pulsein64", - ] + ], + "micropython-stubs": ["*.pyi"], }, + include_package_data=True, install_requires=[ "Adafruit-PlatformDetect>=3.13.0", "Adafruit-PureIO>=1.1.7", diff --git a/src/adafruit_blinka/board/bananapi/bpim5.py b/src/adafruit_blinka/board/bananapi/bpim5.py new file mode 100644 index 0000000..6ed4deb --- /dev/null +++ b/src/adafruit_blinka/board/bananapi/bpim5.py @@ -0,0 +1,49 @@ +# SPDX-FileCopyrightText: 2021 Melissa LeBlanc-Williams for Adafruit Industries +# +# SPDX-License-Identifier: MIT +"""Pin definitions for the Banana Pi M5.""" + +from adafruit_blinka.microcontroller.amlogic.s905x3 import pin + +for it in pin.i2cPorts: + globals()["SCL" + str(it[0])] = it[1] + globals()["SDA" + str(it[0])] = it[2] + +SCL = pin.i2cPorts[0][1] +SDA = pin.i2cPorts[0][2] + +SCLK = pin.SPI0_SCLK +MOSI = pin.SPI0_MOSI +MISO = pin.SPI0_MISO +SPI_CS0 = pin.SPI0_CS0 + +# Pinout reference: +# https://wiki.banana-pi.org/Banana_Pi_BPI-M5#BPI-M5_40PIN_GPIO_.28CON2.29 +P3 = pin.GPIOX_17 # I2C_M2_SDA +P5 = pin.GPIOX_18 # I2C_M2_SCL +P7 = pin.GPIOX_5 +P8 = pin.GPIOX_12 # UART_A_TX +P10 = pin.GPIOX_13 # UART_A_RX +P11 = pin.GPIOX_3 +P12 = pin.GPIOA_8 # TDMB_SCLK +P13 = pin.GPIOX_4 +P15 = pin.GPIOX_7 +P16 = pin.GPIOX_0 +P18 = pin.GPIOX_1 +P19 = pin.GPIOX_8 # PCM_DIN +P21 = pin.GPIOX_9 # PCM_DOUT +P22 = pin.GPIOX_2 # SDIO_D2 +P23 = pin.GPIOX_11 # PCM_CLK +P24 = pin.GPIOX_10 # PCM_SYNC +P26 = pin.GPIOX_16 # PWM_E +P27 = pin.GPIOA_14 # I2C_M3_SDA +P28 = pin.GPIOA_15 # I2C_M3_SCL +P29 = pin.GPIOX_14 # UART_A_CTS +P31 = pin.GPIOX_15 # UART_A_RTS +P32 = pin.GPIOX_19 # PWM_B +P33 = pin.GPIOX_6 +P35 = pin.GPIOAO_7 # TDMB_FS +P36 = pin.GPIOH_5 +P37 = pin.GPIOAO_9 # I2S_MCLK +P38 = pin.GPIOAO_10 # TDMB_DIN SPDIF_OUT +P40 = pin.GPIOAO_4 # TDMB_DOUT diff --git a/src/adafruit_blinka/board/lichee_rv.py b/src/adafruit_blinka/board/lichee_rv.py new file mode 100644 index 0000000..c3a57b7 --- /dev/null +++ b/src/adafruit_blinka/board/lichee_rv.py @@ -0,0 +1,48 @@ +# SPDX-FileCopyrightText: 2022 Aleksandr Saiapin for Adafruit Industries +# +# SPDX-License-Identifier: MIT +"""Pin definitions for the Lichee RV Dock.""" + +from adafruit_blinka.microcontroller.allwinner.D1 import pin + +D3 = pin.PB1 +D5 = pin.PB0 +D7 = pin.PG14 +D8 = pin.PB8 +D9 = pin.PD14 +D10 = pin.PB9 +D11 = pin.PG13 +D12 = pin.PG15 +D13 = pin.PD17 +D15 = pin.PD15 +D16 = pin.PD16 +D17 = pin.PD13 +D18 = pin.PD22 +D19 = pin.PD12 +D21 = pin.PD10 +D22 = pin.PD11 +D23 = pin.PD19 +D24 = pin.PD21 +D25 = pin.PD18 +D26 = pin.PD20 +D27 = pin.PD8 +D28 = pin.PD9 +D29 = pin.PD6 +D30 = pin.PD7 +D31 = pin.PD4 +D32 = pin.PD5 +D33 = pin.PD2 +D34 = pin.PD3 +D35 = pin.PD0 +D36 = pin.PD1 +D37 = pin.PE15 +D38 = pin.PE12 +D40 = pin.PE16 + +SDA2 = D3 +SCL2 = D5 +SDA = SDA2 +SCL = SCL2 + +UART0_TX = D8 +UART0_RX = D10 diff --git a/src/adafruit_blinka/board/nvidia/jetson_orin.py b/src/adafruit_blinka/board/nvidia/jetson_orin.py new file mode 100644 index 0000000..19efc34 --- /dev/null +++ b/src/adafruit_blinka/board/nvidia/jetson_orin.py @@ -0,0 +1,42 @@ +# SPDX-FileCopyrightText: 2022 Linh Hoang for NVIDIA +# SPDX-FileCopyrightText: 2022 Melissa LeBlanc-Williams for Adafruit Industries +# +# SPDX-License-Identifier: MIT +"""Pin definitions for Jetson AGX Orin.""" + +from adafruit_blinka.microcontroller.tegra.t234 import pin + +SDA = pin.SDA +SCL = pin.SCL +SDA_1 = pin.SDA_1 +SCL_1 = pin.SCL_1 + +D4 = pin.Q06 +D5 = pin.AA01 +D6 = pin.AA00 +D7 = pin.Z07 +D8 = pin.Z06 +D9 = pin.Z04 +D10 = pin.Z05 +D11 = pin.Z03 +D12 = pin.BB00 +D13 = pin.AA02 +D16 = pin.R05 +D17 = pin.R04 +D18 = pin.H00 +D19 = pin.I02 +D20 = pin.I01 +D21 = pin.I00 +D22 = pin.N01 +D23 = pin.BB01 +D24 = pin.H00 +D25 = pin.P04 +D26 = pin.AA03 +D27 = pin.R00 + +CE1 = D7 +CE0 = D8 +MISO = D9 +MOSI = D10 +SCLK = D11 +SCK = D11 diff --git a/src/adafruit_blinka/board/orangepi/orangepi4.py b/src/adafruit_blinka/board/orangepi/orangepi4.py new file mode 100644 index 0000000..e767a74 --- /dev/null +++ b/src/adafruit_blinka/board/orangepi/orangepi4.py @@ -0,0 +1,65 @@ +# SPDX-FileCopyrightText: 2021 Melissa LeBlanc-Williams for Adafruit Industries +# +# SPDX-License-Identifier: MIT +"""Pin definitions for the Orangepi 4.""" + +from adafruit_blinka.microcontroller.rockchip.rk3399 import pin + +D3 = pin.GPIO2_A7 # /I2C7_SDA/PIN 71/ +D5 = pin.GPIO2_B0 # /I2C7_SCL/PIN 72/ +D7 = pin.GPIO2_B3 # /SPI2_CLK/PIN 75/ +D8 = pin.GPIO4_C4 # /UART2_TXD/PIN 148/ +D10 = pin.GPIO4_C3 # /UART2_RXD/PIN 147/ +D11 = pin.GPIO4_C2 # /PWM0/PIN 146/ +D13 = pin.GPIO4_C6 # /PWM1/PIN 150/ +D15 = pin.GPIO4_C5 # /SPDIF_TX/PIN 149/ +D16 = pin.GPIO4_D2 # /PIN 154/ +D17 = pin.GPIO4_D4 # /PIN 156/ +D19 = pin.GPIO1_B0 # /UART4_TXD/SPI1_TXD/PIN 40/ +D21 = pin.GPIO1_A7 # /UART4_RXD/SPI1_RXD/PIN 39/ +D22 = pin.GPIO4_D5 # /PIN 157/ +D23 = pin.GPIO1_B1 # /SPI1_CLK/PIN 41/ +D24 = pin.GPIO1_B2 # /SPI1_CS/PIN 42/ +D27 = pin.GPIO2_A0 # /I2C2_SDA/PIN 64/ +D28 = pin.GPIO2_A1 # /I2C2_SCL/PIN 65/ +D29 = pin.GPIO2_B2 # /I2C6_SCL/SPI2_TXD/PIN 74/ +D31 = pin.GPIO2_B1 # /I2C6_SDA/SPI2_RXD/PIN 73/ +D32 = pin.GPIO3_C0 # /SPDIF_TX/UART3_CTS/PIN 112/ +D33 = pin.GPIO2_B4 # /SPI2_CS/PIN 76/ +D35 = pin.GPIO4_A5 # /I2S1_LRCK_TX/PIN 133/ +D36 = pin.GPIO4_A4 # /I2S1_LRCK_RX/PIN 132/ +D37 = pin.GPIO4_D6 # /PIN 158/ +D38 = pin.GPIO4_A6 # /I2S1_SDI/PIN 134/ +D40 = pin.GPIO4_A7 # /I2S1_SDO/PIN 135/ + +SDA2 = D27 +SCL2 = D28 + +SDA6 = D31 +SCL6 = D29 + +SDA7 = D3 +SCL7 = D5 + +SDA = SDA2 +SCL = SCL2 + +SCLK = D7 +MOSI = D29 +MISO = D31 +CS = D33 +SCK = SCLK + +UART2_TX = D8 +UART2_RX = D10 + +UART4_TX = D19 +UART4_RX = D21 + +UART_TX = UART2_TX +UART_RX = UART2_RX + +PWM0 = pin.PWM0 +PWM1 = pin.PWM1 + +ADC_IN0 = pin.ADC_IN0 diff --git a/src/adafruit_blinka/microcontroller/allwinner/D1/__init__.py b/src/adafruit_blinka/microcontroller/allwinner/D1/__init__.py new file mode 100644 index 0000000..78ab2b7 --- /dev/null +++ b/src/adafruit_blinka/microcontroller/allwinner/D1/__init__.py @@ -0,0 +1,4 @@ +# SPDX-FileCopyrightText: 2022 Aleksandr Saiapin for Adafruit Industries +# +# SPDX-License-Identifier: MIT +"""Definition for the AllWinner D1 chip""" diff --git a/src/adafruit_blinka/microcontroller/allwinner/D1/pin.py b/src/adafruit_blinka/microcontroller/allwinner/D1/pin.py new file mode 100644 index 0000000..f545ca6 --- /dev/null +++ b/src/adafruit_blinka/microcontroller/allwinner/D1/pin.py @@ -0,0 +1,112 @@ +# SPDX-FileCopyrightText: 2022 Aleksandr Saiapin for Adafruit Industries +# +# SPDX-License-Identifier: MIT +"""Allwinner D1 pin names""" +from adafruit_blinka.microcontroller.generic_linux.libgpiod_pin import Pin + +PB0 = Pin(32) +TWI2_SCL = PB0 +PB1 = Pin(33) +TWI2_SDA = PB1 +PB2 = Pin(34) +PB3 = Pin(35) +PB4 = Pin(36) +PB5 = Pin(37) +PB6 = Pin(38) +PB7 = Pin(39) +PB8 = Pin(40) +UART0_TX = PB8 +PB9 = Pin(41) +UART0_RX = PB9 +PB10 = Pin(42) +PB11 = Pin(43) +PB12 = Pin(44) +PC0 = Pin(64) +UART2_TX = PC0 +PC1 = Pin(65) +UART2_RX = PC1 +PC2 = Pin(66) +SPI0_SCLK = PC2 +PC3 = Pin(67) +SPI0_CS = PC3 +PC4 = Pin(68) +SPI0_MOSI = PC4 +PC5 = Pin(69) +SPI0_MISO = PC5 +PC6 = Pin(70) +SPI0_WP = PC6 +PC7 = Pin(71) +SPI0_HOLD = PC7 +PD0 = Pin(96) +PD1 = Pin(97) +PD2 = Pin(98) +PD3 = Pin(99) +PD4 = Pin(100) +PD5 = Pin(101) +PD6 = Pin(102) +PD7 = Pin(103) +PD8 = Pin(104) +PD9 = Pin(105) +PD10 = Pin(106) +PD11 = Pin(107) +PD12 = Pin(108) +PD13 = Pin(109) +PD14 = Pin(110) +PD15 = Pin(111) +PD16 = Pin(112) +PD17 = Pin(113) +PD18 = Pin(114) +PD19 = Pin(115) +PD20 = Pin(116) +PD21 = Pin(117) +PD22 = Pin(118) +PE0 = Pin(128) +PE1 = Pin(129) +PE2 = Pin(130) +PE3 = Pin(131) +PE4 = Pin(132) +PE5 = Pin(133) +PE6 = Pin(134) +PE7 = Pin(135) +PE8 = Pin(136) +PE9 = Pin(137) +PE10 = Pin(138) +PE11 = Pin(139) +PE12 = Pin(140) +PE13 = Pin(141) +PE14 = Pin(142) +TWI1_SCL = PE14 +PE15 = Pin(143) +TWI1_SDA = PE15 +PE16 = Pin(144) +TWI3_SCL = PE16 +PE17 = Pin(145) +TWI3_SDA = PE17 +PG6 = Pin(198) +UART1_TX = PG6 +PG7 = Pin(199) +UART1_RX = PG7 +PG8 = Pin(200) +UART1_RTS = PG8 +PG9 = Pin(201) +UART1_CTS = PG9 +PG10 = Pin(202) +PG11 = Pin(203) +PG12 = Pin(204) +PG13 = Pin(205) +PG14 = Pin(206) +PG15 = Pin(207) +PG16 = Pin(208) +PG17 = Pin(209) +PG18 = Pin(210) + +i2cPorts = ( + (2, TWI2_SCL, TWI2_SDA), + (3, TWI3_SCL, TWI3_SDA), +) +uartPorts = ( + (0, UART0_TX, UART0_RX), + (1, UART1_TX, UART1_RX), + (2, UART2_TX, UART2_RX), +) +spiPorts = ((0, SPI0_SCLK, SPI0_MOSI, SPI0_MISO),) diff --git a/src/adafruit_blinka/microcontroller/amlogic/meson_g12_common/pin.py b/src/adafruit_blinka/microcontroller/amlogic/meson_g12_common/pin.py index d920b1f..41cf8f2 100644 --- a/src/adafruit_blinka/microcontroller/amlogic/meson_g12_common/pin.py +++ b/src/adafruit_blinka/microcontroller/amlogic/meson_g12_common/pin.py @@ -11,6 +11,8 @@ Linux kernel 5.4.y (mainline) linux/arch/arm64/boot/dts/amlogic/meson-g12-common.dtsi """ +from typing import Optional +import os import re import gpiod from adafruit_blinka.microcontroller.generic_linux.libgpiod_pin import Pin @@ -110,18 +112,18 @@ UART1_RX = GPIOX_13 uartPorts = ((1, UART1_TX, UART1_RX),) -def get_dts_alias(device: str) -> str: +def get_dts_alias(device: str) -> Optional[str]: """Get the Device Tree Alias""" uevent_path = "/sys/bus/platform/devices/" + device + "/uevent" - with open(uevent_path, "r", encoding="utf-8") as fd: - pattern = r"^OF_ALIAS_0=(.*)$" - uevent = fd.read().split("\n") - for line in uevent: - match = re.search(pattern, line) - if match: - return match.group(1).upper() - - return None + if os.path.exists(uevent_path): + with open(uevent_path, "r", encoding="utf-8") as fd: + pattern = r"^OF_ALIAS_0=(.*)$" + uevent = fd.read().split("\n") + for line in uevent: + match = re.search(pattern, line) + if match: + return match.group(1).upper() + return None # ordered as i2cId, sclId, sdaId diff --git a/src/adafruit_blinka/microcontroller/tegra/t234/__init__.py b/src/adafruit_blinka/microcontroller/tegra/t234/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/adafruit_blinka/microcontroller/tegra/t234/pin.py b/src/adafruit_blinka/microcontroller/tegra/t234/pin.py new file mode 100644 index 0000000..f2f3332 --- /dev/null +++ b/src/adafruit_blinka/microcontroller/tegra/t234/pin.py @@ -0,0 +1,119 @@ +# SPDX-FileCopyrightText: 2022 Linh Hoang for NVIDIA +# SPDX-FileCopyrightText: 2022 Melissa LeBlanc-Williams for Adafruit Industries +# +# SPDX-License-Identifier: MIT + +"""Tegra T234 pin names""" +import atexit +from Jetson import GPIO + +GPIO.setmode(GPIO.TEGRA_SOC) +GPIO.setwarnings(False) # shh! + + +class Pin: + """Pins dont exist in CPython so...lets make our own!""" + + IN = 0 + OUT = 1 + LOW = 0 + HIGH = 1 + PULL_NONE = 0 + PULL_UP = 1 + PULL_DOWN = 2 + + id = None + _value = LOW + _mode = IN + + def __init__(self, bcm_number): + self.id = bcm_number + + def __repr__(self): + return str(self.id) + + def __eq__(self, other): + return self.id == other + + def init(self, mode=IN, pull=None): + """Initialize the Pin""" + if mode is not None: + if mode == self.IN: + self._mode = self.IN + GPIO.setup(self.id, GPIO.IN) + elif mode == self.OUT: + self._mode = self.OUT + GPIO.setup(self.id, GPIO.OUT) + else: + raise RuntimeError("Invalid mode for pin: %s" % self.id) + if pull is not None: + if self._mode != self.IN: + raise RuntimeError("Cannot set pull resistor on output") + if pull == self.PULL_UP: + GPIO.setup(self.id, GPIO.IN, pull_up_down=GPIO.PUD_UP) + elif pull == self.PULL_DOWN: + GPIO.setup(self.id, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) + else: + raise RuntimeError("Invalid pull for pin: %s" % self.id) + + def value(self, val=None): + """Set or return the Pin Value""" + if val is not None: + if val == self.LOW: + self._value = val + GPIO.output(self.id, val) + return None + if val == self.HIGH: + self._value = val + GPIO.output(self.id, val) + return None + raise RuntimeError("Invalid value for pin") + return GPIO.input(self.id) + + # pylint: disable=no-method-argument + @atexit.register + def cleanup(): + """Clean up pins""" + print("Exiting... \nCleaning up pins") + GPIO.cleanup() + + # pylint: enable=no-method-argument + + +# Cannot be used as GPIO +SDA = Pin("GP16_I2C8_DAT") # I2C4 +SCL = Pin("GP81_I2C9_CLK") +SDA_1 = Pin("GP14_I2C2_DAT") # I2C2 +SCL_1 = Pin("GP13_I2C2_CLK") + +# Jetson AGX Orin +Q06 = Pin("GP66") +R04 = Pin("GP72_UART1_RTS_N") +H07 = Pin("GP122") +R00 = Pin("GP68") +N01 = Pin("GP88_PWM1") +BB00 = Pin("GP25") +H00 = Pin("GP115") +Z05 = Pin("GP49_SPI1_MOSI") +Z04 = Pin("GP48_SPI1_MISO") +P04 = Pin("GP56") +Z03 = Pin("GP47_SPI1_CLK") +Z06 = Pin("GP50_SPI1_CS0_N") +Z07 = Pin("GP51_SPI1_CS1_N") +AA01 = Pin("GP18_CAN0_DIN") +AA00 = Pin("GP17_CAN0_DOUT") +BB01 = Pin("GP26") +AA02 = Pin("GP19_CAN1_DOUT") +I02 = Pin("GP125") +R05 = Pin("GP73_UART1_CTS_N") +AA03 = Pin("GP20_CAN1_DIN") +I01 = Pin("GP124") +I00 = Pin("GP123") + +i2cPorts = ( + (7, SCL, SDA), + (1, SCL_1, SDA_1), +) + +# ordered as spiId, sckId, mosiId, misoId +spiPorts = ((0, Z03, Z05, Z04),) diff --git a/src/board.py b/src/board.py index 3a51e5c..0b8d1a3 100644 --- a/src/board.py +++ b/src/board.py @@ -121,9 +121,18 @@ elif board_id == ap_board.ORANGE_PI_ZERO_2: elif board_id == ap_board.ORANGE_PI_3: from adafruit_blinka.board.orangepi.orangepi3 import * +elif board_id == ap_board.ORANGE_PI_4: + from adafruit_blinka.board.orangepi.orangepi4 import * + +elif board_id == ap_board.ORANGE_PI_4_LTS: + from adafruit_blinka.board.orangepi.orangepi4 import * + elif board_id == ap_board.BANANA_PI_M2_ZERO: from adafruit_blinka.board.bananapi.bpim2zero import * +elif board_id == ap_board.BANANA_PI_M5: + from adafruit_blinka.board.bananapi.bpim5 import * + elif board_id == ap_board.GIANT_BOARD: from adafruit_blinka.board.giantboard import * @@ -145,6 +154,9 @@ elif board_id == ap_board.JETSON_NANO: elif board_id == ap_board.JETSON_NX: from adafruit_blinka.board.nvidia.jetson_nx import * +elif board_id == ap_board.JETSON_AGX_ORIN: + from adafruit_blinka.board.nvidia.jetson_orin import * + elif board_id == ap_board.CLARA_AGX_XAVIER: from adafruit_blinka.board.nvidia.clara_agx_xavier import * @@ -265,6 +277,9 @@ elif board_id == ap_board.MACROPAD_U2IF: elif board_id == ap_board.QT2040_TRINKEY_U2IF: from adafruit_blinka.board.qt2040_trinkey_u2if import * +elif board_id == ap_board.LICHEE_RV: + from adafruit_blinka.board.lichee_rv import * + elif "sphinx" in sys.modules: pass diff --git a/src/digitalio.py b/src/digitalio.py index 6b89bf0..b770b8a 100644 --- a/src/digitalio.py +++ b/src/digitalio.py @@ -34,6 +34,8 @@ elif detector.chip.T186: from adafruit_blinka.microcontroller.tegra.t186.pin import Pin elif detector.chip.T194: from adafruit_blinka.microcontroller.tegra.t194.pin import Pin +elif detector.chip.T234: + from adafruit_blinka.microcontroller.tegra.t234.pin import Pin elif detector.chip.S905: from adafruit_blinka.microcontroller.amlogic.s905.pin import Pin elif detector.chip.S905X3: @@ -98,6 +100,8 @@ elif detector.chip.H616: from adafruit_blinka.microcontroller.allwinner.h616.pin import Pin elif detector.board.pico_u2if: from adafruit_blinka.microcontroller.rp2040_u2if.pin import Pin +elif detector.board.LICHEE_RV: + from adafruit_blinka.microcontroller.allwinner.D1.pin import Pin elif ( detector.board.feather_u2if or detector.board.qtpy_u2if diff --git a/src/microcontroller/__init__.py b/src/microcontroller/__init__.py index 6865c4e..6bc4587 100644 --- a/src/microcontroller/__init__.py +++ b/src/microcontroller/__init__.py @@ -64,6 +64,8 @@ elif chip_id == ap_chip.T186: from adafruit_blinka.microcontroller.tegra.t186 import * elif chip_id == ap_chip.T194: from adafruit_blinka.microcontroller.tegra.t194 import * +elif chip_id == ap_chip.T234: + from adafruit_blinka.microcontroller.tegra.t234 import * elif chip_id == ap_chip.S905: from adafruit_blinka.microcontroller.amlogic.s905 import * elif chip_id == ap_chip.S905X3: @@ -122,6 +124,8 @@ elif chip_id == ap_chip.MT8167: from adafruit_blinka.microcontroller.mt8167 import * elif chip_id == ap_chip.RP2040_U2IF: from adafruit_blinka.microcontroller.rp2040_u2if import * +elif chip_id == ap_chip.D1_RISCV: + from adafruit_blinka.microcontroller.allwinner.D1 import * elif chip_id == ap_chip.GENERIC_X86: print("WARNING: GENERIC_X86 is not fully supported. Some features may not work.") elif chip_id is None: diff --git a/src/microcontroller/pin.py b/src/microcontroller/pin.py index 79627c0..b4d595c 100644 --- a/src/microcontroller/pin.py +++ b/src/microcontroller/pin.py @@ -51,6 +51,8 @@ elif chip_id == ap_chip.T186: from adafruit_blinka.microcontroller.tegra.t186.pin import * elif chip_id == ap_chip.T194: from adafruit_blinka.microcontroller.tegra.t194.pin import * +elif chip_id == ap_chip.T234: + from adafruit_blinka.microcontroller.tegra.t234.pin import * elif chip_id == ap_chip.S905: from adafruit_blinka.microcontroller.amlogic.s905.pin import * elif chip_id == ap_chip.S905X3: @@ -105,6 +107,8 @@ elif chip_id == ap_chip.MT8167: from adafruit_blinka.microcontroller.mt8167.pin import * elif chip_id == ap_chip.RP2040_U2IF: from adafruit_blinka.microcontroller.rp2040_u2if.pin import * +elif chip_id == ap_chip.D1_RISCV: + from adafruit_blinka.microcontroller.allwinner.D1.pin import * elif "sphinx" in sys.modules: # pylint: disable=unused-import from adafruit_blinka.microcontroller.generic_micropython import Pin diff --git a/src/micropython-stubs/micropython.pyi b/src/micropython-stubs/micropython.pyi new file mode 100644 index 0000000..33dd6a9 --- /dev/null +++ b/src/micropython-stubs/micropython.pyi @@ -0,0 +1,25 @@ +# SPDX-FileCopyrightText: 2021 Melissa LeBlanc-Williams for Adafruit Industries +# +# SPDX-License-Identifier: MIT +""" +`micropython` - MicroPython Specific Decorator Functions +======================================================== + +* Author(s): cefn +""" + +from typing import Callable, TypeVar, Any, NoReturn + +Fun = TypeVar("Fun", bound=Callable[..., Any]) + +def const(x: int) -> int: + "Emulate making a constant" + +def native(f: Fun) -> Fun: + "Emulate making a native" + +def viper(f: Fun) -> NoReturn: + "User is attempting to use a viper code emitter" + +def asm_thumb(f: Fun) -> NoReturn: + "User is attempting to use an inline assembler" diff --git a/src/usb_hid.py b/src/usb_hid.py index 113ac83..38e19b1 100644 --- a/src/usb_hid.py +++ b/src/usb_hid.py @@ -60,7 +60,7 @@ class Device: """ report_id = report_id or self.report_ids[0] device_path = self.get_device_path(report_id) - with open(device_path, "rb+", encoding="utf-8") as fd: + with open(device_path, "rb+") as fd: if report_id > 0: report = bytearray(report_id.to_bytes(1, "big")) + report fd.write(report) @@ -82,7 +82,7 @@ class Device: Return `None` if nothing received. """ device_path = self.get_device_path(report_id or self.report_ids[0]) - with open(device_path, "rb+", encoding="utf-8") as fd: + with open(device_path, "rb+") as fd: os.set_blocking(fd.fileno(), False) report = fd.read(self.out_report_lengths[0]) if report is not None: