Initializes the sd-card with the given parameters in sdcard_spi_t structure.

The init procedure also takes care of initializing the spi peripheral to master mode and performing all neccecary steps to set the sd-card to spi-mode. Reading the CID and CSD registers is also done within this routine and their values are copied to the given sdcard_spi_t struct.

Parameters

[out]

card

the device descriptor

[in]

params

parameters for this device (pins and spi device are initialized by this driver)

Start adress to read from. Independet of the actual adressing scheme of the used card the adress needs to be given as block address (e.g. 0, 1, 2... NOT: 0, 512... ). The driver takes care of mapping to byte adressing if needed.

[out]

data

Buffer to store the read data in. The user is responsible for providing a suitable buffer size.

[in]

blocksize

Size of data blocks. For now only 512 byte blocks are supported because only older (SDSC) cards support variable blocksizes anyway. With SDHC/SDXC-cards this is always fixed to 512 bytes. SDSC cards are automatically forced to use 512 byte as blocksize by the init procedure.

[in]

nblocks

Number of blocks to read

[out]

state

Contains information about the error state if something went wrong (if return value is lower than nblocks).

Start adress to read from. Independet of the actual adressing scheme of the used card the adress needs to be given as block address (e.g. 0, 1, 2... NOT: 0, 512... ). The driver takes care of mapping to byte adressing if needed.

[out]

data

Buffer that contains the data to be sent.

[in]

blocksize

Size of data blocks. For now only 512 byte blocks are supported because only older (SDSC) cards support variable blocksizes anyway. With SDHC/SDXC-cards this is always fixed to 512 bytes. SDSC cards are automatically forced to use 512 byte as blocksize by the init procedure.

[in]

nblocks

Number of blocks to write

[out]

state

Contains information about the error state if something went wrong (if return value is lower than nblocks).