]> Repositories - Adafruit_Blinka-hackapet.git/commitdiff
ft232h: Fix SPI.readinto's write_value= argument
authorJeff Epler <jepler@gmail.com>
Thu, 28 Jan 2021 21:59:38 +0000 (15:59 -0600)
committerJeff Epler <jepler@gmail.com>
Thu, 28 Jan 2021 21:59:38 +0000 (15:59 -0600)
Before, this argument was ignored.  This prevented adafruit_sdcard from
functioning, as it relies on being able to send out the value 0xff.

src/adafruit_blinka/microcontroller/ft232h/spi.py

index 81797b3557397d85ab7ccef30b2a576cc3c42f01..af164e97b92929ea86550af0f3b321092271acc8 100644 (file)
@@ -67,7 +67,10 @@ class SPI:
     def readinto(self, buf, start=0, end=None, write_value=0):
         """Read data from SPI and into the buffer"""
         end = end if end else len(buf)
-        result = self._port.read(end - start)
+        buffer_out = [write_value] * (end-start)
+        result = self._port.exchange(
+            buffer_out, end - start, duplex=True
+        )
         for i, b in enumerate(result):
             buf[start + i] = b