]> Repositories - Adafruit_Blinka-hackapet.git/commitdiff
Merge remote-tracking branch 'ada/master' into jetson
authorAndy <antan@nvidia.com>
Mon, 25 Mar 2019 22:04:38 +0000 (15:04 -0700)
committerAndy <antan@nvidia.com>
Mon, 25 Mar 2019 22:04:38 +0000 (15:04 -0700)
README.rst
setup.py
src/adafruit_blinka/microcontroller/bcm283x/pulseio/__init__.py [new file with mode: 0644]
src/adafruit_blinka/microcontroller/generic_linux/spi.py
src/board.py
src/busio.py

index 887c262474e1f391120cdd94eee8a7a8d0b4b1a4..d33adb4e693abdfa0cc9e30d0c4af4974ce609c5 100755 (executable)
@@ -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
index bc5c0918334103aee05060e6426fe11bc5fafeaa..7663c15e1b50c8421ff4d1ce6b05a34f388dae29 100755 (executable)
--- 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 (file)
index 0000000..e69de29
index b90587316536e105499e17d317a2073079b7fb18..a8141b96a0e84a0c90c1f5eab05502f8fede8754 100755 (executable)
@@ -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:
index fef78ee0a36c3c3193b1272d50bf5f04077a02b9..db6f8a4655bb5ec59b1e32b7db6d3a59895a879d 100755 (executable)
@@ -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)
index 45e36e4d64e8bc45f7925954a46b91a5f2feb2bf..8810fc4c8e6b9e45d4fd3cd365bebe193d1315fc 100755 (executable)
@@ -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)