Skip to content

Commit 6d69283

Browse files
committed
Correct the docs and usage example for SPIDevice
1 parent 6a20bf8 commit 6d69283

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

adafruit_bus_device/spi_device.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,15 @@
2020
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2121
# THE SOFTWARE.
2222

23+
import digitalio
24+
2325
class SPIDevice:
2426
"""
2527
Represents a single SPI device and manages locking the bus and the device
2628
address.
2729
2830
:param ~busio.SPI spi: The SPI bus the device is on
29-
:param ~microcontroller.Pin chip_select: The chip select pin
31+
:param ~digitalio.DigitalInOut chip_select: The chip select pin object that implements the DigitalInOut API.
3032
:param int extra_clocks: The minimum number of clock cycles to cycle the bus after CS is high. (Used for SD cards.)
3133
3234
.. note:: This class is **NOT** built into CircuitPython. See
@@ -37,14 +39,16 @@ class SPIDevice:
3739
.. code-block:: python
3840
3941
import busio
42+
import digitalio
4043
from board import *
41-
from adafruit_bus_device.spi_device import I2CDevice
44+
from adafruit_bus_device.spi_device import SPIDevice
4245
4346
with busio.SPI(SCK, MOSI, MISO) as spi_bus:
44-
device = SPIDevice(spi_bus, D10)
47+
cs = digitalio.DigitalInOut(D10)
48+
device = SPIDevice(spi_bus, cs)
4549
bytes_read = bytearray(4)
4650
with device as spi:
47-
spi_device.read(bytes_read)
51+
spi_device.readinto(bytes_read)
4852
# A second transaction
4953
with device as spi:
5054
spi.write(bytes_read)

0 commit comments

Comments
 (0)