CHGame 0.3.0
Libraries for the CHGame handheld
Loading...
Searching...
No Matches
SD card blocks

A read-only SPI-mode microSD block driver: sd::init(), sd::read() and sd::stream(). More...

Namespaces

namespace  sd
 The SD card's SPI-mode block driver (CHSd).
 

Detailed Description

A read-only SPI-mode microSD block driver: sd::init(), sd::read() and sd::stream().

HypeRunner's clean-room driver cut down to what reading a game's data file needs: identify the card, read one 512-byte block. No writing, no CRC (the games' files check their own blocks or records), and DMA only in stream(), for a sketch that reads whole files every frame. Most sketches never call these directly: fat::open() and fat::read() do it for them.

The card is a block device addressed by LBA (512-byte block number) whatever its size: SDSC, SDHC and SDXC cards all work.

Warning
Bus rule. SPI1 is shared with the LCD. Call these only after gfx_wait(), before the next flush. SPI1 is handed back exactly as CHGfx left it.
Note
After a read fails, call sd::init() before reading again: a block whose token came late may still be on its way, and init()'s CMD0 is what clears it.