From 2152c18a1e8ec87e45ca2a273819fbde777d4415 Mon Sep 17 00:00:00 2001 From: August <2819763+Dangku@users.noreply.github.com> Date: Sat, 31 Aug 2024 23:43:17 +0800 Subject: [PATCH 01/19] support allwinner h618 chip and bananapi m4berry and m4zero board --- .../board/bananapi/bpim4berry.py | 71 +++++++++ .../board/bananapi/bpim4zero.py | 71 +++++++++ .../allwinner/h618/__init__.py | 4 + .../microcontroller/allwinner/h618/pin.py | 135 ++++++++++++++++++ src/board.py | 6 + src/digitalio.py | 2 + src/microcontroller/__init__.py | 2 + src/microcontroller/pin.py | 2 + 8 files changed, 293 insertions(+) create mode 100644 src/adafruit_blinka/board/bananapi/bpim4berry.py create mode 100644 src/adafruit_blinka/board/bananapi/bpim4zero.py create mode 100644 src/adafruit_blinka/microcontroller/allwinner/h618/__init__.py create mode 100644 src/adafruit_blinka/microcontroller/allwinner/h618/pin.py diff --git a/src/adafruit_blinka/board/bananapi/bpim4berry.py b/src/adafruit_blinka/board/bananapi/bpim4berry.py new file mode 100644 index 00000000..cfed3a31 --- /dev/null +++ b/src/adafruit_blinka/board/bananapi/bpim4berry.py @@ -0,0 +1,71 @@ +# SPDX-FileCopyrightText: 2021 Melissa LeBlanc-Williams for Adafruit Industries +# +# SPDX-License-Identifier: MIT +"""Pin definitions for the Banana Pi M4 Berry.""" + +from adafruit_blinka.microcontroller.allwinner.h618 import pin + +# I2C +I2C3_SCL = pin.TWI3_SCL +I2C3_SDA = pin.TWI3_SDA +I2C4_SCL = pin.TWI4_SCL +I2C4_SDA = pin.TWI4_SDA + +# Default I2C +SCL = I2C4_SCL +SDA = I2C4_SDA + +# UART +UART1_TX = pin.UART1_TX +UART1_RX = pin.UART1_RX +UART5_TX = pin.UART5_TX +UART5_RX = pin.UART5_RX + +# Default UART +TX = UART1_TX +RX = UART1_RX +TXD = UART1_TX +RXD = UART1_RX + +# SPI +SPI1_MOSI = pin.SPI1_MOSI +SPI1_MISO = pin.SPI1_MISO +SPI1_SCLK = pin.SPI1_SCLK +SPI1_CS0 = pin.SPI1_CS0 + +# Default SPI +MOSI = SPI1_MOSI +MISO = SPI1_MISO +SCLK = SPI1_SCLK +CS = SPI1_CS0 + +# Pinout reference: +# https://wiki.banana-pi.org/Banana_Pi_BPI-M4_Berry#BPI-M4_Berry_40-pin_header +PG16 = pin.PG16 +PG15 = pin.PG15 +PG19 = pin.PG19 +PG6 = pin.PG6 +PG7 = pin.PG7 +PH2 = pin.PH2 +PG11 = pin.PG11 +PH3 = pin.PH3 +PG2 = pin.PG2 +PG8 = pin.PG8 +PG9 = pin.PG9 +PH7 = pin.PH7 +PH8 = pin.PH8 +PG1 = pin.PG1 +PH6 = pin.PH6 +PH5 = pin.PH5 +PH9 = pin.PH9 +PG18 = pin.PG18 +PG17 = pin.PG17 +PG3 = pin.PG3 +PG4 = pin.PG4 +PG0 = pin.PG0 +PG5 = pin.PG5 +PG12 = pin.PG12 +PH4 = pin.PH4 +PG10 = pin.PG10 +PG14 = pin.PG14 +PG13 = pin.PG13 diff --git a/src/adafruit_blinka/board/bananapi/bpim4zero.py b/src/adafruit_blinka/board/bananapi/bpim4zero.py new file mode 100644 index 00000000..bd2e553c --- /dev/null +++ b/src/adafruit_blinka/board/bananapi/bpim4zero.py @@ -0,0 +1,71 @@ +# SPDX-FileCopyrightText: 2021 Melissa LeBlanc-Williams for Adafruit Industries +# +# SPDX-License-Identifier: MIT +"""Pin definitions for the Banana Pi M4 Zero.""" + +from adafruit_blinka.microcontroller.allwinner.h618 import pin + +# I2C +I2C0_SCL = pin.TWI0_SCL +I2C0_SDA = pin.TWI0_SDA +I2C1_SCL = pin.TWI1_SCL +I2C1_SDA = pin.TWI1_SDA + +# Default I2C +SCL = I2C0_SCL +SDA = I2C0_SDA + +# UART +UART4_TX = pin.UART4_TX +UART4_RX = pin.UART4_RX +UART5_TX = pin.UART5_TX +UART5_RX = pin.UART5_RX + +# Default UART +TX = UART4_TX +RX = UART4_RX +TXD = UART4_TX +RXD = UART4_RX + +# SPI +SPI1_MOSI = pin.SPI1_MOSI +SPI1_MISO = pin.SPI1_MISO +SPI1_SCLK = pin.SPI1_SCLK +SPI1_CS0 = pin.SPI1_CS0 + +# Default SPI +MOSI = SPI1_MOSI +MISO = SPI1_MISO +SCLK = SPI1_SCLK +CS = SPI1_CS0 + +# Pinout reference: +# https://wiki.banana-pi.org/Banana_Pi_BPI-M4_Zero#BPI-M4_Zero_40-pin_header +D3 = pin.PI6 +D5 = pin.PI5 +D7 = pin.PI12 +D8 = pin.PI13 +D10 = pin.PI14 +D11 = pin.PH2 +D12 = pin.PI1 +D13 = pin.PH3 +D15 = pin.PI11 +D16 = pin.PI15 +D18 = pin.PI16 +D19 = pin.PH7 +D21 = pin.PH8 +D22 = pin.PC2 +D23 = pin.PH6 +D24 = pin.PH5 +D26 = pin.PH9 +D27 = pin.PI8 +D28 = pin.PI7 +D29 = pin.PI10 +D31 = pin.PI9 +D32 = pin.PH4 +D33 = pin.PH10 +D35 = pin.PI2 +D36 = pin.PC7 +D37 = pin.PI0 +D38 = pin.PI4 +D40 = pin.PI3 diff --git a/src/adafruit_blinka/microcontroller/allwinner/h618/__init__.py b/src/adafruit_blinka/microcontroller/allwinner/h618/__init__.py new file mode 100644 index 00000000..bb4a91e0 --- /dev/null +++ b/src/adafruit_blinka/microcontroller/allwinner/h618/__init__.py @@ -0,0 +1,4 @@ +# SPDX-FileCopyrightText: 2021 Melissa LeBlanc-Williams for Adafruit Industries +# +# SPDX-License-Identifier: MIT +"""Definition for the AllWinner H618 chip""" diff --git a/src/adafruit_blinka/microcontroller/allwinner/h618/pin.py b/src/adafruit_blinka/microcontroller/allwinner/h618/pin.py new file mode 100644 index 00000000..7eabaa27 --- /dev/null +++ b/src/adafruit_blinka/microcontroller/allwinner/h618/pin.py @@ -0,0 +1,135 @@ +# SPDX-FileCopyrightText: 2021 Melissa LeBlanc-Williams for Adafruit Industries +# +# SPDX-License-Identifier: MIT +"""Allwinner H618 Pin Names""" +from adafruit_blinka.microcontroller.generic_linux.libgpiod_pin import Pin + +# gpiochip select +__chip_num = 0 +with open("/sys/class/gpio/gpiochip0/label", "r") as f: + label = f.read().strip() + if label == "300b000.pinctrl": + __chip_num = 1 + +PC0 = Pin((__chip_num, 64)) +SPI0_SCLK = PC0 +PC1 = Pin((__chip_num, 65)) +PC2 = Pin((__chip_num, 66)) +SPI0_MOSI = PC2 +PC3 = Pin((__chip_num, 67)) +SPI0_CS0 = PC3 +PC4 = Pin((__chip_num, 68)) +SPI0_MISO = PC4 +PC5 = Pin((__chip_num, 69)) +PC6 = Pin((__chip_num, 70)) +PC7 = Pin((__chip_num, 71)) +PC8 = Pin((__chip_num, 72)) +PC9 = Pin((__chip_num, 73)) +PC10 = Pin((__chip_num, 74)) +PC11 = Pin((__chip_num, 75)) +PC12 = Pin((__chip_num, 76)) +PC13 = Pin((__chip_num, 77)) +PC14 = Pin((__chip_num, 78)) +PC15 = Pin((__chip_num, 79)) + +PF0 = Pin((__chip_num, 160)) +PF1 = Pin((__chip_num, 161)) +PF2 = Pin((__chip_num, 162)) +PF3 = Pin((__chip_num, 163)) +PF4 = Pin((__chip_num, 164)) +PF5 = Pin((__chip_num, 165)) +PF6 = Pin((__chip_num, 166)) + +PG0 = Pin((__chip_num, 192)) +PG1 = Pin((__chip_num, 193)) +PG2 = Pin((__chip_num, 194)) +PG3 = Pin((__chip_num, 195)) +PG4 = Pin((__chip_num, 196)) +PG5 = Pin((__chip_num, 197)) +PG6 = Pin((__chip_num, 198)) +UART1_TX = PG6 +PG7 = Pin((__chip_num, 199)) +UART1_RX = PG7 +PG8 = Pin((__chip_num, 200)) +PG9 = Pin((__chip_num, 201)) +PG10 = Pin((__chip_num, 202)) +PG11 = Pin((__chip_num, 203)) +PG12 = Pin((__chip_num, 204)) +PG13 = Pin((__chip_num, 205)) +PG14 = Pin((__chip_num, 206)) +PG15 = Pin((__chip_num, 207)) +TWI4_SCL = PG15 +PG16 = Pin((__chip_num, 208)) +TWI4_SDA = PG16 +PG17 = Pin((__chip_num, 209)) +TWI3_SCL = PG17 +PG18 = Pin((__chip_num, 210)) +TWI3_SDA = PG18 +PG19 = Pin((__chip_num, 211)) + +PH0 = Pin((__chip_num, 224)) +PH1 = Pin((__chip_num, 225)) +PH2 = Pin((__chip_num, 226)) +UART5_TX = PH2 +PH3 = Pin((__chip_num, 227)) +UART5_RX = PH3 +PH4 = Pin((__chip_num, 228)) +PH5 = Pin((__chip_num, 229)) +UART2_TX = PH5 +SPI1_CS0 = PH5 +PH6 = Pin((__chip_num, 230)) +UART2_RX = PH6 +SPI1_SCLK = PH6 +PH7 = Pin((__chip_num, 231)) +SPI1_MOSI = PH7 +PH8 = Pin((__chip_num, 232)) +SPI1_MISO = PH8 +PH9 = Pin((__chip_num, 233)) +SPI1_CS1 = PH9 +PH10 = Pin((__chip_num, 234)) + +PI0 = Pin((__chip_num, 256)) +PI1 = Pin((__chip_num, 257)) +PI2 = Pin((__chip_num, 258)) +PI3 = Pin((__chip_num, 259)) +PI4 = Pin((__chip_num, 260)) +PI5 = Pin((__chip_num, 261)) +TWI0_SCL = PI5 +PI6 = Pin((__chip_num, 262)) +TWI0_SDA = PI6 +PI7 = Pin((__chip_num, 263)) +TWI1_SCL = PI7 +PI8 = Pin((__chip_num, 264)) +TWI1_SDA = PI8 +PI9 = Pin((__chip_num, 265)) +UART3_TX = PI9 +PI10 = Pin((__chip_num, 266)) +UART3_RX = PI10 +PI11 = Pin((__chip_num, 267)) +PI12 = Pin((__chip_num, 268)) +PI13 = Pin((__chip_num, 269)) +UART4_TX = PI13 +PI14 = Pin((__chip_num, 270)) +UART4_RX = PI14 +PI15 = Pin((__chip_num, 271)) +PI16 = Pin((__chip_num, 272)) + +i2cPorts = ( + (0, TWI0_SCL, TWI0_SDA), + (1, TWI1_SCL, TWI1_SDA), + (3, TWI3_SCL, TWI3_SDA), + (4, TWI4_SCL, TWI4_SDA), +) +# ordered as spiId, sckId, mosiId, misoId +spiPorts = ( + (0, SPI0_SCLK, SPI0_MOSI, SPI0_MISO), + (1, SPI1_SCLK, SPI1_MOSI, SPI1_MISO), +) +# ordered as uartId, txId, rxId +uartPorts = ( + (1, UART1_TX, UART1_RX), + (2, UART2_TX, UART2_RX), + (3, UART3_TX, UART3_RX), + (4, UART4_TX, UART4_RX), + (5, UART5_TX, UART5_RX), +) diff --git a/src/board.py b/src/board.py index 8105fd41..14f600a0 100644 --- a/src/board.py +++ b/src/board.py @@ -152,6 +152,12 @@ elif board_id == ap_board.BANANA_PI_M2_PLUS: from adafruit_blinka.board.bananapi.bpim2plus import * +elif board_id == ap_board.BANANA_PI_M4_BERRY: + from adafruit_blinka.board.bananapi.bpim4berry import * + +elif board_id == ap_board.BANANA_PI_M4_ZERO: + from adafruit_blinka.board.bananapi.bpim4zero import * + elif board_id == ap_board.BANANA_PI_M5: from adafruit_blinka.board.bananapi.bpim5 import * diff --git a/src/digitalio.py b/src/digitalio.py index 46f23a64..6f92fc53 100644 --- a/src/digitalio.py +++ b/src/digitalio.py @@ -111,6 +111,8 @@ from adafruit_blinka.microcontroller.allwinner.h5.pin import Pin elif detector.chip.H6: from adafruit_blinka.microcontroller.allwinner.h6.pin import Pin +elif detector.chip.H618: + from adafruit_blinka.microcontroller.allwinner.h618.pin import Pin elif detector.chip.H616: from adafruit_blinka.microcontroller.allwinner.h616.pin import Pin elif detector.chip.D1_RISCV: diff --git a/src/microcontroller/__init__.py b/src/microcontroller/__init__.py index 036fbc9e..ea0b5e28 100644 --- a/src/microcontroller/__init__.py +++ b/src/microcontroller/__init__.py @@ -61,6 +61,8 @@ def delay_us(delay): from adafruit_blinka.microcontroller.allwinner.h5 import * elif chip_id == ap_chip.H6: from adafruit_blinka.microcontroller.allwinner.h6 import * +elif chip_id == ap_chip.H618: + from adafruit_blinka.microcontroller.allwinner.h618 import * elif chip_id == ap_chip.H616: from adafruit_blinka.microcontroller.allwinner.h616 import * elif chip_id == ap_chip.SAMA5: diff --git a/src/microcontroller/pin.py b/src/microcontroller/pin.py index 5872271f..bdc5a8d7 100644 --- a/src/microcontroller/pin.py +++ b/src/microcontroller/pin.py @@ -51,6 +51,8 @@ from adafruit_blinka.microcontroller.allwinner.h5.pin import * elif chip_id == ap_chip.H6: from adafruit_blinka.microcontroller.allwinner.h6.pin import * +elif chip_id == ap_chip.H618: + from adafruit_blinka.microcontroller.allwinner.h618.pin import * elif chip_id == ap_chip.H616: if board_id == ap_boards.REPKA_PI_4_H6: from adafruit_blinka.board.repkapi.repka_pi_4 import * From 1cf5367a437518d62f44c626e4d684a0faa0e853 Mon Sep 17 00:00:00 2001 From: August <2819763+Dangku@users.noreply.github.com> Date: Sun, 1 Sep 2024 00:01:10 +0800 Subject: [PATCH 02/19] bpim4berry: restore pin define --- .../board/bananapi/bpim4berry.py | 56 +++++++++---------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/src/adafruit_blinka/board/bananapi/bpim4berry.py b/src/adafruit_blinka/board/bananapi/bpim4berry.py index cfed3a31..b220718a 100644 --- a/src/adafruit_blinka/board/bananapi/bpim4berry.py +++ b/src/adafruit_blinka/board/bananapi/bpim4berry.py @@ -41,31 +41,31 @@ # Pinout reference: # https://wiki.banana-pi.org/Banana_Pi_BPI-M4_Berry#BPI-M4_Berry_40-pin_header -PG16 = pin.PG16 -PG15 = pin.PG15 -PG19 = pin.PG19 -PG6 = pin.PG6 -PG7 = pin.PG7 -PH2 = pin.PH2 -PG11 = pin.PG11 -PH3 = pin.PH3 -PG2 = pin.PG2 -PG8 = pin.PG8 -PG9 = pin.PG9 -PH7 = pin.PH7 -PH8 = pin.PH8 -PG1 = pin.PG1 -PH6 = pin.PH6 -PH5 = pin.PH5 -PH9 = pin.PH9 -PG18 = pin.PG18 -PG17 = pin.PG17 -PG3 = pin.PG3 -PG4 = pin.PG4 -PG0 = pin.PG0 -PG5 = pin.PG5 -PG12 = pin.PG12 -PH4 = pin.PH4 -PG10 = pin.PG10 -PG14 = pin.PG14 -PG13 = pin.PG13 +D3 = pin.PG16 +D5 = pin.PG15 +D7 = pin.PG19 +D8 = pin.PG6 +D10 = pin.PG7 +D11 = pin.PH2 +D12 = pin.PG11 +D13 = pin.PH3 +D15 = pin.PG2 +D16 = pin.PG8 +D18 = pin.PG9 +D19 = pin.PH7 +D21 = pin.PH8 +D22 = pin.PG1 +D23 = pin.PH6 +D24 = pin.PH5 +D26 = pin.PH9 +D27 = pin.PG18 +D28 = pin.PG17 +D29 = pin.PG3 +D31 = pin.PG4 +D32 = pin.PG0 +D33 = pin.PG5 +D35 = pin.PG12 +D36 = pin.PH4 +D37 = pin.PG10 +D38 = pin.PG14 +D40 = pin.PG13 From 2982747631256df8d29f689e814f0b5962d13c57 Mon Sep 17 00:00:00 2001 From: August <2819763+Dangku@users.noreply.github.com> Date: Mon, 2 Sep 2024 22:36:38 +0800 Subject: [PATCH 03/19] allwinner h618: support mainline gpiochip --- .../microcontroller/allwinner/h618/pin.py | 28 +++++++++++++++---- 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/src/adafruit_blinka/microcontroller/allwinner/h618/pin.py b/src/adafruit_blinka/microcontroller/allwinner/h618/pin.py index 7eabaa27..cf7b4798 100644 --- a/src/adafruit_blinka/microcontroller/allwinner/h618/pin.py +++ b/src/adafruit_blinka/microcontroller/allwinner/h618/pin.py @@ -4,12 +4,28 @@ """Allwinner H618 Pin Names""" from adafruit_blinka.microcontroller.generic_linux.libgpiod_pin import Pin -# gpiochip select -__chip_num = 0 -with open("/sys/class/gpio/gpiochip0/label", "r") as f: - label = f.read().strip() - if label == "300b000.pinctrl": - __chip_num = 1 +def find_gpiochip_number(target_label): + try: + with open('/sys/kernel/debug/gpio', 'r') as f: + lines = f.readlines() + except FileNotFoundError: + print("The file /sys/kernel/debug/gpio does not exist.") + return None + + gpiochip_number = None + for line in lines: + if target_label in line: + parts = line.split() + for part in parts: + if part.startswith('gpiochip'): + gpiochip_number = part[len('gpiochip'):] + break + break + + return gpiochip_number + +__chip_num = 1 +__chip_num = gpiochip_number = find_gpiochip_number("300b000.pinctrl") PC0 = Pin((__chip_num, 64)) SPI0_SCLK = PC0 From 73a4af98827cef92fb5bd4f7a5ed63686bde31f8 Mon Sep 17 00:00:00 2001 From: August <2819763+Dangku@users.noreply.github.com> Date: Tue, 3 Sep 2024 01:26:36 +0800 Subject: [PATCH 04/19] allwinner h618: support mainline gpiochip --- .../microcontroller/allwinner/h618/pin.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/adafruit_blinka/microcontroller/allwinner/h618/pin.py b/src/adafruit_blinka/microcontroller/allwinner/h618/pin.py index cf7b4798..34fdb6e1 100644 --- a/src/adafruit_blinka/microcontroller/allwinner/h618/pin.py +++ b/src/adafruit_blinka/microcontroller/allwinner/h618/pin.py @@ -3,6 +3,7 @@ # SPDX-License-Identifier: MIT """Allwinner H618 Pin Names""" from adafruit_blinka.microcontroller.generic_linux.libgpiod_pin import Pin +import re def find_gpiochip_number(target_label): try: @@ -15,12 +16,10 @@ def find_gpiochip_number(target_label): gpiochip_number = None for line in lines: if target_label in line: - parts = line.split() - for part in parts: - if part.startswith('gpiochip'): - gpiochip_number = part[len('gpiochip'):] - break - break + match = re.search(r'gpiochip(\d+)', line) + if match: + gpiochip_number = match.group(1) + break return gpiochip_number From 2092c8bddf8d8a89f4325df1c268138f22cac53f Mon Sep 17 00:00:00 2001 From: August <2819763+Dangku@users.noreply.github.com> Date: Tue, 3 Sep 2024 14:04:34 +0800 Subject: [PATCH 05/19] allwinner h618: fix get wrong chip number in venv --- src/adafruit_blinka/microcontroller/allwinner/h618/pin.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/adafruit_blinka/microcontroller/allwinner/h618/pin.py b/src/adafruit_blinka/microcontroller/allwinner/h618/pin.py index 34fdb6e1..fdbdcc63 100644 --- a/src/adafruit_blinka/microcontroller/allwinner/h618/pin.py +++ b/src/adafruit_blinka/microcontroller/allwinner/h618/pin.py @@ -23,8 +23,10 @@ def find_gpiochip_number(target_label): return gpiochip_number -__chip_num = 1 -__chip_num = gpiochip_number = find_gpiochip_number("300b000.pinctrl") +if find_gpiochip_number("300b000.pinctrl"): + __chip_num = 1 +else: + __chip_num = 0 PC0 = Pin((__chip_num, 64)) SPI0_SCLK = PC0 From 18c14b917ecfc19b64a831aad6aa563c2b9390aa Mon Sep 17 00:00:00 2001 From: August <2819763+Dangku@users.noreply.github.com> Date: Tue, 3 Sep 2024 15:14:03 +0800 Subject: [PATCH 06/19] allwinner h618: support pwm --- src/adafruit_blinka/microcontroller/allwinner/h618/pin.py | 8 ++++++++ src/pwmio.py | 2 ++ 2 files changed, 10 insertions(+) diff --git a/src/adafruit_blinka/microcontroller/allwinner/h618/pin.py b/src/adafruit_blinka/microcontroller/allwinner/h618/pin.py index fdbdcc63..426f38d6 100644 --- a/src/adafruit_blinka/microcontroller/allwinner/h618/pin.py +++ b/src/adafruit_blinka/microcontroller/allwinner/h618/pin.py @@ -83,6 +83,7 @@ def find_gpiochip_number(target_label): PG18 = Pin((__chip_num, 210)) TWI3_SDA = PG18 PG19 = Pin((__chip_num, 211)) +PWM1 = PG19 PH0 = Pin((__chip_num, 224)) PH1 = Pin((__chip_num, 225)) @@ -124,6 +125,7 @@ def find_gpiochip_number(target_label): UART3_RX = PI10 PI11 = Pin((__chip_num, 267)) PI12 = Pin((__chip_num, 268)) +PWM2 = PI12 PI13 = Pin((__chip_num, 269)) UART4_TX = PI13 PI14 = Pin((__chip_num, 270)) @@ -150,3 +152,9 @@ def find_gpiochip_number(target_label): (4, UART4_TX, UART4_RX), (5, UART5_TX, UART5_RX), ) + +# SysFS pwm outputs, pwm channel and pin in first tuple +pwmOuts = [ + ((0, 1), PWM1), + ((0, 2), PWM2), +] diff --git a/src/pwmio.py b/src/pwmio.py index 6935ac1a..72ce0d89 100644 --- a/src/pwmio.py +++ b/src/pwmio.py @@ -18,6 +18,8 @@ if detector.board.any_raspberry_pi: from adafruit_blinka.microcontroller.bcm283x.pwmio.PWMOut import PWMOut +elif detector.board.any_bananapi: + from adafruit_blinka.microcontroller.generic_linux.sysfs_pwmout import PWMOut elif detector.board.any_coral_board: from adafruit_blinka.microcontroller.generic_linux.sysfs_pwmout import PWMOut elif detector.board.any_giant_board: From 41b183d45263e45c8f7ee5b6f942edd22c2b2cd3 Mon Sep 17 00:00:00 2001 From: August <2819763+Dangku@users.noreply.github.com> Date: Tue, 3 Sep 2024 19:31:44 +0800 Subject: [PATCH 07/19] support spacemit k1, bananapif3 --- src/adafruit_blinka/board/bananapi/bpif3.py | 56 ++++++ .../rockchip/rk3566/.pin.py.swp | Bin 0 -> 16384 bytes .../microcontroller/spacemit/__init__.py | 4 + .../microcontroller/spacemit/k1/__init__.py | 4 + .../microcontroller/spacemit/k1/pin.py | 180 ++++++++++++++++++ src/board.py | 3 + src/digitalio.py | 2 + src/microcontroller/__init__.py | 2 + src/microcontroller/pin.py | 2 + 9 files changed, 253 insertions(+) create mode 100644 src/adafruit_blinka/board/bananapi/bpif3.py create mode 100644 src/adafruit_blinka/microcontroller/rockchip/rk3566/.pin.py.swp create mode 100644 src/adafruit_blinka/microcontroller/spacemit/__init__.py create mode 100644 src/adafruit_blinka/microcontroller/spacemit/k1/__init__.py create mode 100644 src/adafruit_blinka/microcontroller/spacemit/k1/pin.py diff --git a/src/adafruit_blinka/board/bananapi/bpif3.py b/src/adafruit_blinka/board/bananapi/bpif3.py new file mode 100644 index 00000000..49d71583 --- /dev/null +++ b/src/adafruit_blinka/board/bananapi/bpif3.py @@ -0,0 +1,56 @@ +# SPDX-FileCopyrightText: 2021 Melissa LeBlanc-Williams for Adafruit Industries +# +# SPDX-License-Identifier: MIT +"""Pin definitions for the Banana Pi F3.""" + +from adafruit_blinka.microcontroller.spacemit.k1 import pin + +# I2C +I2C4_SCL = pin.I2C4_SCL +I2C4_SDA = pin.I2C4_SDA + +# Default I2C +SCL = I2C4_SCL +SDA = I2C4_SDA + +# UART +UART0_TX = pin.UART0_TX +UART0_RX = pin.UART0_RX + +# Default UART +TX = UART0_TX +RX = UART0_RX +TXD = UART0_TX +RXD = UART0_RX + +# SPI +SPI3_MOSI = pin.SPI3_MOSI +SPI3_MISO = pin.SPI3_MISO +SPI3_SCLK = pin.SPI3_SCLK +SPI3_CS0 = pin.SPI3_CS0 + +# Default SPI +MOSI = SPI3_MOSI +MISO = SPI3_MISO +SCLK = SPI3_SCLK +CS = SPI3_CS0 + +# Pinout reference: +# https://wiki.banana-pi.org/Banana_Pi_BPI-M4_Berry#BPI-M4_Berry_40-pin_header +D3 = pin.GPIO_52 +D5 = pin.GPIO_51 +D7 = pin.GPIO_70 +D8 = pin.GPIO_47 +D10 = pin.GPIO_48 +D11 = pin.GPIO_71 +D12 = pin.GPIO_74 +D13 = pin.GPIO_72 +D15 = pin.GPIO_73 +D16 = pin.GPIO_91 +D18 = pin.GPIO_92 +D19 = pin.GPIO_77 +D21 = pin.GPIO_78 +D22 = pin.GPIO_49 +D23 = pin.GPIO_75 +D24 = pin.GPIO_76 +D26 = pin.GPIO_50 diff --git a/src/adafruit_blinka/microcontroller/rockchip/rk3566/.pin.py.swp b/src/adafruit_blinka/microcontroller/rockchip/rk3566/.pin.py.swp new file mode 100644 index 0000000000000000000000000000000000000000..7ed8195e96d5a65be059efe2359f0d2e85359708 GIT binary patch literal 16384 zcmeI2ZH!!18OKixg2;;sQ3D#iZqsBJw!3p@cDJS44>Pm8jP0^ZcMFx;+|170-ClNf zW_o9~Wx+&1KTs1x46o`3>q~-f5rZU!7*Ru_K@$Xt@q-^EMpTqU4T-Nr{XO^I^D?EB zQooq=PV(#a{^z;pJkN8U`*O~i#lj7>8E@N|ulT%8srPJqcIn85pQ(R6dai2L+si9! z^2NzNsoj>j>dDR2_-fdU>f@>T`09Ey?nKS;?t1?~r#)V7)|cY7s2@~XQG2C6-isUK zb*(L?+G^B@JB?1eA9q@jvd$*HOFZqy#@uD^~K`PX>{&eRNCs7gh@ zAkl9cdcSwc#e2@wMC5Vj8OSq`XCTi&o`F0Ac?R+f{Nrq;{tkbD7vU**7`_Q#fqUV0Xu)16!{u-ZyuyOd3-B}? zgQIW+VmJsZumC$?Gh7INrG|b5KZ1whL6Ew-9bWS@KUXUS)m=M-nS!^&yJoI7I}ub$ zDwXF8u3VlH*$-xB=WD@?pP6&EpXs&v*#W(n>PhR`ybx3-Gg(@ z)}=vfKPVT(8rii*_C+qH);bF`l6ZnF){Z>sSlb+so3s(P?IZ`tzOxA9h7 z|82Mx*L@pp+4bHATXvndv6fxmZK!3}bscFbm^RiWMo_zgZp=m3zMz{(Mc2-tn@C01 z-k_UEMc3}2n@~l!{!~q@qU+3alQO}It}~B5;J?m1`hfpB^XRVsrqa+||9u;8)%D-E z@m5{`eH*W>H2m~!ycO4fQ)%3~T>nj_$t_J+th8g}wUs8ijn`J1=r&$kY3O!%ZKWaG zXl_A=_AOr6Jo;ZKWaGkuAHKw*y;t6K~@z59B?&0EVMQPC$NF!FRob`y+hIl5 z!%8#8ePlhX#lQ|LvL04s*Lgjx$gb};R6DFRVk5P~imZo~M$E7x>tRJU!-{OfEW3W| zDE(mC+zfo$*5>HOanT)n<2kyynfXq3(alAJZk!a|wqvu4uCt4|@e)~QmsbJTOPyV0 z*BPBgWK#h&qSJ_M3IJKB5!v-nrxDqt5o?M9Wy7q;aEfbLF z+8KEX)AuCNwKwP{Qqi?L=q4s~bCIE&phVY+L^n~1t}}`5`f2X9yc4;8nu`+M_0wFG z@?PcmZ!SuCw{mqGm%S*(9~+k~8_{i^ZP}pfvMD%)fNZmG3jx_C-;Ox4^~DY?vUI7I z;?Amf+)up6j{AxC*mBqoAhQaMUAlC3%AsoVY?qKMPa<%o2f0R zP1@kF^ZoEp=zS>cw3n0KuC2$-l`w9Ht&^Ww^mc~r zb|`MGhjFjdRx0QbW>v|tuS;XL>)YXDEe58(T7KOBJ@VKcnUy#FuoXLt<00T03_;7+&$ zVvzNMVYm#=hK;ZRWWC@g@HMy{mf%Xb0Ay|8OCak4`(ZQ4TEO%0D0~#IhplivJja~= zt8h0g!UUWHPcVP~G#mz**S`;*XP*9T_zbK<88(8<-+x1{pMr0}eIU6%4EZO|K%Rj! zBLlK9F~{Sp$CJCi)@_BuMj27PZZ!Cv7Df~gso6E>tn7G1Ma9P8Ia(M|^>)40S+2Eh zUq%^G%F8~c|FL?v8@8Ln!%@3GoID@*ZSnVyj3$e7yaBUPB8w;dPu{Hb>C3IoV!hQH z9@&>ZXRq*vg57(E_7k7BKB?`(fbB$L8!dThV^Pm*clzFSop!iA`6iWjB+qU07#|*5 z3a9D?K4U#z8tSbf>)xqFC$Dg6bn?=6>d}eysYWM#oMv>*=H!W^)Ae!Ep_8?PG&ug3 zg(>R>uM_4B>z-y9#r~v$%Ic|Wordc1IZ=VIj^`SePBSmzR58s`!znleH^-J-kL0HpjTS%Qb!@!42HZCL2jv6HQhv=DuwLn~>R5I?p0|iybBc9utw_q1ox(v$bi~ z@aKm{wyX4u9iE=Ej3vStQysNmNf^U=c|2*ZG%`By)YvD}iuK;r^Iqx!U37U0je4_j zGmO(U_v{<(Vy!t!Z-nG_mnI*Qpr6}(8)2FQIjys{JWZ z=|W$XuMUxKBsM(bpJ_I0qzbY(2ky69cK0iDX^ zg+X~TkxPlSZkxwhA(O@0%5))Z7qK?oPN$~DV8PM+#IE4lWla`bJ0AI)JZX_#V%hM_ zsvv87f+usPr}bd Date: Wed, 4 Sep 2024 10:10:34 +0800 Subject: [PATCH 08/19] remove tmp file --- .../microcontroller/allwinner/h618/pin.py | 2 +- .../microcontroller/rockchip/rk3566/.pin.py.swp | Bin 16384 -> 0 bytes 2 files changed, 1 insertion(+), 1 deletion(-) delete mode 100644 src/adafruit_blinka/microcontroller/rockchip/rk3566/.pin.py.swp diff --git a/src/adafruit_blinka/microcontroller/allwinner/h618/pin.py b/src/adafruit_blinka/microcontroller/allwinner/h618/pin.py index 426f38d6..ab32a88f 100644 --- a/src/adafruit_blinka/microcontroller/allwinner/h618/pin.py +++ b/src/adafruit_blinka/microcontroller/allwinner/h618/pin.py @@ -2,8 +2,8 @@ # # SPDX-License-Identifier: MIT """Allwinner H618 Pin Names""" -from adafruit_blinka.microcontroller.generic_linux.libgpiod_pin import Pin import re +from adafruit_blinka.microcontroller.generic_linux.libgpiod_pin import Pin def find_gpiochip_number(target_label): try: diff --git a/src/adafruit_blinka/microcontroller/rockchip/rk3566/.pin.py.swp b/src/adafruit_blinka/microcontroller/rockchip/rk3566/.pin.py.swp deleted file mode 100644 index 7ed8195e96d5a65be059efe2359f0d2e85359708..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 16384 zcmeI2ZH!!18OKixg2;;sQ3D#iZqsBJw!3p@cDJS44>Pm8jP0^ZcMFx;+|170-ClNf zW_o9~Wx+&1KTs1x46o`3>q~-f5rZU!7*Ru_K@$Xt@q-^EMpTqU4T-Nr{XO^I^D?EB zQooq=PV(#a{^z;pJkN8U`*O~i#lj7>8E@N|ulT%8srPJqcIn85pQ(R6dai2L+si9! z^2NzNsoj>j>dDR2_-fdU>f@>T`09Ey?nKS;?t1?~r#)V7)|cY7s2@~XQG2C6-isUK zb*(L?+G^B@JB?1eA9q@jvd$*HOFZqy#@uD^~K`PX>{&eRNCs7gh@ zAkl9cdcSwc#e2@wMC5Vj8OSq`XCTi&o`F0Ac?R+f{Nrq;{tkbD7vU**7`_Q#fqUV0Xu)16!{u-ZyuyOd3-B}? zgQIW+VmJsZumC$?Gh7INrG|b5KZ1whL6Ew-9bWS@KUXUS)m=M-nS!^&yJoI7I}ub$ zDwXF8u3VlH*$-xB=WD@?pP6&EpXs&v*#W(n>PhR`ybx3-Gg(@ z)}=vfKPVT(8rii*_C+qH);bF`l6ZnF){Z>sSlb+so3s(P?IZ`tzOxA9h7 z|82Mx*L@pp+4bHATXvndv6fxmZK!3}bscFbm^RiWMo_zgZp=m3zMz{(Mc2-tn@C01 z-k_UEMc3}2n@~l!{!~q@qU+3alQO}It}~B5;J?m1`hfpB^XRVsrqa+||9u;8)%D-E z@m5{`eH*W>H2m~!ycO4fQ)%3~T>nj_$t_J+th8g}wUs8ijn`J1=r&$kY3O!%ZKWaG zXl_A=_AOr6Jo;ZKWaGkuAHKw*y;t6K~@z59B?&0EVMQPC$NF!FRob`y+hIl5 z!%8#8ePlhX#lQ|LvL04s*Lgjx$gb};R6DFRVk5P~imZo~M$E7x>tRJU!-{OfEW3W| zDE(mC+zfo$*5>HOanT)n<2kyynfXq3(alAJZk!a|wqvu4uCt4|@e)~QmsbJTOPyV0 z*BPBgWK#h&qSJ_M3IJKB5!v-nrxDqt5o?M9Wy7q;aEfbLF z+8KEX)AuCNwKwP{Qqi?L=q4s~bCIE&phVY+L^n~1t}}`5`f2X9yc4;8nu`+M_0wFG z@?PcmZ!SuCw{mqGm%S*(9~+k~8_{i^ZP}pfvMD%)fNZmG3jx_C-;Ox4^~DY?vUI7I z;?Amf+)up6j{AxC*mBqoAhQaMUAlC3%AsoVY?qKMPa<%o2f0R zP1@kF^ZoEp=zS>cw3n0KuC2$-l`w9Ht&^Ww^mc~r zb|`MGhjFjdRx0QbW>v|tuS;XL>)YXDEe58(T7KOBJ@VKcnUy#FuoXLt<00T03_;7+&$ zVvzNMVYm#=hK;ZRWWC@g@HMy{mf%Xb0Ay|8OCak4`(ZQ4TEO%0D0~#IhplivJja~= zt8h0g!UUWHPcVP~G#mz**S`;*XP*9T_zbK<88(8<-+x1{pMr0}eIU6%4EZO|K%Rj! zBLlK9F~{Sp$CJCi)@_BuMj27PZZ!Cv7Df~gso6E>tn7G1Ma9P8Ia(M|^>)40S+2Eh zUq%^G%F8~c|FL?v8@8Ln!%@3GoID@*ZSnVyj3$e7yaBUPB8w;dPu{Hb>C3IoV!hQH z9@&>ZXRq*vg57(E_7k7BKB?`(fbB$L8!dThV^Pm*clzFSop!iA`6iWjB+qU07#|*5 z3a9D?K4U#z8tSbf>)xqFC$Dg6bn?=6>d}eysYWM#oMv>*=H!W^)Ae!Ep_8?PG&ug3 zg(>R>uM_4B>z-y9#r~v$%Ic|Wordc1IZ=VIj^`SePBSmzR58s`!znleH^-J-kL0HpjTS%Qb!@!42HZCL2jv6HQhv=DuwLn~>R5I?p0|iybBc9utw_q1ox(v$bi~ z@aKm{wyX4u9iE=Ej3vStQysNmNf^U=c|2*ZG%`By)YvD}iuK;r^Iqx!U37U0je4_j zGmO(U_v{<(Vy!t!Z-nG_mnI*Qpr6}(8)2FQIjys{JWZ z=|W$XuMUxKBsM(bpJ_I0qzbY(2ky69cK0iDX^ zg+X~TkxPlSZkxwhA(O@0%5))Z7qK?oPN$~DV8PM+#IE4lWla`bJ0AI)JZX_#V%hM_ zsvv87f+usPr}bd Date: Wed, 4 Sep 2024 10:19:06 +0800 Subject: [PATCH 09/19] fix Missing function or method docstring (missing-function-docstring) --- src/adafruit_blinka/microcontroller/allwinner/h618/pin.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/adafruit_blinka/microcontroller/allwinner/h618/pin.py b/src/adafruit_blinka/microcontroller/allwinner/h618/pin.py index ab32a88f..8f6c3888 100644 --- a/src/adafruit_blinka/microcontroller/allwinner/h618/pin.py +++ b/src/adafruit_blinka/microcontroller/allwinner/h618/pin.py @@ -6,6 +6,7 @@ from adafruit_blinka.microcontroller.generic_linux.libgpiod_pin import Pin def find_gpiochip_number(target_label): + """Get correct gpiochip number, legacy kernel and mainline kernel are different""" try: with open('/sys/kernel/debug/gpio', 'r') as f: lines = f.readlines() From 3746b1b4aef900105cc9cfa19cada6692d5eb94e Mon Sep 17 00:00:00 2001 From: August <2819763+Dangku@users.noreply.github.com> Date: Wed, 4 Sep 2024 11:09:51 +0800 Subject: [PATCH 10/19] fix pre-commit check fail --- .../microcontroller/allwinner/h618/pin.py | 6 ++++-- .../microcontroller/spacemit/k1/pin.py | 14 ++++---------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/adafruit_blinka/microcontroller/allwinner/h618/pin.py b/src/adafruit_blinka/microcontroller/allwinner/h618/pin.py index 8f6c3888..1019b598 100644 --- a/src/adafruit_blinka/microcontroller/allwinner/h618/pin.py +++ b/src/adafruit_blinka/microcontroller/allwinner/h618/pin.py @@ -5,10 +5,11 @@ import re from adafruit_blinka.microcontroller.generic_linux.libgpiod_pin import Pin + def find_gpiochip_number(target_label): """Get correct gpiochip number, legacy kernel and mainline kernel are different""" try: - with open('/sys/kernel/debug/gpio', 'r') as f: + with open("/sys/kernel/debug/gpio", "r") as f: lines = f.readlines() except FileNotFoundError: print("The file /sys/kernel/debug/gpio does not exist.") @@ -17,13 +18,14 @@ def find_gpiochip_number(target_label): gpiochip_number = None for line in lines: if target_label in line: - match = re.search(r'gpiochip(\d+)', line) + match = re.search(r"gpiochip(\d+)", line) if match: gpiochip_number = match.group(1) break return gpiochip_number + if find_gpiochip_number("300b000.pinctrl"): __chip_num = 1 else: diff --git a/src/adafruit_blinka/microcontroller/spacemit/k1/pin.py b/src/adafruit_blinka/microcontroller/spacemit/k1/pin.py index ad70499e..997db4a9 100644 --- a/src/adafruit_blinka/microcontroller/spacemit/k1/pin.py +++ b/src/adafruit_blinka/microcontroller/spacemit/k1/pin.py @@ -5,7 +5,7 @@ from adafruit_blinka.agnostic import detector from adafruit_blinka.microcontroller.alias import get_pwm_chipid from adafruit_blinka.microcontroller.generic_linux.libgpiod_pin import Pin - + __chip_num = 0 GPIO_0 = Pin((__chip_num, 0)) @@ -141,9 +141,7 @@ I2C4_SCL = GPIO_51 I2C4_SDA = GPIO_52 -i2cPorts = ( - (4, I2C4_SCL, I2C4_SDA), -) +i2cPorts = ((4, I2C4_SCL, I2C4_SDA),) # SPI SPI3_MISO = GPIO_78 @@ -152,18 +150,14 @@ SPI3_CS0 = GPIO_76 # ordered as spiId, sckId, mosiId, misoId -spiPorts = ( - (3, SPI3_SCLK, SPI3_MOSI, SPI3_MISO), -) +spiPorts = ((3, SPI3_SCLK, SPI3_MOSI, SPI3_MISO),) # UART UART0_TX = GPIO_47 UART0_RX = GPIO_48 # ordered as uartId, txId, rxId -uartPorts = ( - (0, UART0_TX, UART0_RX), -) +uartPorts = ((0, UART0_TX, UART0_RX),) # SysFS pwm outputs, pwm channel and pin in first tuple pwmOuts = [] From 9c657918b037f7a8803dbb2596f96d8c3b2026c3 Mon Sep 17 00:00:00 2001 From: landall Date: Wed, 18 Sep 2024 03:57:11 +0800 Subject: [PATCH 11/19] add support for orangepi 3b --- .../board/orangepi/orangepi3b.py | 66 +++++++++++++++++++ .../microcontroller/rockchip/rk3566/pin.py | 9 +++ src/board.py | 3 + 3 files changed, 78 insertions(+) create mode 100644 src/adafruit_blinka/board/orangepi/orangepi3b.py diff --git a/src/adafruit_blinka/board/orangepi/orangepi3b.py b/src/adafruit_blinka/board/orangepi/orangepi3b.py new file mode 100644 index 00000000..2ea83212 --- /dev/null +++ b/src/adafruit_blinka/board/orangepi/orangepi3b.py @@ -0,0 +1,66 @@ +# SPDX-FileCopyrightText: 2021 Melissa LeBlanc-Williams for Adafruit Industries +# +# SPDX-License-Identifier: MIT +"""Pin definitions for the Orangepi 3B.""" + +from adafruit_blinka.microcontroller.rockchip.rk3566 import pin + +# D pin number is ordered by physical pin sequence +# Reference: https://service.robots.org.nz/wiki/Wiki.jsp?page=OrangePi + +# D2 = VCC5V0_SYS +D3 = pin.I2C2_SDA_M1 +# D4 = VCC5V0_SYS +D5 = pin.I2C2_SCL_M1 +# D6 = GND +D7 = pin.GPIO4_C3 # GPIO4_C3/PWM15 +D8 = pin.GPIO0_D1 +# D9 = GND +D10 = pin.GPIO0_D0 +D11 = pin.GPIO3_C6 +D12 = pin.GPIO3_C7 +D13 = pin.GPIO4_A0 +# D14 = GND +D15 = pin.GPIO4_A2 +D16 = pin.GPIO4_A3 +# D17 = Vcc3V3_SYS +D18 = pin.GPIO4_A1 +D19 = pin.SPI3_MOSI_M0 +# D20 = GND +D21 = pin.SPI3_MISO_M0 +D22 = pin.GPIO4_A4 +D23 = pin.SPI3_CLK_M0 +D24 = pin.SPI3_CS0_M0 +# D25 = GND +D26 = pin.GPIO4_A7 +D27 = pin.I2C3_SDA_M0 +D28 = pin.I2C3_SCL_M0 +D29 = pin.GPIO4_A5 +#D30 = GND +D31 = pin.GPIO3_D4 +D32 = pin.GPIO4_C0 +D33 = pin.GPIO3_D7 +# D34 = GND +D35 = pin.GPIO3_D0 +D36 = pin.GPIO3_D5 +D37 = pin.GPIO3_D3 +D38 = pin.GPIO3_D2 +# D39 = GND +D40 = pin.GPIO3_D1 + +# UART +#UART4_TX = pin.GPIO1_B0 +#UART4_RX = pin.GPIO1_A7 + +# SPI +SPI3_MISO = pin.SPI3_MISO_M0 +SPI3_MOSI = pin.SPI3_MOSI_M0 +SPI3_CLK = pin.SPI3_CLK_M0 +SPI3_CS0 = pin.SPI3_CS0_M0 + +# Default SPI +MOSI = SPI3_MOSI +MISO = SPI3_MISO +SCLK = SPI3_CLK +CS = SPI3_CS0 + diff --git a/src/adafruit_blinka/microcontroller/rockchip/rk3566/pin.py b/src/adafruit_blinka/microcontroller/rockchip/rk3566/pin.py index 1a8952b8..5b51baf6 100644 --- a/src/adafruit_blinka/microcontroller/rockchip/rk3566/pin.py +++ b/src/adafruit_blinka/microcontroller/rockchip/rk3566/pin.py @@ -93,6 +93,15 @@ GPIO3_D3 = Pin((3, 27)) GPIO3_D4 = Pin((3, 28)) GPIO3_D5 = Pin((3, 29)) +GPIO3_D6 = Pin((3, 30)) +GPIO3_D7 = Pin((3, 31)) + +# GPIO4 +GPIO4_A0 = Pin((4, 0)) +GPIO4_A1 = Pin((4, 1)) +GPIO4_A2 = Pin((4, 2)) +GPIO4_A3 = Pin((4, 3)) + GPIO4_A4 = Pin((4, 4)) GPIO4_A5 = Pin((4, 5)) GPIO4_A6 = Pin((4, 6)) diff --git a/src/board.py b/src/board.py index 88ae1da9..d1a8be5b 100644 --- a/src/board.py +++ b/src/board.py @@ -134,6 +134,9 @@ elif board_id == ap_board.ORANGE_PI_3: from adafruit_blinka.board.orangepi.orangepi3 import * +elif board_id == ap_board.ORANGE_PI_3B: + from adafruit_blinka.board.orangepi.orangepi3b import * + elif board_id == ap_board.ORANGE_PI_4: from adafruit_blinka.board.orangepi.orangepi4 import * From 80c9d3d3d4de8d8d1b82c95877e0f0c234c189b1 Mon Sep 17 00:00:00 2001 From: rippanda12 Date: Mon, 23 Sep 2024 22:15:33 +0300 Subject: [PATCH 12/19] Add Indiedroid support Closes #896 --- .../board/ameridroid/__init__.py | 4 + .../board/ameridroid/indiedroid_nova.py | 135 ++++++++++++++++++ src/board.py | 3 + 3 files changed, 142 insertions(+) create mode 100644 src/adafruit_blinka/board/ameridroid/__init__.py create mode 100644 src/adafruit_blinka/board/ameridroid/indiedroid_nova.py diff --git a/src/adafruit_blinka/board/ameridroid/__init__.py b/src/adafruit_blinka/board/ameridroid/__init__.py new file mode 100644 index 00000000..18e0b413 --- /dev/null +++ b/src/adafruit_blinka/board/ameridroid/__init__.py @@ -0,0 +1,4 @@ +# SPDX-FileCopyrightText: 2024 Rippanda12 +# +# SPDX-License-Identifier: MIT +"""Boards definition from ameriDroid""" diff --git a/src/adafruit_blinka/board/ameridroid/indiedroid_nova.py b/src/adafruit_blinka/board/ameridroid/indiedroid_nova.py new file mode 100644 index 00000000..69f02e53 --- /dev/null +++ b/src/adafruit_blinka/board/ameridroid/indiedroid_nova.py @@ -0,0 +1,135 @@ +# SPDX-FileCopyrightText: 2024 Rippanda12 +# +# SPDX-License-Identifier: MIT + +"""Pin definitions for the Indiedroid Nova""" + +from adafruit_blinka.microcontroller.rockchip.rk3588s import pin + + +# D1 = +3.3V +# D2 = +5V +D3 = pin.GPIO1_D7 +# D4 = +5V +D5 = pin.GPIO1_D6 +# D6 = GND +D7 = pin.GPIO1_A6 +D8 = pin.GPIO4_A3 +# D9 = GND +D10 = pin.GPIO4_A4 +D11 = pin.GPIO1_B4 +D12 = pin.GPIO0_D0 +D13 = pin.GPIO1_B5 +# D14 = GND +D15 = pin.GPIO3_C4 +D16 = pin.GPIO3_B0 +# D17 = +3.3V +D18 = pin.GPIO3_B1 +D19 = pin.GPIO3_B7 +# D20 = GND +D21 = pin.GPIO3_C0 +D22 = pin.GPIO3_C5 +D23 = pin.GPIO3_C1 +D24 = pin.GPIO0_D3 +# D25 = GND +D26 = pin.GPIO3_C3 +D27 = pin.GPIO1_A0 +D28 = pin.GPIO1_C1 +D29 = pin.GPIO1_A4 +# D30 = GND +D31 = pin.GPIO1_B1 +D32 = pin.GPIO4_A6 +D33 = pin.GPIO1_B2 +# D34 = GND +D35 = pin.GPIO4_A7 +D36 = pin.GPIO4_B5 +D37 = pin.GPIO4_A2 +D38 = pin.GPIO4_B4 +# D39 = GND +D40 = pin.GPIO4_B3 + + +# UART +# UART2_M0 +UART2_TX = pin.GPIO1_B5 +UART2_RX = pin.GPIO1_B6 +# UART0_M2 +UART0_TX = pin.GPIO4_A3 +UART0_RX = pin.GPIO4_A4 +# UART5_M1 +UART5_TX = pin.GPIO3_C4 +UART5_RX = pin.GPIO3_C5 +# UART7_M1 +UART7_TX = pin.GPIO3_C0 +UART7_RX = pin.GPIO3_C1 + +# Default UART -> UART2_M0 + +TX = UART2_TX +RX = UART2_RX +TXD = UART2_TX +RXD = UART2_RX + +# I2C + +# I2C3_M1 +I2C3_SCL = pin.GPIO3_B7 +I2C3_SDA = pin.GPIO3_C0 +# I2C5_M2 +I2C5_SCL = pin.GPIO4_A6 +I2C5_SDA = pin.GPIO4_A7 +# I2C7_M3 +I2C7_SCL = pin.GPIO4_B2 +I2C7_SDA = pin.GPIO4_B3 +# I2C8_M2 +I2C8_SCL = pin.GPIO1_D6 +I2C8_SDA = pin.GPIO1_D7 + +# Default I2C -> I2C8_M2 +SCL = I2C8_SCL +SDA = I2C8_SDA + +# SPI +# SPI0_M2 +SPI0_SCLK = pin.GPIO4_A2 +SPI0_MISO = pin.GPIO1_B1 +SPI0_MOSI = pin.GPIO1_B2 +SPI0_CS0 = pin.GPIO1_B4 +# SPI1_M1 +SPI1_CLK = pin.GPIO3_C1 +SPI1_MISO = pin.GPIO3_C0 +SPI1_MOSI = pin.GPIO3_B7 +SPI1_CS1 = pin.GPIO3_C3 +# SPI4_M2 +SPI4_SCLK = pin.GPIO1_D6 +SPI4_MISO = pin.GPIO1_D7 +SPI4_MOSI = pin.GPIO1_D6 +SPI4_CS0 = pin.GPIO1_D7 +# SPI5_M1 +SPI5_SCLK = pin.GPIO3_B1 +SPI5_MISO = pin.GPIO3_B0 +SPI5_MOSI = pin.GPIO3_B7 +SPI5_CS1 = pin.GPIO3_C3 + +# Default SPI -> SPI4_M2 +MOSI = SPI4_MOSI +MISO = SPI4_MISO +SCLK = SPI4_SCLK +CS = SPI4_CS0 + +# PWM +# PWM2_M1 +PWM2 = pin.GPIO3_B1 +# PWM7_M0 +PWM7 = pin.GPIO0_D0 +# PWM9_M0 +PWM9 = pin.GPIO3_B0 +# PWM11_M1 +PWM11 = pin.GPIO4_B4 +# PWM12_M1 +PWM12 = pin.GPIO4_B5 +# PWM14_M2 +PWM14 = pin.GPIO1_D6 +# PWM15_M0 +PWM15 = pin.GPIO3_C3 + diff --git a/src/board.py b/src/board.py index 88ae1da9..9243fee4 100644 --- a/src/board.py +++ b/src/board.py @@ -434,6 +434,9 @@ elif board_id == ap_board.VIVID_UNIT: from adafruit_blinka.board.vivid_unit import * +elif board_id == ap_board.INDIEDROID_NOVA: + from adafruit_blinka.board.ameridroid.indiedroid_nova import * + elif "sphinx" in sys.modules: pass From 0539b27e2a2b84a101d61fd8ee8bde462747af4b Mon Sep 17 00:00:00 2001 From: landall Date: Tue, 24 Sep 2024 03:47:23 +0800 Subject: [PATCH 13/19] i2c support modify i2c2_m0 to i2c2_m1 add some definition for i2c --- .../board/orangepi/orangepi3b.py | 23 +++++++++++++++++-- .../microcontroller/rockchip/rk3566/pin.py | 3 ++- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/adafruit_blinka/board/orangepi/orangepi3b.py b/src/adafruit_blinka/board/orangepi/orangepi3b.py index 2ea83212..a8e1109b 100644 --- a/src/adafruit_blinka/board/orangepi/orangepi3b.py +++ b/src/adafruit_blinka/board/orangepi/orangepi3b.py @@ -49,8 +49,27 @@ D40 = pin.GPIO3_D1 # UART -#UART4_TX = pin.GPIO1_B0 -#UART4_RX = pin.GPIO1_A7 +UART2_TX_M0 = pin.GPIO0_D1 +UART2_RX_M0 = pin.GPIO0_D0 + +UART7_TX_M2 = pin.GPIO4_A2 +UART7_RX_M2 = pin.GPIO4_A3 + +UART3_TX_M0 = pin.GPIO1_A1 +UART3_RX_M0 = pin.GPIO1_A0 + +UART9_TX_M2 = pin.GPIO4_A4 +UART9_RX_M2 = pin.GPIO4_A5 + +# I2C +I2C2_SCL_M1 = pin.I2C2_SCL_M1 +I2C2_SDA_M1 = pin.I2C2_SDA_M1 +I2C3_SCL_M0 = pin.I2C3_SCL_M0 +I2C3_SDA_M0 = pin.I2C3_SDA_M0 + +# Default I2C +SCL = I2C2_SCL_M1 +SDA = I2C2_SDA_M1 # SPI SPI3_MISO = pin.SPI3_MISO_M0 diff --git a/src/adafruit_blinka/microcontroller/rockchip/rk3566/pin.py b/src/adafruit_blinka/microcontroller/rockchip/rk3566/pin.py index 5b51baf6..5554d5eb 100644 --- a/src/adafruit_blinka/microcontroller/rockchip/rk3566/pin.py +++ b/src/adafruit_blinka/microcontroller/rockchip/rk3566/pin.py @@ -178,7 +178,8 @@ # ordered as i2cId, SCL, SDA i2cPorts = [ (1, I2C1_SCL, I2C1_SDA), - (2, I2C2_SCL_M0, I2C2_SDA_M0), + #(2, I2C2_SCL_M0, I2C2_SDA_M0), + (2, I2C2_SCL_M1, I2C2_SDA_M1), (3, I2C3_SCL_M0, I2C3_SDA_M0), (4, I2C4_SCL_M0, I2C4_SDA_M0), (5, I2C5_SCL_M0, I2C5_SDA_M0), From 9d833e0a0403dc60e16f3f3b75259a73c80de4f4 Mon Sep 17 00:00:00 2001 From: foamyguy Date: Mon, 23 Sep 2024 18:32:04 -0500 Subject: [PATCH 14/19] code format --- src/adafruit_blinka/board/orangepi/orangepi3b.py | 3 +-- src/adafruit_blinka/microcontroller/rockchip/rk3566/pin.py | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/adafruit_blinka/board/orangepi/orangepi3b.py b/src/adafruit_blinka/board/orangepi/orangepi3b.py index a8e1109b..7ec49ade 100644 --- a/src/adafruit_blinka/board/orangepi/orangepi3b.py +++ b/src/adafruit_blinka/board/orangepi/orangepi3b.py @@ -36,7 +36,7 @@ D27 = pin.I2C3_SDA_M0 D28 = pin.I2C3_SCL_M0 D29 = pin.GPIO4_A5 -#D30 = GND +# D30 = GND D31 = pin.GPIO3_D4 D32 = pin.GPIO4_C0 D33 = pin.GPIO3_D7 @@ -82,4 +82,3 @@ MISO = SPI3_MISO SCLK = SPI3_CLK CS = SPI3_CS0 - diff --git a/src/adafruit_blinka/microcontroller/rockchip/rk3566/pin.py b/src/adafruit_blinka/microcontroller/rockchip/rk3566/pin.py index 5554d5eb..e95f390e 100644 --- a/src/adafruit_blinka/microcontroller/rockchip/rk3566/pin.py +++ b/src/adafruit_blinka/microcontroller/rockchip/rk3566/pin.py @@ -178,7 +178,7 @@ # ordered as i2cId, SCL, SDA i2cPorts = [ (1, I2C1_SCL, I2C1_SDA), - #(2, I2C2_SCL_M0, I2C2_SDA_M0), + # (2, I2C2_SCL_M0, I2C2_SDA_M0), (2, I2C2_SCL_M1, I2C2_SDA_M1), (3, I2C3_SCL_M0, I2C3_SDA_M0), (4, I2C4_SCL_M0, I2C4_SDA_M0), From e4139a83d336ab86f6185b0e5639c525d3d56bb2 Mon Sep 17 00:00:00 2001 From: rippanda12 Date: Sun, 6 Oct 2024 16:48:47 +0300 Subject: [PATCH 15/19] Chore: Fix formatting --- src/adafruit_blinka/board/ameridroid/indiedroid_nova.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/adafruit_blinka/board/ameridroid/indiedroid_nova.py b/src/adafruit_blinka/board/ameridroid/indiedroid_nova.py index 69f02e53..ff2501e3 100644 --- a/src/adafruit_blinka/board/ameridroid/indiedroid_nova.py +++ b/src/adafruit_blinka/board/ameridroid/indiedroid_nova.py @@ -132,4 +132,3 @@ PWM14 = pin.GPIO1_D6 # PWM15_M0 PWM15 = pin.GPIO3_C3 - From caa687360b643200967a5213931ea39cf68e21cb Mon Sep 17 00:00:00 2001 From: Yuyu <62864694+mmontol@users.noreply.github.com> Date: Thu, 10 Oct 2024 11:33:24 +0800 Subject: [PATCH 16/19] Add missing I2C6 to i2cPorts --- src/adafruit_blinka/microcontroller/rockchip/rk3588/pin.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/adafruit_blinka/microcontroller/rockchip/rk3588/pin.py b/src/adafruit_blinka/microcontroller/rockchip/rk3588/pin.py index 81c9b162..3abb3b80 100644 --- a/src/adafruit_blinka/microcontroller/rockchip/rk3588/pin.py +++ b/src/adafruit_blinka/microcontroller/rockchip/rk3588/pin.py @@ -241,6 +241,7 @@ (3, I2C3_SCL_M1, I2C3_SDA_M1), (4, I2C4_SCL_M3, I2C4_SDA_M3), (5, I2C5_SCL_M3, I2C5_SDA_M3), + (6, I2C6_SCL_M3, I2C6_SDA_M3), (7, I2C7_SCL_M3, I2C7_SDA_M3), (8, I2C8_SCL_M2, I2C8_SDA_M2), (8, I2C8_SCL_M4, I2C8_SDA_M4), From 380b4e9c3d12554b2915a813de1942ec0519dd56 Mon Sep 17 00:00:00 2001 From: landall Date: Tue, 22 Oct 2024 15:21:10 +0800 Subject: [PATCH 17/19] Update pin.py stored the wrongly commented lines to define 2 I2C port with the same channel id. --- src/adafruit_blinka/microcontroller/rockchip/rk3566/pin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/adafruit_blinka/microcontroller/rockchip/rk3566/pin.py b/src/adafruit_blinka/microcontroller/rockchip/rk3566/pin.py index e95f390e..bfb30138 100644 --- a/src/adafruit_blinka/microcontroller/rockchip/rk3566/pin.py +++ b/src/adafruit_blinka/microcontroller/rockchip/rk3566/pin.py @@ -178,7 +178,7 @@ # ordered as i2cId, SCL, SDA i2cPorts = [ (1, I2C1_SCL, I2C1_SDA), - # (2, I2C2_SCL_M0, I2C2_SDA_M0), + (2, I2C2_SCL_M0, I2C2_SDA_M0), (2, I2C2_SCL_M1, I2C2_SDA_M1), (3, I2C3_SCL_M0, I2C3_SDA_M0), (4, I2C4_SCL_M0, I2C4_SDA_M0), From e61bb98155e8c77c201573bbe347a259b3d2474f Mon Sep 17 00:00:00 2001 From: landall Date: Thu, 24 Oct 2024 05:32:16 +0800 Subject: [PATCH 18/19] Update Copyright for orangepi3b.py --- src/adafruit_blinka/board/orangepi/orangepi3b.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/adafruit_blinka/board/orangepi/orangepi3b.py b/src/adafruit_blinka/board/orangepi/orangepi3b.py index 7ec49ade..2c2e379e 100644 --- a/src/adafruit_blinka/board/orangepi/orangepi3b.py +++ b/src/adafruit_blinka/board/orangepi/orangepi3b.py @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: 2021 Melissa LeBlanc-Williams for Adafruit Industries +# SPDX-FileCopyrightText: 2024 cst_zf for Adafruit Industries # # SPDX-License-Identifier: MIT """Pin definitions for the Orangepi 3B.""" From 38fa646294a9e8c628b12a8f6f3d803d31992f98 Mon Sep 17 00:00:00 2001 From: foamyguy Date: Thu, 24 Oct 2024 15:09:40 -0500 Subject: [PATCH 19/19] update copyright --- src/adafruit_blinka/board/orangepi/orangepi3b.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/adafruit_blinka/board/orangepi/orangepi3b.py b/src/adafruit_blinka/board/orangepi/orangepi3b.py index 2c2e379e..ff4eee04 100644 --- a/src/adafruit_blinka/board/orangepi/orangepi3b.py +++ b/src/adafruit_blinka/board/orangepi/orangepi3b.py @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: 2024 cst_zf for Adafruit Industries +# SPDX-FileCopyrightText: 2024 cst_zf # # SPDX-License-Identifier: MIT """Pin definitions for the Orangepi 3B."""