File tree 1 file changed +8
-4
lines changed
1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change 20
20
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
21
# THE SOFTWARE.
22
22
23
+ import digitalio
24
+
23
25
class SPIDevice :
24
26
"""
25
27
Represents a single SPI device and manages locking the bus and the device
26
28
address.
27
29
28
30
: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.
30
32
:param int extra_clocks: The minimum number of clock cycles to cycle the bus after CS is high. (Used for SD cards.)
31
33
32
34
.. note:: This class is **NOT** built into CircuitPython. See
@@ -37,14 +39,16 @@ class SPIDevice:
37
39
.. code-block:: python
38
40
39
41
import busio
42
+ import digitalio
40
43
from board import *
41
- from adafruit_bus_device.spi_device import I2CDevice
44
+ from adafruit_bus_device.spi_device import SPIDevice
42
45
43
46
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)
45
49
bytes_read = bytearray(4)
46
50
with device as spi:
47
- spi_device.read (bytes_read)
51
+ spi_device.readinto (bytes_read)
48
52
# A second transaction
49
53
with device as spi:
50
54
spi.write(bytes_read)
You can’t perform that action at this time.
0 commit comments