X-Git-Url: https://git.ayoreis.com/Adafruit_Blinka-hackapet.git/blobdiff_plain/2092c8bddf8d8a89f4325df1c268138f22cac53f..3746b1b4aef900105cc9cfa19cada6692d5eb94e:/src/adafruit_blinka/microcontroller/allwinner/h618/pin.py diff --git a/src/adafruit_blinka/microcontroller/allwinner/h618/pin.py b/src/adafruit_blinka/microcontroller/allwinner/h618/pin.py index fdbdcc6..1019b59 100644 --- a/src/adafruit_blinka/microcontroller/allwinner/h618/pin.py +++ b/src/adafruit_blinka/microcontroller/allwinner/h618/pin.py @@ -2,12 +2,14 @@ # # 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): + """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.") @@ -16,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: @@ -83,6 +86,7 @@ TWI3_SCL = PG17 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 +128,7 @@ PI10 = Pin((__chip_num, 266)) 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 +155,9 @@ uartPorts = ( (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), +]