sdcard_spi.h File Reference

Public interface for the sdcard_spi driver. More...

Detailed Description

Public interface for the sdcard_spi driver.

Author
Michel Rottleuthner miche.nosp@m.l.ro.nosp@m.ttleu.nosp@m.thne.nosp@m.r@haw.nosp@m.-ham.nosp@m.burg..nosp@m.de

Definition in file sdcard_spi.h.

#include "periph/spi.h"
#include "periph/gpio.h"
#include "stdbool.h"
+ Include dependency graph for sdcard_spi.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  cid_t
 CID register see section 5.2 in SD-Spec v5.00. More...
 
struct  csd_v1_t
 CSD register with csd structure version 1.0 see section 5.3.2 in SD-Spec v5.00. More...
 
struct  csd_v2_t
 CSD register with csd structure version 2.0 see section 5.3.3 in SD-Spec v5.00. More...
 
union  csd_t
 CSD register (see section 5.3 in SD-Spec v5.00) More...
 
struct  sd_status_t
 SD status register (see section 4.10.2 in SD-Spec v5.00) More...
 
struct  sdcard_spi_params_t
 sdcard_spi device params More...
 
struct  sdcard_spi_t
 Device descriptor for sdcard_spi. More...
 

Macros

#define SD_HC_BLOCK_SIZE   (512)
 size of a single block on SDHC cards
 
#define SDCARD_SPI_INIT_ERROR   (-1)
 returned on failed init
 
#define SDCARD_SPI_OK   (0)
 returned on successful init
 
#define SD_SIZE_OF_OID   2
 OID (OEM/application ID field in CID reg)
 
#define SD_SIZE_OF_PNM   5
 PNM (product name field in CID reg)
 

Enumerations

enum  sd_version_t { SD_V2, SD_V1, MMC_V3, SD_UNKNOWN }
 version type of SD-card More...
 
enum  sd_rw_response_t {
  SD_RW_OK = 0, SD_RW_NO_TOKEN, SD_RW_TIMEOUT, SD_RW_RX_TX_ERROR,
  SD_RW_WRITE_ERROR, SD_RW_CRC_MISMATCH, SD_RW_NOT_SUPPORTED
}
 sdcard_spi r/w-operation return values More...
 

Functions

int sdcard_spi_init (sdcard_spi_t *card, const sdcard_spi_params_t *params)
 Initializes the sd-card with the given parameters in sdcard_spi_t structure. More...
 
int sdcard_spi_read_blocks (sdcard_spi_t *card, int blockaddr, uint8_t *data, int blocksize, int nblocks, sd_rw_response_t *state)
 Reads data blocks (usually multiples of 512 Bytes) from card to buffer. More...
 
int sdcard_spi_write_blocks (sdcard_spi_t *card, int blockaddr, const uint8_t *data, int blocksize, int nblocks, sd_rw_response_t *state)
 Writes data blocks (usually multiples of 512 Bytes) from buffer to card. More...
 
uint64_t sdcard_spi_get_capacity (sdcard_spi_t *card)
 Gets the capacity of the card. More...