Go to the documentation of this file.
32 #define SD_HC_BLOCK_SIZE (512)
33 #define SDCARD_SPI_INIT_ERROR (-1)
34 #define SDCARD_SPI_OK (0)
36 #define SD_SIZE_OF_OID 2
37 #define SD_SIZE_OF_PNM 5
uint8_t TRAN_SPEED
see section 5.3.2 in SD-Spec v5.00
uint8_t WRITE_BL_LEN
see section 5.3.3 in SD-Spec v5.00
uint8_t VDD_R_CURR_MIN
see section 5.3.2 in SD-Spec v5.00
uint16_t ERASE_SIZE
see section 4.10.2.5 in SD-Spec v5.00
uint8_t C_SIZE_MULT
see section 5.3.2 in SD-Spec v5.00
uint8_t UHS_AU_SIZE
see section 4.10.2.9 in SD-Spec v5.00
uint8_t FILE_FORMAT_GRP
see section 5.3.3 in SD-Spec v5.00
uint8_t MID
Manufacturer ID.
@ SD_RW_TIMEOUT
cmd timed out (not-busy-state wasn't entered)
uint8_t AU_SIZE
see section 4.10.2.4 in SD-Spec v5.00
uint8_t DSR_IMP
see section 5.3.2 in SD-Spec v5.00
uint8_t COPY
see section 5.3.3 in SD-Spec v5.00
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.
uint8_t WRITE_BLK_MISALIGN
see section 5.3.2 in SD-Spec v5.00
uint8_t NSAC
see section 5.3.3 in SD-Spec v5.00
uint32_t SUS_ADDR
see section 4.10.2.12 in SD-Spec v5.00
int csd_structure
version of the CSD register structure
gpio_t miso
pin connected to the DAT0 sd pad
sdcard_spi_params_t params
parameters for pin and spi config
uint8_t READ_BL_LEN
see section 5.3.2 in SD-Spec v5.00
Low-level SPI peripheral driver interface definition.
uint8_t UHS_SPEED_GRADE
see section 4.10.2.8 in SD-Spec v5.00
spi_clk_t spi_clk
active SPI clock speed
@ SD_RW_WRITE_ERROR
data-packet response indicates error
csd_v1_t v1
see section 5.3.2 in SD-Spec v5.00
uint8_t CSD_CRC
see section 5.3.2 in SD-Spec v5.00
spi_t spi_dev
SPI bus used.
uint16_t CCC
see section 5.3.2 in SD-Spec v5.00
uint8_t VIDEO_SPEED_CLASS
see section 4.10.2.10 in SD-Spec v5.00
uint8_t FILE_FORMAT
see section 5.3.3 in SD-Spec v5.00
uint8_t DSR_IMP
see section 5.3.3 in SD-Spec v5.00
uint16_t CCC
see section 5.3.3 in SD-Spec v5.00
uint8_t ERASE_BLK_EN
see section 5.3.2 in SD-Spec v5.00
uint8_t CID_CRC
CRC7 checksum.
uint16_t SD_CARD_TYPE
see section 4.10.2 in SD-Spec v5.00
CSD register with csd structure version 1.0 see section 5.3.2 in SD-Spec v5.00.
uint8_t CSD_STRUCTURE
see section 5.3.3 in SD-Spec v5.00
uint8_t ERASE_TIMEOUT
see section 4.10.2.6 in SD-Spec v5.00
uint8_t CSD_STRUCTURE
see section 5.3.2 in SD-Spec v5.00
uint32_t C_SIZE
see section 5.3.3 in SD-Spec v5.00
gpio_t clk
pin connected to the CLK sd pad
uint8_t NSAC
see section 5.3.2 in SD-Spec v5.00
uint8_t READ_BLK_MISALIGN
see section 5.3.2 in SD-Spec v5.00
uint8_t FILE_FORMAT
see section 5.3.2 in SD-Spec v5.00
SD status register (see section 4.10.2 in SD-Spec v5.00)
uint8_t WP_GRP_SIZE
see section 5.3.2 in SD-Spec v5.00
uint16_t MDT
Manufacturing date.
uint8_t SPEED_CLASS
see section 4.10.2.2 in SD-Spec v5.00
uint64_t sdcard_spi_get_capacity(sdcard_spi_t *card)
Gets the capacity of the card.
sd_rw_response_t
sdcard_spi r/w-operation return values
csd_v2_t v2
see section 5.3.3 in SD-Spec v5.00
spi_clk_t
Available SPI clock speeds.
gpio_t cs
pin connected to the DAT3 sd pad
uint8_t PRV
Product revision.
uint8_t SECURED_MODE
see section 4.10.2 in SD-Spec v5.00
uint8_t TMP_WRITE_PROTECT
see section 5.3.2 in SD-Spec v5.00
#define SD_SIZE_OF_PNM
PNM (product name field in CID reg)
uint8_t ERASE_BLK_EN
see section 5.3.3 in SD-Spec v5.00
uint8_t PERFORMANCE_MOVE
see section 4.10.2.3 in SD-Spec v5.00
@ SD_UNKNOWN
SD-version unknown.
uint32_t PSN
Product serial number.
CSD register (see section 5.3 in SD-Spec v5.00)
@ SD_RW_RX_TX_ERROR
error while performing SPI read/write
uint8_t SECTOR_SIZE
see section 5.3.3 in SD-Spec v5.00
uint8_t ERASE_OFFSET
see section 4.10.2.7 in SD-Spec v5.00
uint8_t PERM_WRITE_PROTECT
see section 5.3.3 in SD-Spec v5.00
uint8_t FILE_FORMAT_GRP
see section 5.3.2 in SD-Spec v5.00
uint8_t WRITE_BLK_MISALIGN
see section 5.3.3 in SD-Spec v5.00
uint8_t WRITE_BL_PARTIAL
see section 5.3.2 in SD-Spec v5.00
sd_version_t card_type
version of SD-card
uint8_t WP_GRP_ENABLE
see section 5.3.3 in SD-Spec v5.00
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.
uint32_t SIZE_OF_PROTECTED_AREA
see section 4.10.2 in SD-Spec v5.00
uint8_t SECTOR_SIZE
see section 5.3.2 in SD-Spec v5.00
uint8_t R2W_FACTOR
see section 5.3.3 in SD-Spec v5.00
#define SD_SIZE_OF_OID
OID (OEM/application ID field in CID reg)
uint8_t READ_BLK_MISALIGN
see section 5.3.3 in SD-Spec v5.00
uint8_t TRAN_SPEED
see section 5.3.3 in SD-Spec v5.00
gpio_t mosi
pin connected to the CMD sd pad
uint32_t VSC_AU_SIZE
see section 4.10.2.11 in SD-Spec v5.00
uint16_t C_SIZE
see section 5.3.2 in SD-Spec v5.00
uint8_t DAT_BUS_WIDTH
see section 4.10.2 in SD-Spec v5.00
Low-level GPIO peripheral driver interface definitions.
bool power_act_high
true if card power is enabled by 'power'-pin HIGH
@ SD_RW_NOT_SUPPORTED
operation not supported on used card
bool use_block_addr
true if block addressing (vs.
gpio_t power
pin that controls sd power circuit
uint8_t TAAC
see section 5.3.3 in SD-Spec v5.00
uint8_t VDD_R_CURR_MAX
see section 5.3.2 in SD-Spec v5.00
uint8_t PERM_WRITE_PROTECT
see section 5.3.2 in SD-Spec v5.00
uint8_t R2W_FACTOR
see section 5.3.2 in SD-Spec v5.00
uint8_t COPY
see section 5.3.2 in SD-Spec v5.00
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.
uint8_t VDD_W_CURR_MAX
see section 5.3.2 in SD-Spec v5.00
uint8_t READ_BL_PARTIAL
see section 5.3.2 in SD-Spec v5.00
uint8_t READ_BL_LEN
see section 5.3.3 in SD-Spec v5.00
uint8_t WP_GRP_ENABLE
see section 5.3.2 in SD-Spec v5.00
uint8_t WP_GRP_SIZE
see section 5.3.3 in SD-Spec v5.00
uint8_t CSD_CRC
see section 5.3.3 in SD-Spec v5.00
@ SD_RW_NO_TOKEN
no token was received (on block read)
CID register see section 5.2 in SD-Spec v5.00.
uint8_t READ_BL_PARTIAL
see section 5.3.3 in SD-Spec v5.00
uint8_t WRITE_BL_LEN
see section 5.3.2 in SD-Spec v5.00
uint8_t TMP_WRITE_PROTECT
see section 5.3.3 in SD-Spec v5.00
Device descriptor for sdcard_spi.
uint8_t TAAC
see section 5.3.2 in SD-Spec v5.00
uint8_t WRITE_BL_PARTIAL
see section 5.3.3 in SD-Spec v5.00
sd_version_t
version type of SD-card
unsigned int spi_t
Default type for SPI devices.
bool init_done
set to true once the init procedure completed successfully
uint8_t VDD_W_CURR_MIN
see section 5.3.2 in SD-Spec v5.00
CSD register with csd structure version 2.0 see section 5.3.3 in SD-Spec v5.00.
@ SD_RW_CRC_MISMATCH
CRC-mismatch of received data.