# SPDX-License-Identifier: MIT
name: 🐞 Bug Report
-description: Create a bug report to help us improve
+description: Create a bug report to help us improve. Use New Board Request if your board isn't being detected.
labels:
- bug
body:
---
-name: ð\9f\9a\80 New Board Request
+name: ð\9f\93\9f New Board Request
about: Request Support for a New Board
title: ''
labels: 'New Board Request'
# Required
version: 2
+build:
+ os: "ubuntu-20.04"
+ tools:
+ python: "3.7"
+
python:
- version: "3.7"
install:
- requirements: docs/requirements.txt
- requirements: requirements.txt
Usage Example
=============
-At the time of writing (`git:7fc1f8ab <https://github.com/cefn/Adafruit_Micropython_Blinka/tree/7fc1f8ab477124628a5afebbf6826005955805f9>`_),
-the following sequence runs through some basic testing of the digitalio compatibility layer...
+The pin names may vary by board, so you may need to change the pin names in the code. This
+example runs on the Raspberry Pi boards to blink an LED connected to GPIO 18 (Pin 12):
.. code-block:: python
- from testing import test_module_name
- test_module_name("testing.universal.digitalio")
+ import time
+ import board
+ import digitalio
-An example log from running the suites is `here <https://github.com/cefn/Adafruit_Micropython_Blinka/issues/2#issuecomment-366713394>`_ .
+ PIN = board.D18
+
+ print("hello blinky!")
+
+ led = digitalio.DigitalInOut(PIN)
+ led.direction = digitalio.Direction.OUTPUT
+
+ while True:
+ led.value = True
+ time.sleep(0.5)
+ led.value = False
+ time.sleep(0.5)
Contributing
============
or b"brcm,bcm2711" in compat
):
board_reqs = ["RPi.GPIO", "rpi_ws281x>=4.0.0", "sysv_ipc>=1.1.0"]
+ if (
+ b"ti,am335x" in compat
+ ): # BeagleBone Black, Green, PocketBeagle, BeagleBone AI, etc.
+ board_reqs = ["Adafruit_BBIO"]
setup(
name="Adafruit-Blinka",
#
# SPDX-License-Identifier: MIT
"""AM335x pin names"""
-from Adafruit_BBIO import GPIO
+try:
+ from Adafruit_BBIO import GPIO
+except ImportError as error:
+ raise RuntimeError(
+ "The library 'Adafruit_BBIO' was not found. To install, try typing: "
+ "pip install Adafruit_BBIO"
+ ) from error
class Pin:
chip0 = gpiod.chip("0")
chip1 = gpiod.chip("1")
+if callable(chip0.num_lines):
+ chip0lines = chip0.num_lines()
+else:
+ chip0lines = chip0.num_lines
+
+if callable(chip1.num_lines):
+ chip1lines = chip1.num_lines()
+else:
+ chip1lines = chip1.num_lines
-if chip0.num_lines < 20:
+if chip0lines < 20:
aobus = 0
periphs = 1
- periphs_offset = chip1.num_lines - 85
+ periphs_offset = chip1lines - 85
else:
aobus = 1
periphs = 0
- periphs_offset = chip0.num_lines - 85
+ periphs_offset = chip0lines - 85
del chip0
del chip1
#
# SPDX-License-Identifier: MIT
"""Generic Linux I2C class using PureIO's smbus class"""
+
+import warnings
from Adafruit_PureIO import smbus
class I2C:
- """I2C class"""
+ """
+ I2C class
+
+ Baudrate has no effect on Linux systems. The argument is only there for compatibility.
+ """
MASTER = 0
SLAVE = 1
raise NotImplementedError("Only I2C Master supported!")
_mode = self.MASTER
- # if baudrate != None:
- # print("I2C frequency is not settable in python, ignoring!")
+ if baudrate is not None:
+ warnings.warn(
+ "I2C frequency is not settable in python, ignoring!", RuntimeWarning
+ )
try:
self._i2c_bus = smbus.SMBus(bus_num)
def write(self, buf, start=0, end=None):
"""Write data from the buffer to SPI"""
- if not buf:
+ if buf is None or len(buf) < 1:
return
if end is None:
end = len(buf)
def readinto(self, buf, start=0, end=None, write_value=0):
"""Read data from SPI and into the buffer"""
- if not buf:
+ if buf is None or len(buf) < 1:
return
if end is None:
end = len(buf)
"""Perform a half-duplex write from buffer_out and then
read data into buffer_in
"""
- if not buffer_out or not buffer_in:
+ if buffer_out is None or buffer_in is None:
+ return
+ if len(buffer_out) < 1 or len(buffer_in) < 1:
return
if out_end is None:
out_end = len(buffer_out)
"""
Busio I2C Class for CircuitPython Compatibility. Used
for both MicroPython and Linux.
+
+ NOTE: Frequency has no effect on Linux systems. The argument is only there for compatibility.
"""
def __init__(self, scl, sda, frequency=100000):
if detector.board.any_embedded_linux:
from adafruit_blinka.microcontroller.generic_linux.i2c import I2C as _I2C
+
+ if frequency == 100000:
+ frequency = None # Set to None if default to avoid triggering warning
elif detector.board.ftdi_ft2232h:
from adafruit_blinka.microcontroller.ftdi_mpsse.mpsse.i2c import I2C as _I2C
else: