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.")
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:
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))
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
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 = []