=============
The Micropython compatibility layers described above are intended to provide a CircuitPython-like API for devices which
-are running Micropython. Since corresponding packages should be built-in to any standard
+are running CPython or Micropython. Since corresponding packages should be built-in to any standard
CircuitPython image, they have no value on a device already running CircuitPython and would likely conflict in unhappy ways.
The test suites in the test/src folder under **testing.universal** are by design
url='https://github.com/adafruit/Adafruit_Blinka',
package_dir={'': 'src'},
packages=find_packages("src"),
- # This seems to override find_packages above - I suspect but don't know for sure that
- # we're doing this for a reason -- bpb 2019-01-15:
+ # py_modules lists top-level single file packages to include.
+ # find_packages only finds packages in directories with __init__.py files.
py_modules=['bitbangio', 'board', 'busio', 'digitalio', 'micropython', 'pulseio', 'neopixel_write'],
+ package_data={'adafruit_blinka.microcontroller.bcm283x.pulseio': ['libgpiod_pulsein']},
install_requires=[
"Adafruit-PlatformDetect",
"Adafruit-PureIO",
print("Could not open SPI device - check if SPI is enabled in kernel!")
raise
- def readinto(self, buf, start=0, end=None):
+ def readinto(self, buf, start=0, end=None, write_value=0):
if not buf:
return
if end is None:
self._spi.max_speed_hz = self.baudrate
self._spi.mode = self.mode
self._spi.bits_per_word = self.bits
- data = self._spi.readbytes(end-start)
+ data = self._spi.xfer([write_value]*(end-start))
for i in range(end-start): # 'readinto' the given buffer
buf[start+i] = data[i]
self._spi.close()
if not buffer_out or not buffer_in:
return
if out_end is None:
- out_end = len(buffer_out)
+ out_end = len(buffer_out)
if in_end is None:
in_end = len(buffer_in)
if out_end - out_start != in_end - in_start:
else:
raise NotImplementedError("Board not supported")
+
+def I2C():
+ """The singleton I2C interface"""
+ import busio
+ return busio.I2C(SCL, SDA)
+
+def SPI():
+ """The singleton SPI interface"""
+ import busio
+ return busio.SPI(SCLK, MOSI, MISO)
return self._spi.write(buf, start, end)
def readinto(self, buf, start=0, end=None, write_value=0):
- return self._spi.readinto(buf, start, end)
+ return self._spi.readinto(buf, start, end, write_value=write_value)
def write_readinto(self, buffer_out, buffer_in, out_start=0, out_end=None, in_start=0, in_end=None):
return self._spi.write_readinto(buffer_out, buffer_in, out_start, out_end, in_start, in_end)