From: Andy Date: Mon, 25 Mar 2019 22:04:38 +0000 (-0700) Subject: Merge remote-tracking branch 'ada/master' into jetson X-Git-Tag: 1.2.8^2 X-Git-Url: https://git.ayoreis.com/Adafruit_Blinka-hackapet.git/commitdiff_plain/a8bd0c058b91b06b5e216632261503745a2cb675?hp=fe2eaf883fff4d8570c97af1c0166214f57c7d8b Merge remote-tracking branch 'ada/master' into jetson --- diff --git a/README.rst b/README.rst index 887c262..d33adb4 100755 --- a/README.rst +++ b/README.rst @@ -28,7 +28,7 @@ Dependencies ============= 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 diff --git a/setup.py b/setup.py index bc5c091..7663c15 100755 --- a/setup.py +++ b/setup.py @@ -30,9 +30,10 @@ setup( 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", diff --git a/src/adafruit_blinka/microcontroller/bcm283x/pulseio/__init__.py b/src/adafruit_blinka/microcontroller/bcm283x/pulseio/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/adafruit_blinka/microcontroller/generic_linux/spi.py b/src/adafruit_blinka/microcontroller/generic_linux/spi.py index b905873..a8141b9 100755 --- a/src/adafruit_blinka/microcontroller/generic_linux/spi.py +++ b/src/adafruit_blinka/microcontroller/generic_linux/spi.py @@ -50,7 +50,7 @@ class SPI: 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: @@ -64,7 +64,7 @@ class SPI: 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() @@ -77,7 +77,7 @@ class SPI: 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: diff --git a/src/board.py b/src/board.py index fef78ee..db6f8a4 100755 --- a/src/board.py +++ b/src/board.py @@ -78,3 +78,13 @@ elif "sphinx" in sys.modules: 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) diff --git a/src/busio.py b/src/busio.py index 45e36e4..8810fc4 100755 --- a/src/busio.py +++ b/src/busio.py @@ -129,7 +129,7 @@ class SPI(Lockable): 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)