SDCard(bus: busio.SPI, cs: microcontroller.Pin, baudrate: int = 8000000)¶
SD Card Block Interface
Controls an SD card over SPI. This built-in module has higher read performance than the library adafruit_sdcard, but it is only compatible with
bitbangio.SPI. Usually an SDCard object is used with
storage.VfsFatto allow file I/O to an SD card.
Construct an SPI SD Card object with the given properties
Note that during detection and configuration, a hard-coded low baudrate is used. Data transfers use the specified baurate (rounded down to one that is supported by the microcontroller)
If the same SPI bus is shared with other peripherals, it is important that the SD card be initialized before accessing any other peripheral on the bus. Failure to do so can prevent the SD card from being recognized until it is powered off or re-inserted.
import os import board import sdcardio import storage sd = sdcardio.SDCard(board.SPI(), board.SD_CS) vfs = storage.VfsFat(sd) storage.mount(vfs, '/sd') os.listdir('/sd')
count(self) → int¶
Returns the total number of sectors
Due to technical limitations, this is a function and not a property.
The number of 512-byte blocks, as a number
readblocks(self, start_block: int, buf: _typing.WriteableBuffer) → None¶
Read one or more blocks from the card