Skip to content

Commit

Permalink
Merge pull request #719 from makermelissa/fix-spi-buffer
Browse files Browse the repository at this point in the history
Update SPI to work with ReadableBuffers
  • Loading branch information
tannewt authored Sep 19, 2023
2 parents d7c11ae + b9ff028 commit 234688c
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/adafruit_blinka/microcontroller/generic_linux/spi.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def frequency(self):

def write(self, buf, start=0, end=None):
"""Write data from the buffer to SPI"""
if not buf:
if buf is None or len(buf) < 1:
return
if end is None:
end = len(buf)
Expand All @@ -91,7 +91,7 @@ def write(self, buf, start=0, end=None):

def readinto(self, buf, start=0, end=None, write_value=0):
"""Read data from SPI and into the buffer"""
if not buf:
if buf is None or len(buf) < 1:
return
if end is None:
end = len(buf)
Expand All @@ -116,7 +116,9 @@ def write_readinto(
"""Perform a half-duplex write from buffer_out and then
read data into buffer_in
"""
if not buffer_out or not buffer_in:
if buffer_out is None or buffer_in is None:
return
if len(buffer_out) < 1 or len(buffer_in) < 1:
return
if out_end is None:
out_end = len(buffer_out)
Expand Down

0 comments on commit 234688c

Please sign in to comment.