sdcardio

Interface to an SD card via the SPI bus

class sdcardio.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 busio.SPI, not bitbangio.SPI. Usually an SDCard object is used with storage.VfsFat to allow file I/O to an SD card.

count(self)

Returns the total number of sectors

Due to technical limitations, this is a function and not a property.

Returns:The number of 512-byte blocks, as a number
deinit(self)

Disable permanently.

Returns:None
readblocks(self, start_block: int, buf: WriteableBuffer)

Read one or more blocks from the card

Parameters:
  • start_block (int) – The block to start reading from
  • buf (bytearray) – The buffer to write into. Length must be multiple of 512.
Returns:

None

writeblocks(self, start_block: int, buf: ReadableBuffer)

Write one or more blocks to the card

Parameters:
  • start_block (int) – The block to start writing from
  • buf (bytearray) – The buffer to read from. Length must be multiple of 512.
Returns:

None