Function SDC Init

From Uzebox Wiki
Jump to: navigation, search

uint8_t SDC_Init(sdc_struct_t* sds);


Detects and initializes SD card.

  • sds: SD data structure. The bufp field must point to a valid 512 byte buffer.

Zero on success, error code on failure.

Video Modes



V.5.x.x bootloaders


This takes a few dozen milliseconds. It populates the SD data structure according to the results, which means setting the Initialized, SDHC and CRC flags. Normally you don't ever need to call this as it is called by FS_Init().

The error codes returned by this function:

  • 1: CMD0 failed (possibly no card in socket)
  • 2: CMD59 failed (couldn't enable CRC checking)
  • 3: ACMD41 failed (not possible to initialize, bad card)
  • 4: ACMD41 timed out
  • 5: CMD58 failed (couldn't query card)

When the library is operating in compatibility mode (no bootloader detected), it does not return error code 2, rather tries to enable CRC checking twice and ignore failure. This is used to support the Uzem emulator which doesn't emulate SD CRC.