Skip to content

Commit 76b1d23

Browse files
committed
CS should be high during first initialization
1 parent 597dffe commit 76b1d23

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

adafruit_sdcard.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,15 +97,17 @@ def __init__(self, spi, cs, baudrate=1320000):
9797
self._cdv = 512
9898

9999
# initialise the card
100-
self._init_card()
100+
self._init_card(cs)
101101

102102
# Create a new SPIDevice with the (probably) higher operating baudrate.
103103
self._spi = spi_device.SPIDevice(spi, cs, baudrate=baudrate, extra_clocks=8)
104104

105-
def _init_card(self):
105+
def _init_card(self, cs):
106106
"""Initialize the card in SPI mode."""
107107
# clock card at least 80 cycles with cs high
108108
with self._spi as card:
109+
# Force CS high.
110+
cs.value = True
109111
self._single_byte[0] = 0xFF
110112
for _ in range(80 // 8 + 1):
111113
card.write(self._single_byte)

0 commit comments

Comments
 (0)