]> Repositories - Adafruit_Blinka-hackapet.git/commitdiff
Merge pull request #322 from dmanla/master
authorMelissa LeBlanc-Williams <melissa@adafruit.com>
Sun, 1 Nov 2020 17:49:03 +0000 (10:49 -0700)
committerGitHub <noreply@github.com>
Sun, 1 Nov 2020 17:49:03 +0000 (10:49 -0700)
Adding PineH64 SBC support

41 files changed:
.github/workflows/build.yml
examples/mcps_busio_i2c.py [new file with mode: 0755]
requirements.txt
setup.py
src/adafruit_blinka/__init__.py
src/adafruit_blinka/board/bananapi/bpim2zero.py [new file with mode: 0644]
src/adafruit_blinka/board/nvidia/clara_agx_xavier.py [new file with mode: 0644]
src/adafruit_blinka/board/pyboard.py
src/adafruit_blinka/board/stm32/__init__.py [new file with mode: 0644]
src/adafruit_blinka/board/stm32/stm32mp157c_dk2.py [new file with mode: 0644]
src/adafruit_blinka/board/udoo_x86ultra.py [new file with mode: 0644]
src/adafruit_blinka/microcontroller/am335x/sysfs_pwmout.py
src/adafruit_blinka/microcontroller/amlogic/meson_g12_common/pin.py
src/adafruit_blinka/microcontroller/bcm283x/pulseio/PulseIn.py
src/adafruit_blinka/microcontroller/ft232h/spi.py
src/adafruit_blinka/microcontroller/generic_linux/i2c.py
src/adafruit_blinka/microcontroller/generic_linux/libgpiod_pin.py
src/adafruit_blinka/microcontroller/generic_linux/periphery_pin.py
src/adafruit_blinka/microcontroller/generic_linux/sysfs_analogin.py
src/adafruit_blinka/microcontroller/generic_linux/sysfs_analogout.py
src/adafruit_blinka/microcontroller/generic_linux/sysfs_pin.py
src/adafruit_blinka/microcontroller/generic_linux/sysfs_pwmout.py
src/adafruit_blinka/microcontroller/mcp2221/mcp2221.py
src/adafruit_blinka/microcontroller/nova/pwmout.py
src/adafruit_blinka/microcontroller/nxp_lpc4330/pin.py
src/adafruit_blinka/microcontroller/nxp_lpc4330/pwmout.py
src/adafruit_blinka/microcontroller/pentium/__init__.py [new file with mode: 0644]
src/adafruit_blinka/microcontroller/pentium/n3710/.gitignore [new file with mode: 0644]
src/adafruit_blinka/microcontroller/pentium/n3710/__init__.py [new file with mode: 0644]
src/adafruit_blinka/microcontroller/pentium/n3710/pin.py [new file with mode: 0644]
src/adafruit_blinka/microcontroller/stm32/stm32f405/__init__.py [new file with mode: 0644]
src/adafruit_blinka/microcontroller/stm32/stm32f405/pin.py [moved from src/adafruit_blinka/microcontroller/stm32/pin.py with 98% similarity]
src/adafruit_blinka/microcontroller/stm32/stm32mp157/__init__.py [new file with mode: 0644]
src/adafruit_blinka/microcontroller/stm32/stm32mp157/pin.py [new file with mode: 0755]
src/adafruit_blinka/microcontroller/tegra/t194/pin.py
src/board.py
src/busio.py
src/digitalio.py
src/microcontroller/__init__.py
src/microcontroller/pin.py
test/src/testing/adafruit_blinka.py

index b0f79c273442b0faf46272c006a7839c073a3e79..f00cbfe4231e70a782eb36d472f4c7ac4d38e9b4 100644 (file)
@@ -35,7 +35,7 @@ jobs:
         source actions-ci/install.sh
     - name: Pip install pylint, black, & Sphinx
       run: |
-        pip install --force-reinstall pylint black==19.10b0 Sphinx sphinx-rtd-theme
+        pip install --force-reinstall pylint black Sphinx sphinx-rtd-theme
     - name: Library version
       run: git describe --dirty --always --tags
     - name: Check formatting
diff --git a/examples/mcps_busio_i2c.py b/examples/mcps_busio_i2c.py
new file mode 100755 (executable)
index 0000000..4729e3e
--- /dev/null
@@ -0,0 +1,57 @@
+import time
+import hid
+import busio
+
+from adafruit_blinka.microcontroller.mcp2221.mcp2221 import mcp2221 as _mcp2221
+from adafruit_blinka.microcontroller.mcp2221.mcp2221 import MCP2221 as _MCP2221
+from adafruit_blinka.microcontroller.mcp2221.i2c import I2C as _MCP2221I2C
+
+MLXADDR = 0x33
+ADDRID1 = 0x2407
+
+
+class MCP2221(_MCP2221):  # pylint: disable=too-few-public-methods
+    def __init__(self, address):
+        self._hid = hid.device()
+        self._hid.open_path(address)
+        print("Connected to " + str(address))
+        self._gp_config = [0x07] * 4  # "don't care" initial value
+        for pin in range(4):
+            self.gp_set_mode(pin, self.GP_GPIO)  # set to GPIO mode
+            self.gpio_set_direction(pin, 1)  # set to INPUT
+
+
+class MCP2221I2C(_MCP2221I2C):  # pylint: disable=too-few-public-methods
+    def __init__(self, mcp2221, *, frequency=100000):
+        self._mcp2221 = mcp2221
+        self._mcp2221.i2c_configure(frequency)
+
+
+class I2C(busio.I2C):  # pylint: disable=too-few-public-methods
+    def __init__(self, mcp2221_i2c):
+        self._i2c = mcp2221_i2c
+
+
+addresses = [mcp["path"] for mcp in hid.enumerate(0x04D8, 0x00DD)]
+
+i2c_devices = []
+i2c_devices.append(I2C(MCP2221I2C(_mcp2221)))
+
+for addr in addresses:
+    try:
+        i2c_device = I2C(MCP2221I2C(MCP2221(addr)))
+        i2c_devices.append(i2c_device)
+    except OSError:
+        print("Device path: " + str(addr) + " is used")
+
+
+while True:
+    for i2c in i2c_devices:
+        addrbuf = bytearray(2)
+        addrbuf[0] = ADDRID1 >> 8
+        addrbuf[1] = ADDRID1 & 0xFF
+        inbuf = bytearray(6)
+        i2c.writeto_then_readfrom(MLXADDR, addrbuf, inbuf)
+        print("Device " + str(i2c_devices.index(i2c)) + ": ")
+        print(inbuf)
+        time.sleep(0.5)
index 67765e51dd640b6352b764f3933e288ad8180ef7..4eaf385e8b12c988284ee346a31182b7afa7d4a9 100755 (executable)
@@ -1,5 +1,5 @@
-Adafruit-PlatformDetect>=2.11.1
-Adafruit-PureIO>=1.1.5
+Adafruit-PlatformDetect>=2.18.1
+Adafruit-PureIO>=1.1.7
 Jetson.GPIO; platform_machine=='aarch64'
 RPi.GPIO; platform_machine=='armv7l' or platform_machine=='armv6l'
 rpi_ws281x>=4.0.0; platform_machine=='armv7l' or platform_machine=='armv6l'
index c0c845026b498a949db45e5bd7a3bb04fa58c8ce..2465ba800addf9bec33f10d479baaa55bc9b7ade 100755 (executable)
--- a/setup.py
+++ b/setup.py
@@ -29,7 +29,7 @@ if os.path.exists("/proc/device-tree/compatible"):
         or b"brcm,bcm2837" in compat
         or b"brcm,bcm2838" in compat
     ):
-        board_reqs = ["RPi.GPIO", "rpi_ws281x>=4.0.0"]
+        board_reqs = ["RPi.GPIO", "rpi_ws281x>=4.0.0", "sysv_ipc"]
 
 setup(
     name="Adafruit-Blinka",
@@ -60,9 +60,8 @@ setup(
         "adafruit_blinka.microcontroller.bcm283x.pulseio": ["libgpiod_pulsein"]
     },
     install_requires=[
-        "Adafruit-PlatformDetect>=2.11.1",
-        "Adafruit-PureIO>=1.1.5",
-        "sysv_ipc; platform_system != 'Windows' and platform_machine != 'mips'",
+        "Adafruit-PlatformDetect>=2.18.1",
+        "Adafruit-PureIO>=1.1.7",
         "pyftdi>=0.40.0",
     ]
     + board_reqs,
index 2df8a2d702228cd493a493da985788753c47081c..69e917851be562cef45acbaa934d58b1518be6b5 100755 (executable)
@@ -8,8 +8,8 @@
 
 class Enum:
     """
-        Object supporting CircuitPython-style of static symbols
-        as seen with Direction.OUTPUT, Pull.UP
+    Object supporting CircuitPython-style of static symbols
+    as seen with Direction.OUTPUT, Pull.UP
     """
 
     def __repr__(self):
@@ -27,8 +27,8 @@ class Enum:
     @classmethod
     def iteritems(cls):
         """
-            Inspects attributes of the class for instances of the class
-            and returns as key,value pairs mirroring dict#iteritems
+        Inspects attributes of the class for instances of the class
+        and returns as key,value pairs mirroring dict#iteritems
         """
         for key in dir(cls):
             val = getattr(cls, key)
diff --git a/src/adafruit_blinka/board/bananapi/bpim2zero.py b/src/adafruit_blinka/board/bananapi/bpim2zero.py
new file mode 100644 (file)
index 0000000..9b68f1b
--- /dev/null
@@ -0,0 +1,36 @@
+"""Pin definitions for the Banana Pi M2 Zero."""
+
+# The Banana Pi M2 Zero uses the AllWinner H2 SoC, but pins
+# are the same as the AllWinner H3 SoC, so we import those
+from adafruit_blinka.microcontroller.allwinner.h3 import pin
+
+PA12 = pin.PA12
+SDA = pin.PA12
+PA11 = pin.PA11
+SCL = pin.PA11
+PA6 = pin.PA6
+PWM1 = pin.PA6
+PA1 = pin.PA1
+UART2_RX = pin.PA1
+PA0 = pin.PA0
+UART2_TX = pin.PA0
+PA3 = pin.PA3
+UART2_CTS = pin.PA3
+PA10 = pin.PA10
+
+PA13 = pin.PA13
+SPI1_CS = pin.PA13
+PA14 = pin.PA14
+SPI1_CLK = pin.PA14
+PA2 = pin.PA2
+UART2_RTS = pin.PA2
+PA18 = pin.PA18
+TWI1_SCK = pin.PA18
+PG6 = pin.PG6
+UART1_TX = pin.PG6
+PG7 = pin.PG7
+UART1_RX = pin.PG7
+
+SCLK = pin.PA14
+MOSI = pin.PA15
+MISO = pin.PA16
diff --git a/src/adafruit_blinka/board/nvidia/clara_agx_xavier.py b/src/adafruit_blinka/board/nvidia/clara_agx_xavier.py
new file mode 100644 (file)
index 0000000..d65e95a
--- /dev/null
@@ -0,0 +1,38 @@
+"""Pin definitions for Clara AGX Xavier."""
+
+from adafruit_blinka.microcontroller.tegra.t194 import pin
+
+SDA = pin.SDA
+SCL = pin.SCL
+SDA_1 = pin.SDA_1
+SCL_1 = pin.SCL_1
+
+D4 = pin.Q06
+D5 = pin.AA03
+D6 = pin.AA02
+D7 = pin.Z07
+D8 = pin.Z06
+D9 = pin.Z04
+D10 = pin.Z05
+D11 = pin.Z03
+D12 = pin.BB01
+D13 = pin.AA00
+D16 = pin.R05
+D17 = pin.R04
+D18 = pin.H07
+D19 = pin.I02
+D20 = pin.I01
+D21 = pin.I00
+D22 = pin.N01
+D23 = pin.BB00
+D24 = pin.H00
+D25 = pin.Q01
+D26 = pin.AA01
+D27 = pin.P04
+
+CE1 = D7
+CE0 = D8
+MISO = D9
+MOSI = D10
+SCLK = D11
+SCK = D11
index 4c5eb10cb775aac5f39c9f5cd1b2f71a24054cb0..14ed95758a781156d041fb1bd06751384f04f84c 100755 (executable)
@@ -1,6 +1,6 @@
 """PyBoard pin names"""
 
-from adafruit_blinka.microcontroller.stm32 import pin
+from adafruit_blinka.microcontroller.stm32.stm32f405 import pin
 
 X1 = pin.A0
 X2 = pin.A1
diff --git a/src/adafruit_blinka/board/stm32/__init__.py b/src/adafruit_blinka/board/stm32/__init__.py
new file mode 100644 (file)
index 0000000..d0e9d45
--- /dev/null
@@ -0,0 +1 @@
+"""Boards definition from STM32"""
diff --git a/src/adafruit_blinka/board/stm32/stm32mp157c_dk2.py b/src/adafruit_blinka/board/stm32/stm32mp157c_dk2.py
new file mode 100644 (file)
index 0000000..2f8cde1
--- /dev/null
@@ -0,0 +1,49 @@
+"""Pin definitions for the STM32MP157C Development Kit 2."""
+
+from adafruit_blinka.microcontroller.stm32.stm32mp157 import pin
+
+D2 = pin.PA12
+D3 = pin.PA11
+D4 = pin.PA8
+D5 = pin.PG2
+D6 = pin.PH11
+D7 = pin.PF3
+D8 = pin.PF6
+D9 = pin.PF8
+D10 = pin.PF9
+D11 = pin.PF7
+D12 = pin.PD13
+D13 = pin.PC7
+D14 = pin.PB10
+D15 = pin.PB12
+D16 = pin.PB13
+D17 = pin.PG8
+D18 = pin.PI5
+D19 = pin.PI7
+D20 = pin.PI6
+D21 = pin.PF11
+D22 = pin.PG15
+D23 = pin.PF1
+D24 = pin.PF0
+D25 = pin.PF4
+D26 = pin.PF5
+D27 = pin.PD7
+
+SDA = D2
+SCL = D3
+
+SDA1 = pin.PF15
+SCL1 = pin.PD12
+
+SCLK = D11
+MOSI = D10
+MISO = D9
+
+CE0 = D8
+CE1 = D7
+
+CS = CE0
+SCK = SCLK
+
+UART_TX = D14
+UART_RX = D15
diff --git a/src/adafruit_blinka/board/udoo_x86ultra.py b/src/adafruit_blinka/board/udoo_x86ultra.py
new file mode 100644 (file)
index 0000000..744d774
--- /dev/null
@@ -0,0 +1,70 @@
+"""Pin definitions for Udoo x86 Ultra
+(should work for Ultra and Ultra II)
+
+There are 2 naming systems.  A Digital Pin system which includes
+the arduino chip (Leonardo or 101).  The Braswell #s start at 16 and
+is documented in the diagram and text for linux version later than 4.15 in:
+https://www.udoo.org/docs-x86II/Introduction/Introduction.html
+The other is based on the hardware manual:
+https://udoo.org/download/files/UDOO_X86/Doc/UDOO_X86II_MANUAL.pdf
+
+This will use the D system based on the diagram in the user guide
+
+i2c use i2c(board.I2C0_SCL, board_I2C0_SDA) or i2c(board.I2C1_SCL, board_I2C1_SDA)
+for the i2c(board.SCL, board.SCL) in the examples
+
+UART use pyserial not busio
+"""
+
+from adafruit_blinka.microcontroller.pentium.n3710 import pin
+
+# Connector CN15
+D16 = pin.UART1_RTS
+D17 = pin.UART1_CTS
+D18 = pin.UART1_TXD
+D19 = pin.UART1_RXD
+D20 = pin.UART2_RTS
+D21 = pin.UART2_CTS
+D22 = pin.UART2_TXD
+D23 = pin.UART2_RXD
+
+# Connector CN13 LPC interface
+D24 = pin.GPIO_275
+D25 = pin.GPIO_280
+D26 = pin.GPIO_273
+D27 = pin.GPIO_278
+D28 = pin.GPIO_276
+D29 = pin.GPIO_279
+D30 = pin.GPIO_307
+
+# Connector CN14
+D34 = pin.I2C0_SCL
+D35 = pin.I2C0_SDA
+
+D36 = pin.GPIO_492
+D37 = pin.GPIO_490
+
+D38 = pin.I2C1_SCL
+D39 = pin.I2C1_SDA
+
+# Connector CN12 SDIO SD/MMC interfaces
+D40 = pin.GPIO_358
+D41 = pin.GPIO_243
+D42 = pin.GPIO_249
+D43 = pin.GPIO_246
+D44 = pin.GPIO_253
+D45 = pin.GPIO_250
+D46 = pin.GPIO_247
+
+# aliases
+UART1_RX = D19
+UART1_TX = D18
+
+UART2_RX = D23
+UART2_TX = D22
+
+I2C0_SCL = D34  # labeled on diagram as I2C1, hardware manual port 0
+I2C0_SDA = D35  # i2cdetect-l lists it as i2c-0
+
+I2C1_SCL = D38  # Labeled on diagram as I2C2, hardware manual port 5
+I2C1_SCL = D39  # i2cdetect lists it as i2c-1
index 2ba135927da79d86e24ae76fd758e9fed9383c63..b99e1cc8000ef88293ecb81146fd8e3b49bc6bbf 100644 (file)
@@ -9,7 +9,7 @@ import os
 try:
     from microcontroller.pin import pwmOuts
 except ImportError:
-    raise RuntimeError("No PWM outputs defined for this board")
+    raise RuntimeError("No PWM outputs defined for this board") from ImportError
 
 # pylint: disable=unnecessary-pass
 class PWMError(IOError):
@@ -105,7 +105,7 @@ class PWMOut:
                 ) as f_export:
                     f_export.write("%d\n" % self._pwmpin)
             except IOError as e:
-                raise PWMError(e.errno, "Exporting PWM pin: " + e.strerror)
+                raise PWMError(e.errno, "Exporting PWM pin: " + e.strerror) from IOError
 
         # Look up the period, for fast duty cycle updates
         self._period = self._get_period()
@@ -135,7 +135,9 @@ class PWMOut:
                     ) as f_unexport:
                         f_unexport.write("%d\n" % self._pwmpin)
                 except IOError as e:
-                    raise PWMError(e.errno, "Unexporting PWM pin: " + e.strerror)
+                    raise PWMError(
+                        e.errno, "Unexporting PWM pin: " + e.strerror
+                    ) from IOError
         except Exception as e:
             # due to a race condition for which I have not yet been
             # able to find the root cause, deinit() often fails
@@ -192,7 +194,9 @@ class PWMOut:
         try:
             period_ns = int(period_ns)
         except ValueError:
-            raise PWMError(None, 'Unknown period value: "%s"' % period_ns)
+            raise PWMError(
+                None, 'Unknown period value: "%s"' % period_ns
+            ) from ValueError
 
         # Convert period from nanoseconds to seconds
         period = period_ns / 1e9
@@ -230,7 +234,9 @@ class PWMOut:
         try:
             duty_cycle_ns = int(duty_cycle_ns)
         except ValueError:
-            raise PWMError(None, 'Unknown duty cycle value: "%s"' % duty_cycle_ns)
+            raise PWMError(
+                None, 'Unknown duty cycle value: "%s"' % duty_cycle_ns
+            ) from ValueError
 
         # Convert duty cycle from nanoseconds to seconds
         duty_cycle = duty_cycle_ns / 1e9
index 165bca71db19a9a3b4c7340212f4aaf5f7ca5b9d..82fa6ea267b07072b1c629589cdea8b71c8a8ed0 100644 (file)
@@ -9,8 +9,8 @@ Linux kernel 5.4.y (mainline)
 """
 
 import re
-from adafruit_blinka.microcontroller.generic_linux.libgpiod_pin import Pin
 import gpiod
+from adafruit_blinka.microcontroller.generic_linux.libgpiod_pin import Pin
 
 chip0 = gpiod.Chip("0")
 chip1 = gpiod.Chip("1")
index d2390f6fed489d77f040b9735408ef42981d9084..19dc98f32089364b6e266712f07ce39038dda5e1 100644 (file)
@@ -45,7 +45,9 @@ class PulseIn:
                 print("Message Queue Key: ", self._mq.key)
             queues.append(self._mq)
         except sysv_ipc.ExistentialError:
-            raise RuntimeError("Message queue creation failed")
+            raise RuntimeError(
+                "Message queue creation failed"
+            ) from sysv_ipc.ExistentialError
 
         dir_path = os.path.dirname(os.path.realpath(__file__))
         cmd = [
@@ -68,26 +70,29 @@ class PulseIn:
         # wait for it to start up
         if DEBUG:
             print("Waiting for startup success message from subprocess")
-        message = self._wait_receive_msg()
+        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.25, type=2):
+    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"""
-        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."
-        )
+        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
 
index afdf3140c5374933f2d9ab6328228f3e385615e4..81797b3557397d85ab7ccef30b2a576cc3c42f01 100644 (file)
@@ -60,7 +60,8 @@ class SPI:
             chunk_end = chunk_start + self._spi.PAYLOAD_MAX_LENGTH
             self._port.write(buf[chunk_start:chunk_end])
         if rest:
-            self._port.write(buf[-1 * rest :])
+            rest_start = start + chunks * self._spi.PAYLOAD_MAX_LENGTH
+            self._port.write(buf[rest_start:end])
 
     # pylint: disable=unused-argument
     def readinto(self, buf, start=0, end=None, write_value=0):
index 1870dfc802eb28206a1bca6c8f3ddbd0fa10d124..7be7514a9426af43188158b0da31bfa423501405 100644 (file)
@@ -25,7 +25,7 @@ class I2C:
         except FileNotFoundError:
             raise RuntimeError(
                 "I2C Bus #%d not found, check if enabled in config!" % bus_num
-            )
+            ) from RuntimeError
 
     # pylint: enable=unused-argument
 
index 4ffa5c1725da19bf4e2d049e02940f7da1e527fd..db9007a6d55d479b4322ed2a67ba2b10804f43a7 100644 (file)
@@ -5,7 +5,7 @@ except ImportError:
     raise ImportError(
         "libgpiod Python bindings not found, please install and try again! See "
         "https://github.com/adafruit/Raspberry-Pi-Installer-Scripts/blob/master/libgpiod.sh"
-    )
+    ) from ImportError
 
 
 class Pin:
index 69044f84757a26994a360eb45fca1c91c50335a0..0986d0135b11d3407321e24e539df89d44ae5644 100644 (file)
@@ -5,7 +5,7 @@ except ImportError:
     raise ImportError(
         "Periphery Python bindings not found, please install and try again! "
         "Try running 'pip3 install python-periphery'"
-    )
+    ) from ImportError
 
 
 class Pin:
index bf6988be1033b4b7192132722ed22a195f78f0ef..e8a7376c615786a0ea759229a7886d01e947ec45 100644 (file)
@@ -13,7 +13,7 @@ from adafruit_blinka import ContextManaged
 try:
     from microcontroller.pin import analogIns
 except ImportError:
-    raise RuntimeError("No Analog Inputs defined for this board")
+    raise RuntimeError("No Analog Inputs defined for this board") from ImportError
 
 
 class AnalogIn(ContextManaged):
index ec8b6c6ab58ffd7959625cf7f25e04fdd1d31d7f..56263d39555a384178cef873328139438747af36 100644 (file)
@@ -13,7 +13,7 @@ from adafruit_blinka import ContextManaged
 try:
     from microcontroller.pin import analogOuts
 except ImportError:
-    raise RuntimeError("No Analog Outputs defined for this board")
+    raise RuntimeError("No Analog Outputs defined for this board") from ImportError
 
 
 class AnalogOut(ContextManaged):
index c5b56e69869603a83308da2255d113646688d674..50c27a7b6ca0a3d13bad10b0c413c89cbbc54ba1 100644 (file)
@@ -135,7 +135,7 @@ class Pin:
                 with open("/sys/class/gpio/export", "w") as f_export:
                     f_export.write("{:d}\n".format(self.id))
             except IOError as e:
-                raise GPIOError(e.errno, "Exporting GPIO: " + e.strerror)
+                raise GPIOError(e.errno, "Exporting GPIO: " + e.strerror) from IOError
 
             # Loop until GPIO is exported
             exported = False
@@ -164,7 +164,7 @@ class Pin:
                     ):
                         raise GPIOError(
                             e.errno, "Setting GPIO direction: " + e.strerror
-                        )
+                        ) from IOError
 
                 time.sleep(self.GPIO_OPEN_DELAY)
         else:
@@ -173,13 +173,15 @@ class Pin:
                 with open(os.path.join(gpio_path, "direction"), "w") as f_direction:
                     f_direction.write(direction.lower() + "\n")
             except IOError as e:
-                raise GPIOError(e.errno, "Setting GPIO direction: " + e.strerror)
+                raise GPIOError(
+                    e.errno, "Setting GPIO direction: " + e.strerror
+                ) from IOError
 
         # Open value
         try:
             self._fd = os.open(os.path.join(gpio_path, "value"), os.O_RDWR)
         except OSError as e:
-            raise GPIOError(e.errno, "Opening GPIO: " + e.strerror)
+            raise GPIOError(e.errno, "Opening GPIO: " + e.strerror) from OSError
 
         self._path = gpio_path
 
@@ -192,7 +194,7 @@ class Pin:
         try:
             os.close(self._fd)
         except OSError as e:
-            raise GPIOError(e.errno, "Closing GPIO: " + e.strerror)
+            raise GPIOError(e.errno, "Closing GPIO: " + e.strerror) from OSError
 
         self._fd = None
 
@@ -202,20 +204,20 @@ class Pin:
             os.write(unexport_fd, "{:d}\n".format(self.id).encode())
             os.close(unexport_fd)
         except OSError as e:
-            raise GPIOError(e.errno, "Unexporting GPIO: " + e.strerror)
+            raise GPIOError(e.errno, "Unexporting GPIO: " + e.strerror) from OSError
 
     def _read(self):
         # Read value
         try:
             buf = os.read(self._fd, 2)
         except OSError as e:
-            raise GPIOError(e.errno, "Reading GPIO: " + e.strerror)
+            raise GPIOError(e.errno, "Reading GPIO: " + e.strerror) from OSError
 
         # Rewind
         try:
             os.lseek(self._fd, 0, os.SEEK_SET)
         except OSError as e:
-            raise GPIOError(e.errno, "Rewinding GPIO: " + e.strerror)
+            raise GPIOError(e.errno, "Rewinding GPIO: " + e.strerror) from OSError
 
         if buf[0] == b"0"[0]:
             return False
@@ -235,13 +237,13 @@ class Pin:
             else:
                 os.write(self._fd, b"0\n")
         except OSError as e:
-            raise GPIOError(e.errno, "Writing GPIO: " + e.strerror)
+            raise GPIOError(e.errno, "Writing GPIO: " + e.strerror) from OSError
 
         # Rewind
         try:
             os.lseek(self._fd, 0, os.SEEK_SET)
         except OSError as e:
-            raise GPIOError(e.errno, "Rewinding GPIO: " + e.strerror)
+            raise GPIOError(e.errno, "Rewinding GPIO: " + e.strerror) from OSError
 
     @property
     def chip_name(self):
@@ -270,9 +272,13 @@ class Pin:
                 label = f_label.read()
         except (GPIOError, IOError) as e:
             if isinstance(e, IOError):
-                raise GPIOError(e.errno, "Reading gpiochip label: " + e.strerror)
+                raise GPIOError(
+                    e.errno, "Reading gpiochip label: " + e.strerror
+                ) from IOError
 
-            raise GPIOError(None, "Reading gpiochip label: " + e.strerror)
+            raise GPIOError(
+                None, "Reading gpiochip label: " + e.strerror
+            ) from GPIOError
 
         return label.strip()
 
@@ -284,7 +290,9 @@ class Pin:
             with open(os.path.join(self._path, "direction"), "r") as f_direction:
                 direction = f_direction.read()
         except IOError as e:
-            raise GPIOError(e.errno, "Getting GPIO direction: " + e.strerror)
+            raise GPIOError(
+                e.errno, "Getting GPIO direction: " + e.strerror
+            ) from IOError
 
         return direction.strip()
 
@@ -299,7 +307,9 @@ class Pin:
             with open(os.path.join(self._path, "direction"), "w") as f_direction:
                 f_direction.write(direction.lower() + "\n")
         except IOError as e:
-            raise GPIOError(e.errno, "Setting GPIO direction: " + e.strerror)
+            raise GPIOError(
+                e.errno, "Setting GPIO direction: " + e.strerror
+            ) from IOError
 
     direction = property(_get_direction, _set_direction)
 
index 6cf477c15dd63aa1e8422890504d92920d847b6d..4fc8e23b0fab29bdafb563476b3c9bb58e2b7a28 100644 (file)
@@ -9,7 +9,7 @@ import os
 try:
     from microcontroller.pin import pwmOuts
 except ImportError:
-    raise RuntimeError("No PWM outputs defined for this board")
+    raise RuntimeError("No PWM outputs defined for this board") from ImportError
 
 
 # pylint: disable=unnecessary-pass
@@ -107,7 +107,7 @@ class PWMOut:
             with open(os.path.join(channel_path, self._export_path), "w") as f_export:
                 f_export.write("%d\n" % self._pwmpin)
         except IOError as e:
-            raise PWMError(e.errno, "Exporting PWM pin: " + e.strerror)
+            raise PWMError(e.errno, "Exporting PWM pin: " + e.strerror) from IOError
 
         # self._set_enabled(False) # This line causes a write error when trying to enable
 
@@ -136,7 +136,9 @@ class PWMOut:
                 ) as f_unexport:
                     f_unexport.write("%d\n" % self._pwmpin)
             except IOError as e:
-                raise PWMError(e.errno, "Unexporting PWM pin: " + e.strerror)
+                raise PWMError(
+                    e.errno, "Unexporting PWM pin: " + e.strerror
+                ) from IOError
 
         self._channel = None
         self._pwmpin = None
@@ -184,7 +186,9 @@ class PWMOut:
         try:
             period_ns = int(period_ns)
         except ValueError:
-            raise PWMError(None, 'Unknown period value: "%s"' % period_ns)
+            raise PWMError(
+                None, 'Unknown period value: "%s"' % period_ns
+            ) from ValueError
 
         # Convert period from nanoseconds to seconds
         period = period_ns / 1e9
@@ -222,7 +226,9 @@ class PWMOut:
         try:
             duty_cycle_ns = int(duty_cycle_ns)
         except ValueError:
-            raise PWMError(None, 'Unknown duty cycle value: "%s"' % duty_cycle_ns)
+            raise PWMError(
+                None, 'Unknown duty cycle value: "%s"' % duty_cycle_ns
+            ) from ValueError
 
         # Convert duty cycle from nanoseconds to seconds
         duty_cycle = duty_cycle_ns / 1e9
index a4a1d990a58ecd8419873c81d2cd4b62403e6a5d..e01eb7b1e59f5222ebd4edf31eafb740688510fd 100644 (file)
@@ -6,13 +6,12 @@ import hid
 
 # Here if you need it
 MCP2221_HID_DELAY = float(os.environ.get("BLINKA_MCP2221_HID_DELAY", 0))
-# Use to set delay between reset and device reopen
+# Use to set delay between reset and device reopen. if negative, don't reset at all
 MCP2221_RESET_DELAY = float(os.environ.get("BLINKA_MCP2221_RESET_DELAY", 0.5))
 
 # from the C driver
 # http://ww1.microchip.com/downloads/en/DeviceDoc/mcp2221_0_1.tar.gz
 # others (???) determined during driver developement
-# pylint: disable=bad-whitespace
 RESP_ERR_NOERR = 0x00
 RESP_ADDR_NACK = 0x25
 RESP_READ_ERR = 0x7F
@@ -35,7 +34,6 @@ RESP_I2C_WRITINGNOSTOP = 0x45  # ???
 MCP2221_RETRY_MAX = 50
 MCP2221_MAX_I2C_DATA_LEN = 60
 MASK_ADDR_NACK = 0x40
-# pylint: enable=bad-whitespace
 
 
 class MCP2221:
@@ -53,7 +51,8 @@ class MCP2221:
     def __init__(self):
         self._hid = hid.device()
         self._hid.open(MCP2221.VID, MCP2221.PID)
-        self._reset()
+        if MCP2221_RESET_DELAY >= 0:
+            self._reset()
         self._gp_config = [0x07] * 4  # "don't care" initial value
         for pin in range(4):
             self.gp_set_mode(pin, self.GP_GPIO)  # set to GPIO mode
@@ -286,6 +285,8 @@ class MCP2221:
                     continue
                 if resp[2] in (RESP_READ_COMPL, RESP_READ_PARTIAL):
                     break
+            else:
+                raise RuntimeError("I2C read error: max retries reached.")
 
             # move data into buffer
             chunk = min(end - start, 60)
index 413938028eb6335cd849d2713a07b8424c9ab411..2ff0c2594e909c7af5c0e27b21ee90e3e0baf5ed 100644 (file)
@@ -3,7 +3,7 @@
 try:
     from microcontroller.pin import pwmOuts
 except ImportError:
-    raise RuntimeError("No PWM outputs defined for this board")
+    raise RuntimeError("No PWM outputs defined for this board") from ImportError
 
 from microcontroller.pin import Pin
 
index cfa96fe2ccababefb07f1e701a95a584d1842573..24d542dd5770a3a8d11b67f106fbd8f9822b35f3 100644 (file)
@@ -4,11 +4,11 @@ try:
     from greatfet.interfaces.adc import ADC
 
     gf = GreatFET()
-except:
+except ModuleNotFoundError:
     raise RuntimeError(
         "Unable to create GreatFET object. Make sure library is "
         "installed and the device is connected."
-    )
+    ) from ModuleNotFoundError
 
 
 class Pin:
index 5bb7889d3430f74aff8f13a37f2a6f6da742898d..91c3ede1b12e8902d2c3cc2a8ac3523d1d6b278c 100644 (file)
@@ -5,7 +5,7 @@ from greatfet import GreatFET
 try:
     from microcontroller.pin import pwmOuts
 except ImportError:
-    raise RuntimeError("No PWM outputs defined for this board")
+    raise RuntimeError("No PWM outputs defined for this board") from ImportError
 
 # pylint: disable=unnecessary-pass
 class PWMError(IOError):
diff --git a/src/adafruit_blinka/microcontroller/pentium/__init__.py b/src/adafruit_blinka/microcontroller/pentium/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/src/adafruit_blinka/microcontroller/pentium/n3710/.gitignore b/src/adafruit_blinka/microcontroller/pentium/n3710/.gitignore
new file mode 100644 (file)
index 0000000..0e7f550
--- /dev/null
@@ -0,0 +1 @@
+pins
diff --git a/src/adafruit_blinka/microcontroller/pentium/n3710/__init__.py b/src/adafruit_blinka/microcontroller/pentium/n3710/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/src/adafruit_blinka/microcontroller/pentium/n3710/pin.py b/src/adafruit_blinka/microcontroller/pentium/n3710/pin.py
new file mode 100644 (file)
index 0000000..3093a20
--- /dev/null
@@ -0,0 +1,86 @@
+"""Pentium N3710 (Braswell core SOC) pin names
+   i2c and GPIO can be accessed through Blinka.
+   For i2c use IC20_SCL, IC20-SDA and IC21-SCL, IC21-SDA in the i2c(<sdl, sda>) calls.
+   For UART use pyserial"""
+from adafruit_blinka.microcontroller.generic_linux.libgpiod_pin import Pin
+
+# gpiochip3
+GPIO_243 = Pin((3, 15))
+GPIO_246 = Pin((3, 18))
+GPIO_247 = Pin((3, 19))
+GPIO_249 = Pin((3, 21))
+GPIO_250 = Pin((3, 22))
+GPIO_253 = Pin((3, 25))
+GPIO_273 = Pin((3, 45))
+GPIO_275 = Pin((3, 47))
+GPIO_276 = Pin((3, 48))
+GPIO_278 = Pin((3, 50))
+GPIO_279 = Pin((3, 51))
+GPIO_280 = Pin((3, 52))
+GPIO_307 = Pin((3, 79))
+
+SDIO_D3 = SDMMC2_D3 = GPIO_243
+SDIO_DI = SDMMC2_D1 = GPIO_246
+SDIO_CLK = SDMMC2_CLK = GPIO_247
+SDIO_D2 = SDMMC2_D2 = GPIO_249
+SDIO_CMD = SDMMC2_CMD = GPIO_250
+SDIO_D0 = SDMMC2_D0 = GPIO_253
+
+MF_LPC_AD2 = GPIO_273
+MF_LPC_AD0 = GPIO_275
+LPC_FRAMEB = GPIO_276
+MF_LPC_AD3 = GPIO_278
+MF_LPC_CLKOUT0 = GPIO_279
+MF_LPC_AD1 = GPIO_280
+ILB_SERIRQ = GPIO_307
+
+# ggpiochip1
+GPIO_358 = Pin((1, 17))
+GPIO_SUS3 = SDIO_WAKE = GPIO_358
+
+
+# gpiochip0
+GPIO_490 = Pin((0, 76))
+GPIO_492 = Pin((0, 78))
+
+SATA_GP1 = TS_INT = GPIO_490
+SATA_GP2 = TS_RST = GPIO_492
+
+
+# not general gpio on chip 0
+# use pyserial not blinka.  These are only included for completeness
+
+UART1_RXD = Pin((0, 16))
+UART1_TXD = Pin((0, 20))
+UART1_RTS = Pin((0, 15))
+UART1_CTS = Pin((0, 18))
+
+UART2_RXD = Pin((0, 17))
+UART2_TXD = Pin((0, 21))
+UART2_RTS = Pin((0, 19))
+UART2_CTS = Pin((0, 22))
+
+GPIO_429 = UART1_RTS
+GPIO_430 = UART1_RXD
+GPIO_431 = UART2_RXD
+GPIO_432 = UART1_CTS
+GPIO_434 = UART1_TXD
+GPIO_435 = UART2_TXD
+GPIO_436 = UART2_CTS
+
+# i2c use these addresses when accessing i2c from Blinka.  You can also access
+# the i2c useing smbus
+I2C0_SDA = Pin((0, 61))  # IC21 on diagram, port 0 in hardware manual
+I2C0_SCL = Pin((0, 65))
+
+I2C1_SDA = TS_I2C_SDA = Pin((0, 45))  # I2C2 on diagram, port 5 in hardware manual
+I2C1_SCL = TS_I2C_SCL = Pin((0, 48))
+
+
+GPIO_469 = I2C1_SDA  # I2C2 on diagram
+GPIO_472 = I2C1_SCL
+GPIO_475 = I2C0_SDA  # I2C1 on diagram
+GPIO_479 = I2C0_SCL
+
+# ordered as i2cId, sclId, sdaId
+i2cPorts = ((0, I2C0_SCL, I2C0_SDA), (1, I2C1_SCL, I2C1_SDA))
diff --git a/src/adafruit_blinka/microcontroller/stm32/stm32f405/__init__.py b/src/adafruit_blinka/microcontroller/stm32/stm32f405/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
similarity index 98%
rename from src/adafruit_blinka/microcontroller/stm32/pin.py
rename to src/adafruit_blinka/microcontroller/stm32/stm32f405/pin.py
index b308069c35cdd7c3603bb4d039cc7d2e65a2eba0..52ec1c0e68428dde44d40ae42e07b3bf0daf7377 100755 (executable)
@@ -1,4 +1,4 @@
-"""STM32 pins"""
+"""STM32F405 pins"""
 
 from microcontroller import Pin
 
diff --git a/src/adafruit_blinka/microcontroller/stm32/stm32mp157/__init__.py b/src/adafruit_blinka/microcontroller/stm32/stm32mp157/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/src/adafruit_blinka/microcontroller/stm32/stm32mp157/pin.py b/src/adafruit_blinka/microcontroller/stm32/stm32mp157/pin.py
new file mode 100755 (executable)
index 0000000..0196982
--- /dev/null
@@ -0,0 +1,154 @@
+"""STM32MP157 pins"""
+from adafruit_blinka.microcontroller.generic_linux.periphery_pin import Pin
+
+PA0 = Pin((0, 0))
+PA1 = Pin((0, 1))
+PA2 = Pin((0, 2))
+PA3 = Pin((0, 3))
+PA4 = Pin((0, 4))
+PA5 = Pin((0, 5))
+PA6 = Pin((0, 6))
+PA7 = Pin((0, 7))
+PA8 = Pin((0, 8))
+PA9 = Pin((0, 9))
+PA11 = Pin((0, 11))
+PA12 = Pin((0, 12))
+PA13 = Pin((0, 13))
+PA14 = Pin((0, 14))
+PA15 = Pin((0, 15))
+PB0 = Pin((1, 0))
+PB1 = Pin((1, 1))
+PB2 = Pin((1, 2))
+PB3 = Pin((1, 3))
+PB4 = Pin((1, 4))
+PB5 = Pin((1, 5))
+PB6 = Pin((1, 6))
+PB7 = Pin((1, 7))
+PB8 = Pin((1, 8))
+PB9 = Pin((1, 9))
+PB10 = Pin((1, 10))
+PB11 = Pin((1, 11))
+PB12 = Pin((1, 12))
+PB13 = Pin((1, 13))
+PB14 = Pin((1, 14))
+PB15 = Pin((1, 15))
+PC0 = Pin((2, 0))
+PC1 = Pin((2, 1))
+PC2 = Pin((2, 2))
+PC3 = Pin((2, 3))
+PC4 = Pin((2, 4))
+PC5 = Pin((2, 5))
+PC6 = Pin((2, 6))
+PC7 = Pin((2, 7))
+PC8 = Pin((2, 8))
+PC9 = Pin((2, 9))
+PC10 = Pin((2, 10))
+PC11 = Pin((2, 11))
+PC12 = Pin((2, 12))
+PC13 = Pin((2, 13))
+PD0 = Pin((3, 0))
+PD1 = Pin((3, 1))
+PD2 = Pin((3, 2))
+PD3 = Pin((3, 3))
+PD4 = Pin((3, 4))
+PD5 = Pin((3, 5))
+PD6 = Pin((3, 6))
+PD7 = Pin((3, 7))
+PD8 = Pin((3, 8))
+PD9 = Pin((3, 9))
+PD10 = Pin((3, 10))
+PD11 = Pin((3, 11))
+PD12 = Pin((3, 12))
+PD13 = Pin((3, 13))
+PD14 = Pin((3, 14))
+PD15 = Pin((3, 15))
+PE0 = Pin((4, 0))
+PE1 = Pin((4, 1))
+PE2 = Pin((4, 2))
+PE3 = Pin((4, 3))
+PE4 = Pin((4, 4))
+PE5 = Pin((4, 5))
+PE6 = Pin((4, 6))
+PE7 = Pin((4, 7))
+PE8 = Pin((4, 8))
+PE9 = Pin((4, 9))
+PE10 = Pin((4, 10))
+PE11 = Pin((4, 11))
+PE12 = Pin((4, 12))
+PE13 = Pin((4, 13))
+PE14 = Pin((4, 14))
+PE15 = Pin((4, 15))
+PF0 = Pin((5, 0))
+PF1 = Pin((5, 1))
+PF2 = Pin((5, 2))
+PF3 = Pin((5, 3))
+PF4 = Pin((5, 4))
+PF5 = Pin((5, 5))
+PF6 = Pin((5, 6))
+PF7 = Pin((5, 7))
+PF8 = Pin((5, 8))
+PF9 = Pin((5, 9))
+PF10 = Pin((5, 10))
+PF11 = Pin((5, 11))
+PF12 = Pin((5, 12))
+PF13 = Pin((5, 13))
+PF14 = Pin((5, 14))
+PF15 = Pin((5, 15))
+PG1 = Pin((6, 1))
+PG2 = Pin((6, 2))
+PG3 = Pin((6, 3))
+PG4 = Pin((6, 4))
+PG5 = Pin((6, 5))
+PG6 = Pin((6, 6))
+PG7 = Pin((6, 7))
+PG8 = Pin((6, 8))
+PG9 = Pin((6, 9))
+PG10 = Pin((6, 10))
+PG11 = Pin((6, 11))
+PG12 = Pin((6, 12))
+PG13 = Pin((6, 13))
+PG14 = Pin((6, 14))
+PG15 = Pin((6, 15))
+PH2 = Pin((7, 2))
+PH3 = Pin((7, 3))
+PH4 = Pin((7, 4))
+PH5 = Pin((7, 5))
+PH6 = Pin((7, 6))
+PH7 = Pin((7, 7))
+PH8 = Pin((7, 8))
+PH9 = Pin((7, 9))
+PH10 = Pin((7, 10))
+PH11 = Pin((7, 11))
+PH12 = Pin((7, 12))
+PH13 = Pin((7, 13))
+PH14 = Pin((7, 14))
+PH15 = Pin((7, 15))
+PI0 = Pin((8, 0))
+PI1 = Pin((8, 1))
+PI2 = Pin((8, 2))
+PI3 = Pin((8, 3))
+PI4 = Pin((8, 4))
+PI5 = Pin((8, 5))
+PI6 = Pin((8, 6))
+PI7 = Pin((8, 7))
+PI8 = Pin((8, 8))
+PI9 = Pin((8, 9))
+PI10 = Pin((8, 10))
+PI11 = Pin((8, 11))
+PZ0 = Pin((9, 0))
+PZ1 = Pin((9, 1))
+PZ2 = Pin((9, 2))
+PZ3 = Pin((9, 3))
+PZ4 = Pin((9, 4))
+PZ5 = Pin((9, 5))
+PZ6 = Pin((9, 6))
+PZ7 = Pin((9, 7))
+
+# ordered as uartId, txId, rxId
+UART_PORTS = ((3, PB10, PB12),)
+
+# ordered as i2cId, sclId, sdaId
+I2C_PORTS = (
+    (1, PD12, PF15),
+    (5, PA11, PA12),
+)
index 9a803cbe8daa7022562ee9ac9a6b12ff3778b58b..4bcfff9984064042dc49cb3a4976e0f188684a00 100644 (file)
@@ -111,6 +111,9 @@ Y02 = Pin("SPI3_MOSI")
 T07 = Pin("DAP5_DIN")
 T06 = Pin("DAP5_DOUT")
 
+# Clara AGX Xavier only
+P04 = Pin("SOC_GPIO04")
+
 # Shared
 N01 = Pin("SOC_GPIO54")
 R00 = Pin("SOC_GPIO44")
index da35c7d527e18dd2f74119d9fb2113e3a78497a6..1ae88b81904566d4b76b70513fafb0b1ac438a8b 100755 (executable)
@@ -50,10 +50,10 @@ elif detector.board.any_raspberry_pi_40_pin:
 elif detector.board.any_raspberry_pi_cm:
     from adafruit_blinka.board.raspberrypi.raspi_cm import *
 
-elif detector.board.RASPBERRY_PI_A or detector.board.RASPBERRY_PI_B_REV1:
+elif detector.board.RASPBERRY_PI_B_REV1:
     from adafruit_blinka.board.raspberrypi.raspi_1b_rev1 import *
 
-elif detector.board.RASPBERRY_PI_B_REV2:
+elif detector.board.RASPBERRY_PI_A or detector.board.RASPBERRY_PI_B_REV2:
     from adafruit_blinka.board.raspberrypi.raspi_1b_rev2 import *
 
 elif board_id == ap_board.BEAGLEBONE_BLACK:
@@ -96,6 +96,9 @@ elif board_id == ap_board.ORANGE_PI_PLUS_2E:
 elif board_id == ap_board.ORANGE_PI_2:
     from adafruit_blinka.board.orangepi.orangepipc import *
 
+elif board_id == ap_board.BANANA_PI_M2_ZERO:
+    from adafruit_blinka.board.bananapi.bpim2zero import *
+
 elif board_id == ap_board.GIANT_BOARD:
     from adafruit_blinka.board.giantboard import *
 
@@ -114,6 +117,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.CLARA_AGX_XAVIER:
+    from adafruit_blinka.board.nvidia.clara_agx_xavier import *
+
 elif board_id == ap_board.CORAL_EDGE_TPU_DEV:
     from adafruit_blinka.board.coral_edge_tpu import *
 
@@ -162,6 +168,12 @@ elif board_id == ap_board.ONION_OMEGA2:
 elif board_id == ap_board.ROCK_PI_S:
     from adafruit_blinka.board.radxa.rockpis import *
 
+elif board_id == ap_board.UDOO_X86:
+    from adafruit_blinka.board.udoo_x86ultra import *
+
+elif board_id == ap_board.STM32MP157C_DK2:
+    from adafruit_blinka.board.stm32.stm32mp157c_dk2 import *
+
 elif "sphinx" in sys.modules:
     pass
 
index 279bd46f80ba4910aff9e1518d54c70c482f5cc7..1cad051eaedfb50ed3c16217acdc4a4a108a3629 100755 (executable)
@@ -127,7 +127,7 @@ class I2C(Lockable):
         in_end=None,
         stop=False
     ):
-        """"Write to a device at specified address from a buffer then read
+        """ "Write to a device at specified address from a buffer then read
         from a device at specified address into a buffer
         """
         return self._i2c.writeto_then_readfrom(
@@ -293,7 +293,7 @@ class SPI(Lockable):
         except AttributeError:
             raise NotImplementedError(
                 "Frequency attribute not implemented for this platform"
-            )
+            ) from AttributeError
 
     def write(self, buf, start=0, end=None):
         """Write to the SPI device"""
@@ -412,3 +412,36 @@ class UART(Lockable):
     def write(self, buf):
         """Write to the UART from a buffer"""
         return self._uart.write(buf)
+
+
+class OneWire:
+    """
+    Stub class for OneWire, which is currently not implemented
+    """
+
+    def __init__(self, pin):
+        raise NotImplementedError("OneWire has not been implemented")
+
+    def deinit(self):
+        """
+        Deinitialize the OneWire bus and release any hardware resources for reuse.
+        """
+        raise NotImplementedError("OneWire has not been implemented")
+
+    def reset(self):
+        """
+        Reset the OneWire bus and read presence
+        """
+        raise NotImplementedError("OneWire has not been implemented")
+
+    def read_bit(self):
+        """
+        Read in a bit
+        """
+        raise NotImplementedError("OneWire has not been implemented")
+
+    def write_bit(self, value):
+        """
+        Write out a bit based on value.
+        """
+        raise NotImplementedError("OneWire has not been implemented")
index 4b0036b6537f835236f5324f8bb45418a03e3ddc..080abbf2c008bfd3507395d5863d913215f4c8f5 100755 (executable)
@@ -53,10 +53,15 @@ elif detector.board.binho_nova:
     from adafruit_blinka.microcontroller.nova.pin import Pin
 elif detector.board.greatfet_one:
     from adafruit_blinka.microcontroller.nxp_lpc4330.pin import Pin
-elif detector.chip.STM32:
+elif detector.chip.STM32F405:
     from machine import Pin
 elif detector.board.microchip_mcp2221:
     from adafruit_blinka.microcontroller.mcp2221.pin import Pin
+elif detector.chip.PENTIUM_N3710:
+    from adafruit_blinka.microcontroller.pentium.n3710.pin import Pin
+elif detector.chip.STM32MP157:
+    from adafruit_blinka.microcontroller.stm32.stm32mp157.pin import Pin
+
 from adafruit_blinka import Enum, ContextManaged
 
 
index 027a557e6cfe8c2aec9c8d4821bc813964644ee5..afca22ac7339ec0287a57f5c33a0e42a9ea67949 100755 (executable)
@@ -34,8 +34,8 @@ class Pin(Enum):
 
 if chip_id == ap_chip.ESP8266:
     from adafruit_blinka.microcontroller.esp8266 import *
-elif chip_id == ap_chip.STM32:
-    from adafruit_blinka.microcontroller.stm32 import *
+elif chip_id == ap_chip.STM32F405:
+    from adafruit_blinka.microcontroller.stm32.stm32f405 import *
 elif chip_id == ap_chip.BCM2XXX:
     from adafruit_blinka.microcontroller.bcm283x import *
 elif chip_id == ap_chip.AM33XX:
@@ -78,5 +78,9 @@ elif chip_id == ap_chip.MIPS24KC:
     from adafruit_blinka.microcontroller.atheros.ar9331.pin import *
 elif chip_id == ap_chip.MIPS24KEC:
     from adafruit_blinka.microcontroller.mips24kec.pin import *
+elif chip_id == ap_chip.PENTIUM_N3710:
+    from adafruit_blinka.microcontroller.pentium.n3710.pin import *
+elif chip_id == ap_chip.STM32MP157:
+    from adafruit_blinka.microcontroller.stm32.stm32mp157.pin import *
 else:
     raise NotImplementedError("Microcontroller not supported:", chip_id)
index 09edd3ce217be3e568f017eca2364f7d46945c35..fe89bd9361da90e8ae46350315daa8add9ec4eed 100755 (executable)
@@ -8,8 +8,8 @@ from adafruit_blinka.agnostic import chip_id
 
 if chip_id == ap_chip.ESP8266:
     from adafruit_blinka.microcontroller.esp8266.pin import *
-elif chip_id == ap_chip.STM32:
-    from adafruit_blinka.microcontroller.stm32.pin import *
+elif chip_id == ap_chip.STM32F405:
+    from adafruit_blinka.microcontroller.stm32.stm32f405.pin import *
 elif chip_id == ap_chip.BCM2XXX:
     from adafruit_blinka.microcontroller.bcm283x.pin import *
 elif chip_id == ap_chip.AM33XX:
@@ -56,5 +56,9 @@ elif chip_id == ap_chip.MIPS24KC:
     from adafruit_blinka.microcontroller.atheros.ar9331.pin import *
 elif chip_id == ap_chip.MIPS24KEC:
     from adafruit_blinka.microcontroller.mips24kec.pin import *
+elif chip_id == ap_chip.PENTIUM_N3710:
+    from adafruit_blinka.microcontroller.pentium.n3710.pin import *
+elif chip_id == ap_chip.STM32MP157:
+    from adafruit_blinka.microcontroller.stm32.stm32mp157.pin import *
 else:
     raise NotImplementedError("Microcontroller not supported: ", chip_id)
index 5ad38e21d1d83816ed2263a24da828291a416751..3fcecc34c4f603e97ca8dd4bccb6e30f3c56e243 100644 (file)
@@ -3,8 +3,8 @@ import unittest
 
 class TestEnum(unittest.TestCase):
     """
-        Verifies the repl() and str() behaviour of an example Enum
-        Enums represent configuration values such as digitalio.Direction, digitalio.Pull etc.
+    Verifies the repl() and str() behaviour of an example Enum
+    Enums represent configuration values such as digitalio.Direction, digitalio.Pull etc.
     """
 
     def setUp(self):
@@ -24,7 +24,13 @@ class TestEnum(unittest.TestCase):
     def test_iteritems(self):
         """A subtype of Enum can list all attributes of its own type"""
         items = list(self.Cls.iteritems())
-        self.assertEqual(items, [("one", self.Cls.one), ("two", self.Cls.two),])
+        self.assertEqual(
+            items,
+            [
+                ("one", self.Cls.one),
+                ("two", self.Cls.two),
+            ],
+        )
 
     def test_repr(self):
         """A repr() call on an Enum gives its fully-qualified name"""