Skip to content

Commit d06079e

Browse files
committed
docs(sdcardio): describe the real shared-SPI CS invariant
The previous ".. important::" note said SD card init must come first on a shared SPI bus. That rule happened to work when every co-resident CS line had a hardware pull-up, but it is not the real invariant: what actually matters is that every CS on the shared bus is in a known HIGH (deselected) state before any SPI transaction. On boards where a CS floats (e.g. the Feather RP2040 RFM, whose RFM_CS has no pull-up), it must be driven HIGH in software; init order is secondary.
1 parent bfb650d commit d06079e

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

shared-bindings/sdcardio/SDCard.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,18 @@
3838
//| the microcontroller)
3939
//|
4040
//| .. important::
41-
//| If the same SPI bus is shared with other peripherals, it is important that
42-
//| the SD card be initialized before accessing any other peripheral on the bus.
43-
//| Failure to do so can prevent the SD card from being recognized until it is
44-
//| powered off or re-inserted.
41+
//| When the SPI bus is shared with other peripherals, every CS pin on
42+
//| the bus must be in a known HIGH (deselected) state before any SPI
43+
//| transaction occurs. This is normally guaranteed by a hardware
44+
//| pull-up on each CS line, but on boards where a co-resident
45+
//| peripheral's CS floats (for example the Feather RP2040 RFM, whose
46+
//| ``RFM_CS`` has no pull-up), that CS must be driven HIGH in
47+
//| software before the SD card is initialized. If any CS is allowed
48+
//| to float low, the SPI bus can be corrupted during SD card init
49+
//| and the card may not be recognized until it is powered off or
50+
//| re-inserted. The order in which peripherals are constructed is
51+
//| secondary; what matters is that all CS lines are deselected
52+
//| before any SPI transaction.
4553
//|
4654
//| Example usage:
4755
//|

0 commit comments

Comments
 (0)