moved a bunch of garbage (things that have nothing to do in root) to _trash
This commit is contained in:
parent
d094982b2c
commit
3226ed29ec
2610 changed files with 0 additions and 0 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,164 @@
|
|||
# SPDX-FileCopyrightText: 2021 Melissa LeBlanc-Williams for Adafruit Industries
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
"""
|
||||
G12A, G12B, and SM1 Common Definitions
|
||||
Ref:
|
||||
Linux kernel 4.9.y (hardkernel)
|
||||
linux/include/dt-bindings/gpio/meson-g12a-gpio.h
|
||||
Linux kernel 5.4.y (mainline)
|
||||
linux/include/dt-bindings/gpio/meson-g12a-gpio.h
|
||||
linux/arch/arm64/boot/dts/amlogic/meson-g12-common.dtsi
|
||||
"""
|
||||
|
||||
import gpiod
|
||||
from adafruit_blinka.microcontroller.alias import get_dts_alias
|
||||
from adafruit_blinka.microcontroller.generic_linux.libgpiod_pin import Pin
|
||||
|
||||
chip0 = gpiod.Chip("0")
|
||||
chip1 = gpiod.Chip("1")
|
||||
|
||||
if chip0.num_lines() < 20:
|
||||
aobus = 0
|
||||
periphs = 1
|
||||
periphs_offset = chip1.num_lines() - 85
|
||||
else:
|
||||
aobus = 1
|
||||
periphs = 0
|
||||
periphs_offset = chip0.num_lines() - 85
|
||||
|
||||
chip0.close()
|
||||
chip1.close()
|
||||
|
||||
GPIOAO_0 = GPIO496 = Pin((aobus, 0))
|
||||
GPIOAO_1 = GPIO497 = Pin((aobus, 1))
|
||||
GPIOAO_2 = GPIO498 = Pin((aobus, 2))
|
||||
GPIOAO_3 = GPIO499 = Pin((aobus, 3))
|
||||
GPIOAO_4 = GPIO500 = Pin((aobus, 4))
|
||||
GPIOAO_5 = GPIO501 = Pin((aobus, 5))
|
||||
GPIOAO_6 = GPIO502 = Pin((aobus, 6))
|
||||
GPIOAO_7 = GPIO503 = Pin((aobus, 7))
|
||||
GPIOAO_8 = GPIO504 = Pin((aobus, 8))
|
||||
GPIOAO_9 = GPIO505 = Pin((aobus, 9))
|
||||
GPIOAO_10 = GPIO506 = Pin((aobus, 10))
|
||||
GPIOAO_11 = GPIO507 = Pin((aobus, 11))
|
||||
|
||||
GPIOE_0 = GPIO508 = Pin((aobus, 12))
|
||||
GPIOE_1 = GPIO509 = Pin((aobus, 13))
|
||||
GPIOE_2 = GPIO510 = Pin((aobus, 14))
|
||||
|
||||
GPIOZ_0 = GPIO427 = Pin((periphs, 0 + periphs_offset))
|
||||
GPIOZ_1 = GPIO428 = Pin((periphs, 1 + periphs_offset))
|
||||
GPIOZ_2 = GPIO429 = Pin((periphs, 2 + periphs_offset))
|
||||
GPIOZ_3 = GPIO430 = Pin((periphs, 3 + periphs_offset))
|
||||
GPIOZ_4 = GPIO431 = Pin((periphs, 4 + periphs_offset))
|
||||
GPIOZ_5 = GPIO432 = Pin((periphs, 5 + periphs_offset))
|
||||
GPIOZ_6 = GPIO433 = Pin((periphs, 6 + periphs_offset))
|
||||
GPIOZ_7 = GPIO434 = Pin((periphs, 7 + periphs_offset))
|
||||
GPIOZ_8 = GPIO435 = Pin((periphs, 8 + periphs_offset))
|
||||
GPIOZ_9 = GPIO436 = Pin((periphs, 9 + periphs_offset))
|
||||
GPIOZ_10 = GPIO437 = Pin((periphs, 10 + periphs_offset))
|
||||
GPIOZ_11 = GPIO438 = Pin((periphs, 11 + periphs_offset))
|
||||
GPIOZ_12 = GPIO439 = Pin((periphs, 12 + periphs_offset))
|
||||
GPIOZ_13 = GPIO440 = Pin((periphs, 13 + periphs_offset))
|
||||
GPIOZ_14 = GPIO441 = Pin((periphs, 14 + periphs_offset))
|
||||
GPIOZ_15 = GPIO442 = Pin((periphs, 15 + periphs_offset))
|
||||
|
||||
GPIOH_0 = GPIO443 = Pin((periphs, 16 + periphs_offset))
|
||||
GPIOH_1 = GPIO444 = Pin((periphs, 17 + periphs_offset))
|
||||
GPIOH_2 = GPIO445 = Pin((periphs, 18 + periphs_offset))
|
||||
GPIOH_3 = GPIO446 = Pin((periphs, 19 + periphs_offset))
|
||||
GPIOH_4 = GPIO447 = Pin((periphs, 20 + periphs_offset))
|
||||
GPIOH_5 = GPIO448 = Pin((periphs, 21 + periphs_offset))
|
||||
GPIOH_6 = GPIO449 = Pin((periphs, 22 + periphs_offset))
|
||||
GPIOH_7 = GPIO450 = Pin((periphs, 23 + periphs_offset))
|
||||
GPIOH_8 = GPIO451 = Pin((periphs, 24 + periphs_offset))
|
||||
|
||||
BOOT_0 = GPIO452 = Pin((periphs, 25 + periphs_offset))
|
||||
BOOT_1 = GPIO453 = Pin((periphs, 26 + periphs_offset))
|
||||
BOOT_2 = GPIO454 = Pin((periphs, 27 + periphs_offset))
|
||||
BOOT_3 = GPIO455 = Pin((periphs, 28 + periphs_offset))
|
||||
BOOT_4 = GPIO456 = Pin((periphs, 29 + periphs_offset))
|
||||
BOOT_5 = GPIO457 = Pin((periphs, 30 + periphs_offset))
|
||||
BOOT_6 = GPIO458 = Pin((periphs, 31 + periphs_offset))
|
||||
BOOT_7 = GPIO459 = Pin((periphs, 32 + periphs_offset))
|
||||
BOOT_8 = GPIO460 = Pin((periphs, 33 + periphs_offset))
|
||||
BOOT_9 = GPIO461 = Pin((periphs, 34 + periphs_offset))
|
||||
BOOT_10 = GPIO462 = Pin((periphs, 35 + periphs_offset))
|
||||
BOOT_11 = GPIO463 = Pin((periphs, 36 + periphs_offset))
|
||||
BOOT_12 = GPIO464 = Pin((periphs, 37 + periphs_offset))
|
||||
BOOT_13 = GPIO465 = Pin((periphs, 38 + periphs_offset))
|
||||
BOOT_14 = GPIO466 = Pin((periphs, 39 + periphs_offset))
|
||||
BOOT_15 = GPIO467 = Pin((periphs, 40 + periphs_offset))
|
||||
|
||||
GPIOC_0 = GPIO468 = Pin((periphs, 41 + periphs_offset))
|
||||
GPIOC_1 = GPIO469 = Pin((periphs, 42 + periphs_offset))
|
||||
GPIOC_2 = GPIO470 = Pin((periphs, 43 + periphs_offset))
|
||||
GPIOC_3 = GPIO471 = Pin((periphs, 44 + periphs_offset))
|
||||
GPIOC_4 = GPIO472 = Pin((periphs, 45 + periphs_offset))
|
||||
GPIOC_5 = GPIO473 = Pin((periphs, 46 + periphs_offset))
|
||||
GPIOC_6 = GPIO474 = Pin((periphs, 47 + periphs_offset))
|
||||
GPIOC_7 = GPIO475 = Pin((periphs, 48 + periphs_offset))
|
||||
|
||||
GPIOA_0 = GPIO460 = Pin((periphs, 49 + periphs_offset))
|
||||
GPIOA_1 = GPIO461 = Pin((periphs, 50 + periphs_offset))
|
||||
GPIOA_2 = GPIO462 = Pin((periphs, 51 + periphs_offset))
|
||||
GPIOA_3 = GPIO463 = Pin((periphs, 52 + periphs_offset))
|
||||
GPIOA_4 = GPIO464 = Pin((periphs, 53 + periphs_offset))
|
||||
GPIOA_5 = GPIO465 = Pin((periphs, 54 + periphs_offset))
|
||||
GPIOA_6 = GPIO466 = Pin((periphs, 55 + periphs_offset))
|
||||
GPIOA_7 = GPIO467 = Pin((periphs, 56 + periphs_offset))
|
||||
GPIOA_8 = GPIO468 = Pin((periphs, 57 + periphs_offset))
|
||||
GPIOA_9 = GPIO469 = Pin((periphs, 58 + periphs_offset))
|
||||
GPIOA_10 = GPIO470 = Pin((periphs, 59 + periphs_offset))
|
||||
GPIOA_11 = GPIO471 = Pin((periphs, 60 + periphs_offset))
|
||||
GPIOA_12 = GPIO472 = Pin((periphs, 61 + periphs_offset))
|
||||
GPIOA_13 = GPIO473 = Pin((periphs, 62 + periphs_offset))
|
||||
GPIOA_14 = GPIO474 = Pin((periphs, 63 + periphs_offset))
|
||||
GPIOA_15 = GPIO475 = Pin((periphs, 64 + periphs_offset))
|
||||
|
||||
GPIOX_0 = GPIO476 = Pin((periphs, 65 + periphs_offset))
|
||||
GPIOX_1 = GPIO477 = Pin((periphs, 66 + periphs_offset))
|
||||
GPIOX_2 = GPIO478 = Pin((periphs, 67 + periphs_offset))
|
||||
GPIOX_3 = GPIO479 = Pin((periphs, 68 + periphs_offset))
|
||||
GPIOX_4 = GPIO480 = Pin((periphs, 69 + periphs_offset))
|
||||
GPIOX_5 = GPIO481 = Pin((periphs, 70 + periphs_offset))
|
||||
GPIOX_6 = GPIO482 = Pin((periphs, 71 + periphs_offset))
|
||||
GPIOX_7 = GPIO483 = Pin((periphs, 72 + periphs_offset))
|
||||
GPIOX_8 = GPIO484 = Pin((periphs, 73 + periphs_offset))
|
||||
GPIOX_9 = GPIO485 = Pin((periphs, 74 + periphs_offset))
|
||||
GPIOX_10 = GPIO486 = Pin((periphs, 75 + periphs_offset))
|
||||
GPIOX_11 = GPIO487 = Pin((periphs, 76 + periphs_offset))
|
||||
GPIOX_12 = GPIO488 = Pin((periphs, 77 + periphs_offset))
|
||||
GPIOX_13 = GPIO489 = Pin((periphs, 78 + periphs_offset))
|
||||
GPIOX_14 = GPIO490 = Pin((periphs, 79 + periphs_offset))
|
||||
GPIOX_15 = GPIO491 = Pin((periphs, 80 + periphs_offset))
|
||||
GPIOX_16 = GPIO492 = Pin((periphs, 81 + periphs_offset))
|
||||
GPIOX_17 = GPIO493 = Pin((periphs, 82 + periphs_offset))
|
||||
GPIOX_18 = GPIO494 = Pin((periphs, 83 + periphs_offset))
|
||||
GPIOX_19 = GPIO495 = Pin((periphs, 84 + periphs_offset))
|
||||
|
||||
SPI0_SCLK = GPIOA_1
|
||||
SPI0_MCLK0 = GPIOA_0
|
||||
SPI0_SDO = GPIOA_3
|
||||
SPI0_SDI = GPIOA_4
|
||||
|
||||
# ordered as spiId, sckId, mosiId, misoId
|
||||
spiPorts = ((0, SPI0_SCLK, SPI0_MCLK0, SPI0_SDO, SPI0_SDI),)
|
||||
|
||||
UART1_TX = GPIOH_7
|
||||
UART1_RX = GPIOH_6
|
||||
|
||||
# ordered as uartId, txId, rxId
|
||||
uartPorts = ((1, UART1_TX, UART1_RX),)
|
||||
|
||||
# ordered as i2cId, sclId, sdaId
|
||||
i2cPorts = []
|
||||
|
||||
alias = get_dts_alias("ff805000.i2c")
|
||||
if alias is not None:
|
||||
globals()[alias + "_SCL"] = GPIOX_18
|
||||
globals()[alias + "_SDA"] = GPIOX_17
|
||||
i2cPorts.append((int(alias[3]), GPIOX_18, GPIOX_17))
|
||||
|
||||
i2cPorts = tuple(i2cPorts)
|
|
@ -0,0 +1,183 @@
|
|||
# SPDX-FileCopyrightText: 2021 Melissa LeBlanc-Williams for Adafruit Industries
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
"""Custom PulseIn Class to read PWM signals"""
|
||||
import time
|
||||
import subprocess
|
||||
import os
|
||||
import atexit
|
||||
import random
|
||||
import struct
|
||||
import sysv_ipc
|
||||
|
||||
DEBUG = False
|
||||
queues = []
|
||||
procs = []
|
||||
|
||||
|
||||
# The message queues live outside of python space, and must be formally cleaned!
|
||||
def final():
|
||||
"""In case the program is cancelled or quit, we need to clean up the PulseIn
|
||||
helper process and also the message queue, this is called at exit to do so"""
|
||||
if DEBUG:
|
||||
print("Cleaning up message queues", queues)
|
||||
print("Cleaning up processes", procs)
|
||||
for q in queues:
|
||||
q.remove()
|
||||
for proc in procs:
|
||||
proc.terminate()
|
||||
|
||||
|
||||
atexit.register(final)
|
||||
|
||||
|
||||
# pylint: disable=c-extension-no-member
|
||||
class PulseIn:
|
||||
"""PulseIn Class to read PWM signals"""
|
||||
|
||||
def __init__(self, pin, maxlen=2, idle_state=False):
|
||||
"""Create a PulseIn object associated with the given pin.
|
||||
The object acts as a read-only sequence of pulse lengths with
|
||||
a given max length. When it is active, new pulse lengths are
|
||||
added to the end of the list. When there is no more room
|
||||
(len() == maxlen) the oldest pulse length is removed to make room."""
|
||||
self._pin = pin
|
||||
self._maxlen = maxlen
|
||||
self._idle_state = idle_state
|
||||
self._queue_key = random.randint(1, 9999)
|
||||
try:
|
||||
self._mq = sysv_ipc.MessageQueue(None, flags=sysv_ipc.IPC_CREX)
|
||||
if DEBUG:
|
||||
print("Message Queue Key: ", self._mq.key)
|
||||
queues.append(self._mq)
|
||||
except sysv_ipc.ExistentialError:
|
||||
raise RuntimeError(
|
||||
"Message queue creation failed"
|
||||
) from sysv_ipc.ExistentialError
|
||||
|
||||
# Check if OS is 64-bit
|
||||
if struct.calcsize("P") * 8 == 64: # pylint: disable=no-member
|
||||
libgpiod_filename = "libgpiod_pulsein64"
|
||||
else:
|
||||
libgpiod_filename = "libgpiod_pulsein"
|
||||
|
||||
dir_path = os.path.dirname(os.path.realpath(__file__))
|
||||
cmd = [
|
||||
dir_path + "/" + libgpiod_filename,
|
||||
"--pulses",
|
||||
str(maxlen),
|
||||
"--queue",
|
||||
str(self._mq.key),
|
||||
]
|
||||
if idle_state:
|
||||
cmd.append("-i")
|
||||
cmd.append("gpiochip0")
|
||||
cmd.append(str(pin))
|
||||
if DEBUG:
|
||||
print(cmd)
|
||||
|
||||
self._process = subprocess.Popen(cmd) # pylint: disable=consider-using-with
|
||||
procs.append(self._process)
|
||||
|
||||
# wait for it to start up
|
||||
if DEBUG:
|
||||
print("Waiting for startup success message from subprocess")
|
||||
message = self._wait_receive_msg(timeout=0.25)
|
||||
if message[0] != b"!":
|
||||
raise RuntimeError("Could not establish message queue with subprocess")
|
||||
self._paused = False
|
||||
|
||||
# pylint: disable=redefined-builtin
|
||||
def _wait_receive_msg(self, timeout=0, type=2):
|
||||
"""Internal helper that will wait for new messages of a given type,
|
||||
and throw an exception on timeout"""
|
||||
if timeout > 0:
|
||||
stamp = time.monotonic()
|
||||
while (time.monotonic() - stamp) < timeout:
|
||||
try:
|
||||
message = self._mq.receive(block=False, type=type)
|
||||
return message
|
||||
except sysv_ipc.BusyError:
|
||||
time.sleep(0.001) # wait a bit then retry!
|
||||
# uh-oh timed out
|
||||
raise RuntimeError(
|
||||
"Timed out waiting for PulseIn message. Make sure libgpiod is installed."
|
||||
)
|
||||
message = self._mq.receive(block=True, type=type)
|
||||
return message
|
||||
|
||||
# pylint: enable=redefined-builtin
|
||||
|
||||
def deinit(self):
|
||||
"""Deinitialises the PulseIn and releases any hardware and software
|
||||
resources for reuse."""
|
||||
# Clean up after ourselves
|
||||
self._process.terminate()
|
||||
procs.remove(self._process)
|
||||
self._mq.remove()
|
||||
queues.remove(self._mq)
|
||||
|
||||
def __enter__(self):
|
||||
"""No-op used by Context Managers."""
|
||||
return self
|
||||
|
||||
def __exit__(self, exc_type, exc_value, tb):
|
||||
"""Automatically deinitializes the hardware when exiting a context."""
|
||||
self.deinit()
|
||||
|
||||
def resume(self, trigger_duration=0):
|
||||
"""Resumes pulse capture after an optional trigger pulse."""
|
||||
if trigger_duration != 0:
|
||||
self._mq.send("t%d" % trigger_duration, True, type=1)
|
||||
else:
|
||||
self._mq.send("r", True, type=1)
|
||||
self._paused = False
|
||||
|
||||
def pause(self):
|
||||
"""Pause pulse capture"""
|
||||
self._mq.send("p", True, type=1)
|
||||
self._paused = True
|
||||
|
||||
@property
|
||||
def paused(self):
|
||||
"""True when pulse capture is paused as a result of pause() or
|
||||
an error during capture such as a signal that is too fast."""
|
||||
return self._paused
|
||||
|
||||
@property
|
||||
def maxlen(self):
|
||||
"""The maximum length of the PulseIn. When len() is equal to maxlen,
|
||||
it is unclear which pulses are active and which are idle."""
|
||||
return self._maxlen
|
||||
|
||||
def clear(self):
|
||||
"""Clears all captured pulses"""
|
||||
self._mq.send("c", True, type=1)
|
||||
|
||||
def popleft(self):
|
||||
"""Removes and returns the oldest read pulse."""
|
||||
self._mq.send("^", True, type=1)
|
||||
message = self._wait_receive_msg()
|
||||
reply = int(message[0].decode("utf-8"))
|
||||
# print(reply)
|
||||
if reply == -1:
|
||||
raise IndexError("pop from empty list")
|
||||
return reply
|
||||
|
||||
def __len__(self):
|
||||
"""Returns the current pulse length"""
|
||||
self._mq.send("l", True, type=1)
|
||||
message = self._wait_receive_msg()
|
||||
return int(message[0].decode("utf-8"))
|
||||
|
||||
# pylint: disable=redefined-builtin
|
||||
def __getitem__(self, index, type=None):
|
||||
"""Returns the value at the given index or values in slice."""
|
||||
self._mq.send("i%d" % index, True, type=1)
|
||||
message = self._wait_receive_msg()
|
||||
ret = int(message[0].decode("utf-8"))
|
||||
if ret == -1:
|
||||
raise IndexError("list index out of range")
|
||||
return ret
|
||||
|
||||
# pylint: enable=redefined-builtin
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,3 @@
|
|||
# SPDX-FileCopyrightText: 2021 Melissa LeBlanc-Williams for Adafruit Industries
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
Binary file not shown.
|
@ -0,0 +1,3 @@
|
|||
# SPDX-FileCopyrightText: 2021 Melissa LeBlanc-Williams for Adafruit Industries
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,191 @@
|
|||
# SPDX-FileCopyrightText: 2021 Melissa LeBlanc-Williams for Adafruit Industries
|
||||
# SPDX-FileCopyrightText: 2023 Steve Jeong for Hardkernel
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
"""
|
||||
G12A, G12B, and SM1 Common Definitions
|
||||
Ref:
|
||||
Linux kernel 4.9.y (hardkernel)
|
||||
linux/include/dt-bindings/gpio/meson-g12a-gpio.h
|
||||
Linux kernel 5.4.y (mainline)
|
||||
linux/include/dt-bindings/gpio/meson-g12a-gpio.h
|
||||
linux/arch/arm64/boot/dts/amlogic/meson-g12-common.dtsi
|
||||
"""
|
||||
|
||||
from adafruit_blinka.agnostic import detector
|
||||
from adafruit_blinka.microcontroller.alias import get_dts_alias, get_pwm_chipid
|
||||
from adafruit_blinka.microcontroller.generic_linux.libgpiod_pin import Pin
|
||||
from adafruit_blinka.microcontroller.generic_linux.libgpiod_chip import Chip
|
||||
|
||||
chip0 = Chip("0")
|
||||
chip1 = Chip("1")
|
||||
|
||||
chip0lines = chip0.num_lines
|
||||
chip1lines = chip1.num_lines
|
||||
|
||||
if chip0lines < 20:
|
||||
aobus = 0
|
||||
periphs = 1
|
||||
periphs_offset = chip1lines - 85
|
||||
else:
|
||||
aobus = 1
|
||||
periphs = 0
|
||||
periphs_offset = chip0lines - 85
|
||||
|
||||
del chip0
|
||||
del chip1
|
||||
|
||||
GPIOAO_0 = GPIO496 = Pin((aobus, 0))
|
||||
GPIOAO_1 = GPIO497 = Pin((aobus, 1))
|
||||
GPIOAO_2 = GPIO498 = Pin((aobus, 2))
|
||||
GPIOAO_3 = GPIO499 = Pin((aobus, 3))
|
||||
GPIOAO_4 = GPIO500 = Pin((aobus, 4))
|
||||
GPIOAO_5 = GPIO501 = Pin((aobus, 5))
|
||||
GPIOAO_6 = GPIO502 = Pin((aobus, 6))
|
||||
GPIOAO_7 = GPIO503 = Pin((aobus, 7))
|
||||
GPIOAO_8 = GPIO504 = Pin((aobus, 8))
|
||||
GPIOAO_9 = GPIO505 = Pin((aobus, 9))
|
||||
GPIOAO_10 = GPIO506 = Pin((aobus, 10))
|
||||
GPIOAO_11 = GPIO507 = Pin((aobus, 11))
|
||||
GPIOE_0 = GPIO508 = Pin((aobus, 12))
|
||||
GPIOE_1 = GPIO509 = Pin((aobus, 13))
|
||||
GPIOE_2 = GPIO510 = Pin((aobus, 14))
|
||||
GPIO_TEST_N = GPIO511 = Pin((aobus, 15))
|
||||
|
||||
GPIOH_0 = GPIO427 = Pin((periphs, 16 + periphs_offset))
|
||||
GPIOH_1 = GPIO428 = Pin((periphs, 17 + periphs_offset))
|
||||
GPIOH_2 = GPIO429 = Pin((periphs, 18 + periphs_offset))
|
||||
GPIOH_3 = GPIO430 = Pin((periphs, 19 + periphs_offset))
|
||||
GPIOH_4 = GPIO431 = Pin((periphs, 20 + periphs_offset))
|
||||
GPIOH_5 = GPIO432 = Pin((periphs, 21 + periphs_offset))
|
||||
GPIOH_6 = GPIO433 = Pin((periphs, 22 + periphs_offset))
|
||||
GPIOH_7 = GPIO434 = Pin((periphs, 23 + periphs_offset))
|
||||
GPIOH_8 = GPIO435 = Pin((periphs, 24 + periphs_offset))
|
||||
|
||||
GPIOA_0 = GPIO460 = Pin((periphs, 49 + periphs_offset))
|
||||
GPIOA_1 = GPIO461 = Pin((periphs, 50 + periphs_offset))
|
||||
GPIOA_2 = GPIO462 = Pin((periphs, 51 + periphs_offset))
|
||||
GPIOA_3 = GPIO463 = Pin((periphs, 52 + periphs_offset))
|
||||
GPIOA_4 = GPIO464 = Pin((periphs, 53 + periphs_offset))
|
||||
GPIOA_5 = GPIO465 = Pin((periphs, 54 + periphs_offset))
|
||||
GPIOA_6 = GPIO466 = Pin((periphs, 55 + periphs_offset))
|
||||
GPIOA_7 = GPIO467 = Pin((periphs, 56 + periphs_offset))
|
||||
GPIOA_8 = GPIO468 = Pin((periphs, 57 + periphs_offset))
|
||||
GPIOA_9 = GPIO469 = Pin((periphs, 58 + periphs_offset))
|
||||
GPIOA_10 = GPIO470 = Pin((periphs, 59 + periphs_offset))
|
||||
GPIOA_11 = GPIO471 = Pin((periphs, 60 + periphs_offset))
|
||||
GPIOA_12 = GPIO472 = Pin((periphs, 61 + periphs_offset))
|
||||
GPIOA_13 = GPIO473 = Pin((periphs, 62 + periphs_offset))
|
||||
GPIOA_14 = GPIO474 = Pin((periphs, 63 + periphs_offset))
|
||||
GPIOA_15 = GPIO475 = Pin((periphs, 64 + periphs_offset))
|
||||
|
||||
GPIOX_0 = GPIO476 = Pin((periphs, 65 + periphs_offset))
|
||||
GPIOX_1 = GPIO477 = Pin((periphs, 66 + periphs_offset))
|
||||
GPIOX_2 = GPIO478 = Pin((periphs, 67 + periphs_offset))
|
||||
GPIOX_3 = GPIO479 = Pin((periphs, 68 + periphs_offset))
|
||||
GPIOX_4 = GPIO480 = Pin((periphs, 69 + periphs_offset))
|
||||
GPIOX_5 = GPIO481 = Pin((periphs, 70 + periphs_offset))
|
||||
GPIOX_6 = GPIO482 = Pin((periphs, 71 + periphs_offset))
|
||||
GPIOX_7 = GPIO483 = Pin((periphs, 72 + periphs_offset))
|
||||
GPIOX_8 = GPIO484 = Pin((periphs, 73 + periphs_offset))
|
||||
GPIOX_9 = GPIO485 = Pin((periphs, 74 + periphs_offset))
|
||||
GPIOX_10 = GPIO486 = Pin((periphs, 75 + periphs_offset))
|
||||
GPIOX_11 = GPIO487 = Pin((periphs, 76 + periphs_offset))
|
||||
GPIOX_12 = GPIO488 = Pin((periphs, 77 + periphs_offset))
|
||||
GPIOX_13 = GPIO489 = Pin((periphs, 78 + periphs_offset))
|
||||
GPIOX_14 = GPIO490 = Pin((periphs, 79 + periphs_offset))
|
||||
GPIOX_15 = GPIO491 = Pin((periphs, 80 + periphs_offset))
|
||||
GPIOX_16 = GPIO492 = Pin((periphs, 81 + periphs_offset))
|
||||
GPIOX_17 = GPIO493 = Pin((periphs, 82 + periphs_offset))
|
||||
GPIOX_18 = GPIO494 = Pin((periphs, 83 + periphs_offset))
|
||||
GPIOX_19 = GPIO495 = Pin((periphs, 84 + periphs_offset))
|
||||
|
||||
SPI0_SCLK = GPIOX_11
|
||||
SPI0_MISO = GPIOX_9
|
||||
SPI0_MOSI = GPIOX_8
|
||||
SPI0_CS0 = GPIOX_10
|
||||
|
||||
UART1_TX = GPIOX_12
|
||||
UART1_RX = GPIOX_13
|
||||
|
||||
# ordered as i2cId, sclId, sdaId
|
||||
i2cPorts = []
|
||||
|
||||
# ordered as spiId, sckId, mosiId, misoId
|
||||
spiPorts = ((0, SPI0_SCLK, SPI0_MOSI, SPI0_MISO),)
|
||||
|
||||
# SysFs pwm outputs, pwm channel and pin in first tuple
|
||||
pwmOuts = []
|
||||
|
||||
# ordered as uartId, txId, rxId
|
||||
uartPorts = [
|
||||
(1, UART1_TX, UART1_RX),
|
||||
]
|
||||
|
||||
# SysFS analog inputs, Ordered as analog analogInId, device, and channel
|
||||
analogIns = []
|
||||
|
||||
board = detector.board.id
|
||||
if board in ("ODROID_C4", "ODROID_N2"):
|
||||
alias = get_dts_alias("ffd1d000.i2c")
|
||||
if alias is not None:
|
||||
globals()[alias + "_SCL"] = GPIOX_18
|
||||
globals()[alias + "_SDA"] = GPIOX_17
|
||||
i2cPorts.append((int(alias[-1]), GPIOX_18, GPIOX_17))
|
||||
alias = get_dts_alias("ffd1c000.i2c")
|
||||
if alias is not None:
|
||||
globals()[alias + "_SCL"] = GPIOA_15
|
||||
globals()[alias + "_SDA"] = GPIOA_14
|
||||
i2cPorts.append((int(alias[-1]), GPIOA_15, GPIOA_14))
|
||||
alias = get_dts_alias("ffd24000.serial")
|
||||
if alias is not None:
|
||||
globals()[alias + "_TX"] = GPIOX_12
|
||||
globals()[alias + "_RX"] = GPIOX_13
|
||||
uartPorts.append((int(alias[-1]), GPIOX_12, GPIOX_13))
|
||||
alias = get_dts_alias("ffd23000.serial")
|
||||
if alias is not None:
|
||||
globals()[alias + "_TX"] = GPIOX_6
|
||||
globals()[alias + "_RX"] = GPIOX_7
|
||||
uartPorts.append((int(alias[-1]), GPIOX_6, GPIOX_7))
|
||||
|
||||
if board in ("ODROID_C4"):
|
||||
alias = get_pwm_chipid("ffd1b000.pwm")
|
||||
if alias is not None:
|
||||
globals()["PWMA"] = GPIOX_6
|
||||
globals()["PWMB"] = GPIOX_19
|
||||
pwmOuts.append(((int(alias[-1]), 0), GPIOX_6))
|
||||
pwmOuts.append(((int(alias[-1]), 1), GPIOX_19))
|
||||
alias = get_pwm_chipid("ffd1a000.pwm")
|
||||
if alias is not None:
|
||||
globals()["PWMC"] = GPIOX_5
|
||||
globals()["PWMD"] = GPIOX_3
|
||||
pwmOuts.append(((int(alias[-1]), 0), GPIOX_5))
|
||||
pwmOuts.append(((int(alias[-1]), 1), GPIOX_3))
|
||||
alias = get_pwm_chipid("ffd19000.pwm")
|
||||
if alias is not None:
|
||||
globals()["PWME"] = GPIOX_16
|
||||
globals()["PWMF"] = GPIOX_7
|
||||
pwmOuts.append(((int(alias[-1]), 0), GPIOX_16))
|
||||
pwmOuts.append(((int(alias[-1]), 1), GPIOX_7))
|
||||
analogIns.append((37, 0, 2))
|
||||
analogIns.append((40, 0, 0))
|
||||
if board in ("ODROID_N2"):
|
||||
alias = get_pwm_chipid("ffd1a000.pwm")
|
||||
if alias is not None:
|
||||
globals()["PWMC"] = GPIOX_5
|
||||
globals()["PWMD"] = GPIOX_6
|
||||
pwmOuts.append(((int(alias[-1]), 0), GPIOX_5))
|
||||
pwmOuts.append(((int(alias[-1]), 1), GPIOX_6))
|
||||
alias = get_pwm_chipid("ffd19000.pwm")
|
||||
if alias is not None:
|
||||
globals()["PWME"] = GPIOX_16
|
||||
globals()["PWMF"] = GPIOX_7
|
||||
pwmOuts.append(((int(alias[-1]), 0), GPIOX_16))
|
||||
pwmOuts.append(((int(alias[-1]), 1), GPIOX_7))
|
||||
analogIns.append((37, 0, 3))
|
||||
analogIns.append((40, 0, 2))
|
||||
|
||||
analogIns = tuple(analogIns)
|
||||
i2cPorts = tuple(i2cPorts)
|
||||
pwmOuts = tuple(pwmOuts)
|
||||
uartPorts = tuple(uartPorts)
|
|
@ -0,0 +1,185 @@
|
|||
# SPDX-FileCopyrightText: 2021 Melissa LeBlanc-Williams for Adafruit Industries
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
"""Custom PulseIn Class to read PWM signals"""
|
||||
import time
|
||||
import subprocess
|
||||
import os
|
||||
import atexit
|
||||
import random
|
||||
import sysv_ipc
|
||||
|
||||
DEBUG = False
|
||||
queues = []
|
||||
procs = []
|
||||
|
||||
|
||||
# The message queues live outside of python space, and must be formally cleaned!
|
||||
def final():
|
||||
"""In case the program is cancelled or quit, we need to clean up the PulseIn
|
||||
helper process and also the message queue, this is called at exit to do so"""
|
||||
if DEBUG:
|
||||
print("Cleaning up message queues", queues)
|
||||
print("Cleaning up processes", procs)
|
||||
for q in queues:
|
||||
q.remove()
|
||||
for proc in procs:
|
||||
proc.terminate()
|
||||
|
||||
|
||||
atexit.register(final)
|
||||
|
||||
|
||||
# pylint: disable=c-extension-no-member
|
||||
class PulseIn:
|
||||
"""PulseIn Class to read PWM signals"""
|
||||
|
||||
def __init__(self, pin, maxlen=2, idle_state=False):
|
||||
"""Create a PulseIn object associated with the given pin.
|
||||
The object acts as a read-only sequence of pulse lengths with
|
||||
a given max length. When it is active, new pulse lengths are
|
||||
added to the end of the list. When there is no more room
|
||||
(len() == maxlen) the oldest pulse length is removed to make room."""
|
||||
|
||||
if isinstance(pin.id, tuple):
|
||||
self._pin = str(pin.id[1])
|
||||
self._chip = "gpiochip{}".format(pin.id[0])
|
||||
else:
|
||||
self._pin = str(pin.id)
|
||||
self._chip = "gpiochip0"
|
||||
|
||||
self._maxlen = maxlen
|
||||
self._idle_state = idle_state
|
||||
self._queue_key = random.randint(1, 9999)
|
||||
try:
|
||||
self._mq = sysv_ipc.MessageQueue(None, flags=sysv_ipc.IPC_CREX)
|
||||
if DEBUG:
|
||||
print("Message Queue Key: ", self._mq.key)
|
||||
queues.append(self._mq)
|
||||
except sysv_ipc.ExistentialError:
|
||||
raise RuntimeError(
|
||||
"Message queue creation failed"
|
||||
) from sysv_ipc.ExistentialError
|
||||
|
||||
# Check if OS is 64-bit
|
||||
libgpiod_filename = "libgpiod_pulsein"
|
||||
dir_path = os.path.dirname(os.path.realpath(__file__))
|
||||
cmd = [
|
||||
dir_path + "/" + libgpiod_filename,
|
||||
"--pulses",
|
||||
str(maxlen),
|
||||
"--queue",
|
||||
str(self._mq.key),
|
||||
]
|
||||
if idle_state:
|
||||
cmd.append("-i")
|
||||
cmd.append(self._chip)
|
||||
cmd.append(self._pin)
|
||||
if DEBUG:
|
||||
print(cmd)
|
||||
|
||||
self._process = subprocess.Popen(cmd) # pylint: disable=consider-using-with
|
||||
procs.append(self._process)
|
||||
|
||||
# wait for it to start up
|
||||
if DEBUG:
|
||||
print("Waiting for startup success message from subprocess")
|
||||
message = self._wait_receive_msg(timeout=0.25)
|
||||
if message[0] != b"!":
|
||||
raise RuntimeError("Could not establish message queue with subprocess")
|
||||
self._paused = False
|
||||
|
||||
# pylint: disable=redefined-builtin
|
||||
def _wait_receive_msg(self, timeout=0, type=2):
|
||||
"""Internal helper that will wait for new messages of a given type,
|
||||
and throw an exception on timeout"""
|
||||
if timeout > 0:
|
||||
stamp = time.monotonic()
|
||||
while (time.monotonic() - stamp) < timeout:
|
||||
try:
|
||||
message = self._mq.receive(block=False, type=type)
|
||||
return message
|
||||
except sysv_ipc.BusyError:
|
||||
time.sleep(0.001) # wait a bit then retry!
|
||||
# uh-oh timed out
|
||||
raise RuntimeError(
|
||||
"Timed out waiting for PulseIn message. Make sure libgpiod is installed."
|
||||
)
|
||||
message = self._mq.receive(block=True, type=type)
|
||||
return message
|
||||
|
||||
# pylint: enable=redefined-builtin
|
||||
|
||||
def deinit(self):
|
||||
"""Deinitialises the PulseIn and releases any hardware and software
|
||||
resources for reuse."""
|
||||
# Clean up after ourselves
|
||||
self._process.terminate()
|
||||
procs.remove(self._process)
|
||||
self._mq.remove()
|
||||
queues.remove(self._mq)
|
||||
|
||||
def __enter__(self):
|
||||
"""No-op used by Context Managers."""
|
||||
return self
|
||||
|
||||
def __exit__(self, exc_type, exc_value, tb):
|
||||
"""Automatically deinitializes the hardware when exiting a context."""
|
||||
self.deinit()
|
||||
|
||||
def resume(self, trigger_duration=0):
|
||||
"""Resumes pulse capture after an optional trigger pulse."""
|
||||
if trigger_duration != 0:
|
||||
self._mq.send("t%d" % trigger_duration, True, type=1)
|
||||
else:
|
||||
self._mq.send("r", True, type=1)
|
||||
self._paused = False
|
||||
|
||||
def pause(self):
|
||||
"""Pause pulse capture"""
|
||||
self._mq.send("p", True, type=1)
|
||||
self._paused = True
|
||||
|
||||
@property
|
||||
def paused(self):
|
||||
"""True when pulse capture is paused as a result of pause() or
|
||||
an error during capture such as a signal that is too fast."""
|
||||
return self._paused
|
||||
|
||||
@property
|
||||
def maxlen(self):
|
||||
"""The maximum length of the PulseIn. When len() is equal to maxlen,
|
||||
it is unclear which pulses are active and which are idle."""
|
||||
return self._maxlen
|
||||
|
||||
def clear(self):
|
||||
"""Clears all captured pulses"""
|
||||
self._mq.send("c", True, type=1)
|
||||
|
||||
def popleft(self):
|
||||
"""Removes and returns the oldest read pulse."""
|
||||
self._mq.send("^", True, type=1)
|
||||
message = self._wait_receive_msg()
|
||||
reply = int(message[0].decode("utf-8"))
|
||||
# print(reply)
|
||||
if reply == -1:
|
||||
raise IndexError("pop from empty list")
|
||||
return reply
|
||||
|
||||
def __len__(self):
|
||||
"""Returns the current pulse length"""
|
||||
self._mq.send("l", True, type=1)
|
||||
message = self._wait_receive_msg()
|
||||
return int(message[0].decode("utf-8"))
|
||||
|
||||
# pylint: disable=redefined-builtin
|
||||
def __getitem__(self, index, type=None):
|
||||
"""Returns the value at the given index or values in slice."""
|
||||
self._mq.send("i%d" % index, True, type=1)
|
||||
message = self._wait_receive_msg()
|
||||
ret = int(message[0].decode("utf-8"))
|
||||
if ret == -1:
|
||||
raise IndexError("list index out of range")
|
||||
return ret
|
||||
|
||||
# pylint: enable=redefined-builtin
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,3 @@
|
|||
# SPDX-FileCopyrightText: 2023 Jan Volckaert for Adafruit Industries
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,93 @@
|
|||
# SPDX-FileCopyrightText: 2021 Melissa LeBlanc-Williams for Adafruit Industries
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
"""AmLogic s905 pin names"""
|
||||
from adafruit_blinka.microcontroller.generic_linux.libgpiod_pin import Pin
|
||||
|
||||
GPIO122 = Pin((0, 0))
|
||||
GPIO123 = Pin((0, 1))
|
||||
GPIO124 = Pin((0, 2))
|
||||
GPIO125 = Pin((0, 3))
|
||||
GPIO126 = Pin((0, 4))
|
||||
GPIO127 = Pin((0, 5))
|
||||
GPIO128 = Pin((0, 6))
|
||||
GPIO129 = Pin((0, 7))
|
||||
GPIO130 = Pin((0, 8))
|
||||
GPIO131 = Pin((0, 9))
|
||||
GPIO132 = Pin((0, 10))
|
||||
GPIO133 = Pin((0, 11))
|
||||
GPIO134 = Pin((0, 12))
|
||||
GPIO135 = Pin((0, 13))
|
||||
|
||||
GPIO205 = Pin((1, 69))
|
||||
GPIO206 = Pin((1, 70))
|
||||
GPIO207 = Pin((1, 71))
|
||||
GPIO208 = Pin((1, 72))
|
||||
GPIO209 = Pin((1, 73))
|
||||
GPIO210 = Pin((1, 74))
|
||||
|
||||
GPIO211 = Pin((1, 75))
|
||||
GPIO212 = Pin((1, 76))
|
||||
GPIO213 = Pin((1, 77))
|
||||
GPIO214 = Pin((1, 78))
|
||||
GPIO215 = Pin((1, 79))
|
||||
GPIO216 = Pin((1, 80))
|
||||
GPIO217 = Pin((1, 81))
|
||||
GPIO218 = Pin((1, 82))
|
||||
GPIO219 = Pin((1, 83))
|
||||
GPIO220 = Pin((1, 84))
|
||||
GPIO221 = Pin((1, 85))
|
||||
GPIO222 = Pin((1, 86))
|
||||
GPIO223 = Pin((1, 87))
|
||||
GPIO224 = Pin((1, 88))
|
||||
GPIO225 = Pin((1, 89))
|
||||
GPIO226 = Pin((1, 90))
|
||||
GPIO227 = Pin((1, 91))
|
||||
|
||||
GPIO228 = Pin((1, 92))
|
||||
GPIO229 = Pin((1, 93))
|
||||
GPIO230 = Pin((1, 94))
|
||||
GPIO231 = Pin((1, 95))
|
||||
GPIO232 = Pin((1, 96))
|
||||
GPIO233 = Pin((1, 97))
|
||||
GPIO234 = Pin((1, 98))
|
||||
GPIO235 = Pin((1, 99))
|
||||
GPIO236 = Pin((1, 100))
|
||||
GPIO237 = Pin((1, 101))
|
||||
GPIO238 = Pin((1, 102))
|
||||
GPIO239 = Pin((1, 103))
|
||||
GPIO240 = Pin((1, 104))
|
||||
GPIO241 = Pin((1, 105))
|
||||
GPIO242 = Pin((1, 106))
|
||||
GPIO243 = Pin((1, 107))
|
||||
GPIO247 = Pin((1, 111))
|
||||
GPIO248 = Pin((1, 112))
|
||||
GPIO249 = Pin((1, 113))
|
||||
|
||||
I2C0_SDA = GPIO205
|
||||
I2C0_SCL = GPIO206
|
||||
I2C1_SDA = GPIO207
|
||||
I2C1_SCL = GPIO208
|
||||
I2C2_SDA = GPIO209
|
||||
I2C2_SCL = GPIO210
|
||||
|
||||
UART1_TX = GPIO240
|
||||
UART1_RX = GPIO241
|
||||
UART2_TX = GPIO205
|
||||
UART2_RX = GPIO206
|
||||
|
||||
SPI0_SCLK = GPIO230
|
||||
SPI0_MISO = GPIO232
|
||||
SPI0_MOSI = GPIO235
|
||||
|
||||
i2cPorts = (
|
||||
(0, I2C0_SCL, I2C0_SDA),
|
||||
(1, I2C1_SCL, I2C1_SDA),
|
||||
)
|
||||
# ordered as spiId, sckId, mosiId, misoId
|
||||
spiPorts = ((0, SPI0_SCLK, SPI0_MOSI, SPI0_MISO),)
|
||||
# ordered as uartId, txId, rxId
|
||||
uartPorts = (
|
||||
(1, UART1_TX, UART1_RX),
|
||||
(2, UART2_TX, UART2_RX),
|
||||
)
|
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,75 @@
|
|||
# SPDX-FileCopyrightText: 2021 Melissa LeBlanc-Williams for Adafruit Industries
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
"""AmLogic s905x pin names"""
|
||||
# pylint: disable=wildcard-import,unused-wildcard-import
|
||||
from adafruit_blinka.microcontroller.generic_linux.libgpiod_pin import Pin
|
||||
|
||||
# Chip 0
|
||||
GPIO100 = Pin((0, 0))
|
||||
GPIO101 = Pin((0, 1))
|
||||
GPIO104 = Pin((0, 4))
|
||||
GPIO105 = Pin((0, 5))
|
||||
GPIO106 = Pin((0, 6))
|
||||
GPIO109 = Pin((0, 9))
|
||||
GPIO110 = Pin((0, 10))
|
||||
|
||||
# Chip 1
|
||||
GPIO220 = Pin((1, 20))
|
||||
GPIO222 = Pin((1, 22))
|
||||
GPIO223 = Pin((1, 23))
|
||||
GPIO224 = Pin((1, 24))
|
||||
GPIO225 = Pin((1, 25))
|
||||
GPIO275 = Pin((1, 75))
|
||||
GPIO276 = Pin((1, 76))
|
||||
GPIO279 = Pin((1, 79))
|
||||
GPIO280 = Pin((1, 80))
|
||||
GPIO281 = Pin((1, 81))
|
||||
GPIO282 = Pin((1, 82))
|
||||
GPIO283 = Pin((1, 83))
|
||||
GPIO284 = Pin((1, 84))
|
||||
GPIO285 = Pin((1, 85))
|
||||
GPIO286 = Pin((1, 86))
|
||||
GPIO287 = Pin((1, 87))
|
||||
GPIO288 = Pin((1, 88))
|
||||
GPIO289 = Pin((1, 89))
|
||||
GPIO290 = Pin((1, 90))
|
||||
GPIO291 = Pin((1, 91))
|
||||
GPIO292 = Pin((1, 92))
|
||||
GPIO293 = Pin((1, 93))
|
||||
GPIO294 = Pin((1, 94))
|
||||
GPIO295 = Pin((1, 95))
|
||||
GPIO296 = Pin((1, 96))
|
||||
GPIO297 = Pin((1, 97))
|
||||
GPIO298 = Pin((1, 98))
|
||||
|
||||
I2C0_SDA = GPIO105
|
||||
I2C0_SCK = GPIO104
|
||||
I2C1_SDA = GPIO275
|
||||
I2C1_SCK = GPIO276
|
||||
|
||||
UART1_RX = GPIO288
|
||||
UART1_TX = GPIO287
|
||||
UART2_RX = GPIO292
|
||||
UART2_TX = GPIO291
|
||||
|
||||
SPI0_SCLK = GPIO290
|
||||
SPI0_MISO = GPIO288
|
||||
SPI0_MOSI = GPIO287
|
||||
SPI0_CS = GPIO289
|
||||
SPI1_SCLK = GPIO223
|
||||
SPI1_MISO = GPIO288
|
||||
SPI1_MOSI = GPIO287
|
||||
SPI1_CS = GPIO289
|
||||
|
||||
i2cPorts = (
|
||||
(0, I2C0_SCK, I2C0_SDA),
|
||||
(1, I2C1_SCK, I2C1_SDA),
|
||||
)
|
||||
|
||||
spiPorts = ((0, SPI0_SCLK, SPI0_MOSI, SPI0_MISO), (1, SPI1_SCLK, SPI1_MOSI, SPI1_MISO))
|
||||
|
||||
uartPorts = (
|
||||
(1, UART1_TX, UART1_RX),
|
||||
(2, UART2_TX, UART2_RX),
|
||||
)
|
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,6 @@
|
|||
# SPDX-FileCopyrightText: 2021 Melissa LeBlanc-Williams for Adafruit Industries
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
"""AmLogic s905x3 pin names"""
|
||||
# pylint: disable=wildcard-import,unused-wildcard-import
|
||||
from adafruit_blinka.microcontroller.amlogic.meson_g12_common.pin import *
|
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,77 @@
|
|||
# SPDX-FileCopyrightText: 2021 Melissa LeBlanc-Williams for Adafruit Industries
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
"""AmLogic s905y2 pin names"""
|
||||
# pylint: disable=wildcard-import,unused-wildcard-import
|
||||
from adafruit_blinka.microcontroller.generic_linux.libgpiod_pin import Pin
|
||||
|
||||
periphs = 0
|
||||
aobus = 1
|
||||
|
||||
GPIO412 = GPIOAO_0 = Pin((aobus, 0))
|
||||
GPIO413 = GPIOAO_1 = Pin((aobus, 1))
|
||||
GPIO414 = GPIOAO_2 = Pin((aobus, 2))
|
||||
GPIO415 = GPIOAO_3 = Pin((aobus, 3))
|
||||
GPIO416 = GPIOAO_4 = Pin((aobus, 4))
|
||||
|
||||
GPIO420 = GPIOAO_8 = Pin((aobus, 8))
|
||||
GPIO421 = GPIOAO_9 = Pin((aobus, 9))
|
||||
GPIO422 = GPIOAO_10 = Pin((aobus, 10))
|
||||
GPIO423 = GPIOAO_11 = Pin((aobus, 11))
|
||||
|
||||
GPIO447 = GPIOH_4 = Pin((periphs, 20))
|
||||
GPIO448 = GPIOH_5 = Pin((periphs, 21))
|
||||
GPIO449 = GPIOH_6 = Pin((periphs, 22))
|
||||
GPIO450 = GPIOH_7 = Pin((periphs, 23))
|
||||
GPIO451 = GPIOH_8 = Pin((periphs, 24))
|
||||
|
||||
GPIO490 = GPIOA_14 = Pin((periphs, 63))
|
||||
GPIO491 = GPIOA_15 = Pin((periphs, 64))
|
||||
|
||||
|
||||
GPIO500 = GPIOX_8 = Pin((periphs, 73))
|
||||
GPIO501 = GPIOX_9 = Pin((periphs, 74))
|
||||
GPIO502 = GPIOX_10 = Pin((periphs, 75))
|
||||
GPIO503 = GPIOX_11 = Pin((periphs, 76))
|
||||
|
||||
|
||||
I2C1_SDA = GPIOH_6
|
||||
I2C1_SCL = GPIOH_7
|
||||
I2C3_SDA = GPIOA_14
|
||||
I2C3_SCL = GPIOA_15
|
||||
I2C4_SDA = GPIOAO_3
|
||||
I2C4_SCL = GPIOAO_2
|
||||
|
||||
SPIA_SCLK = GPIOX_11
|
||||
SPIA_MISO = GPIOX_9
|
||||
SPIA_MOSI = GPIOX_8
|
||||
|
||||
SPIB_SCLK = GPIOH_7
|
||||
SPIB_MISO = GPIOH_5
|
||||
SPIB_MOSI = GPIOH_4
|
||||
|
||||
UARTA_TX = GPIOAO_2
|
||||
UARTA_RX = GPIOAO_3
|
||||
UARTB_TX = GPIOAO_8
|
||||
UARTB_RX = GPIOAO_9
|
||||
UARTC_TX = GPIOH_7
|
||||
UARTC_RX = GPIOH_6
|
||||
|
||||
i2cPorts = (
|
||||
(1, I2C1_SCL, I2C1_SDA),
|
||||
(3, I2C3_SCL, I2C3_SDA),
|
||||
(4, I2C4_SCL, I2C4_SDA),
|
||||
)
|
||||
|
||||
spiPorts = (
|
||||
(0, SPIA_SCLK, SPIA_MOSI, SPIA_MISO),
|
||||
(1, SPIB_SCLK, SPIB_MOSI, SPIB_MISO),
|
||||
)
|
||||
|
||||
uartPorts = (
|
||||
(0, UARTA_TX, UARTA_RX),
|
||||
(1, UARTB_TX, UARTB_RX),
|
||||
(4, UARTC_TX, UARTC_RX),
|
||||
)
|
||||
|
||||
pwmOuts = (((2, 0), GPIOAO_11),)
|
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,6 @@
|
|||
# SPDX-FileCopyrightText: 2021 Melissa LeBlanc-Williams for Adafruit Industries
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
"""AmLogic s922x pin names"""
|
||||
# pylint: disable=wildcard-import,unused-wildcard-import
|
||||
from adafruit_blinka.microcontroller.amlogic.meson_g12_common.pin import *
|
Loading…
Add table
Add a link
Reference in a new issue