]> Repositories - Adafruit_Blinka-hackapet.git/blobdiff - src/adafruit_blinka/microcontroller/ft232h/spi.py
Merge pull request #464 from twa127/master
[Adafruit_Blinka-hackapet.git] / src / adafruit_blinka / microcontroller / ft232h / spi.py
index 81797b3557397d85ab7ccef30b2a576cc3c42f01..fd16b39348f71f5c23c063ea3434bcfebe194ef2 100644 (file)
@@ -1,5 +1,6 @@
 """SPI Class for FT232H"""
 from adafruit_blinka.microcontroller.ft232h.pin import Pin
 """SPI Class for FT232H"""
 from adafruit_blinka.microcontroller.ft232h.pin import Pin
+from adafruit_blinka.microcontroller.ft232h.url import get_ftdi_url
 
 # pylint: disable=protected-access
 class SPI:
 
 # pylint: disable=protected-access
 class SPI:
@@ -14,7 +15,7 @@ class SPI:
         # pylint: enable=import-outside-toplevel
 
         self._spi = SpiController(cs_count=1)
         # pylint: enable=import-outside-toplevel
 
         self._spi = SpiController(cs_count=1)
-        self._spi.configure("ftdi://ftdi:ft232h/1")
+        self._spi.configure(get_ftdi_url())
         self._port = self._spi.get_port(0)
         self._port.set_frequency(100000)
         self._port._cpol = 0
         self._port = self._spi.get_port(0)
         self._port.set_frequency(100000)
         self._port._cpol = 0
@@ -67,7 +68,8 @@ 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)
     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
 
         for i, b in enumerate(result):
             buf[start + i] = b