134 #include "periph_conf.h" 
  150 #ifndef SDMMC_CPU_DMA_REQUIREMENTS 
  151 #define SDMMC_CPU_DMA_REQUIREMENTS 
  162 #define sdmmc_buf_t     SDMMC_CPU_DMA_REQUIREMENTS uint8_t 
  170 #define SDMMC_SDHC_BLOCK_SIZE   (512) 
  180 #define SDMMC_CMD(n)        (n) 
  185 #define SDMMC_ACMD_PREFIX   (1 << 7) 
  190 #define SDMMC_ACMD(n)       (SDMMC_ACMD_PREFIX | SDMMC_CMD(n)) 
  237 #define SDMMC_CMD_NO_ARG        (0x00000000UL) 
  240 #define SDMMC_CMD_ARG_RCA(n)    ((uint32_t)n << 16) 
  243 #define SDMMC_RESP_CRC          (1UL << 4) 
  245 #define SDMMC_RESP_BUSY         (1UL << 5) 
  247 #define SDMMC_RESP_IDX          (0xf) 
  285 #define SDMMC_CMD8_CHECK_PATTERN    (0xaa)           
  286 #define SDMMC_CMD8_VHS_27_36V       (0b0001 << 8)    
  287 #define SDMMC_CMD8_PCIE_AVAIL       (1 << 12)        
  288 #define SDMMC_CMD8_PCIE_12V         (1 << 13)        
  291 #define SDMMC_CMD8_CHECK  (SDMMC_CMD8_VHS_27_36V | SDMMC_CMD8_CHECK_PATTERN) 
  301 #define SDMMC_OCR_18V           (1UL << 7)   
  302 #define SDMMC_OCR_27_28V        (1UL << 15)  
  303 #define SDMMC_OCR_28_29V        (1UL << 16)  
  304 #define SDMMC_OCR_29_30V        (1UL << 17)  
  305 #define SDMMC_OCR_30_31V        (1UL << 18)  
  306 #define SDMMC_OCR_31_32V        (1UL << 19)  
  307 #define SDMMC_OCR_32_33V        (1UL << 20)  
  308 #define SDMMC_OCR_33_34V        (1UL << 21)  
  309 #define SDMMC_OCR_34_35V        (1UL << 22)  
  310 #define SDMMC_OCR_35_36V        (1UL << 23)  
  312 #define SDMMC_OCR_S18A          (1UL << 24)  
  313 #define SDMMC_OCR_OVER_2TB      (1UL << 27)  
  314 #define SDMMC_OCR_UHS_II        (1UL << 29)  
  315 #define SDMMC_OCR_CCS           (1UL << 30)  
  316 #define SDMMC_OCR_POWER_UP      (1UL << 31)  
  325 #define SDMMC_OCR_ALL_VOLTAGES  (SDMMC_OCR_27_28V | SDMMC_OCR_28_29V | \ 
  326                                  SDMMC_OCR_29_30V | SDMMC_OCR_30_31V | \ 
  327                                  SDMMC_OCR_31_32V | SDMMC_OCR_32_33V | \ 
  328                                  SDMMC_OCR_33_34V | SDMMC_OCR_34_35V | \ 
  355 #define SDMMC_CARD_TYPE_SD  (SDMMC_CARD_TYPE_SDSC_V1 | \ 
  356                              SDMMC_CARD_TYPE_SDSC_V2_V3 | \ 
  357                              SDMMC_CARD_TYPE_SDHC_SDXC) 
  408 #define SDMMC_CARD_STATUS_OUT_OF_RANGE          (1UL << 31)      
  409 #define SDMMC_CARD_STATUS_ADDRESS_ERROR         (1UL << 30)      
  410 #define SDMMC_CARD_STATUS_BLOCK_LEN_ERROR       (1UL << 29)      
  411 #define SDMMC_CARD_STATUS_ERASE_SEQ_ERROR       (1UL << 28)      
  412 #define SDMMC_CARD_STATUS_ERASE_PARAM           (1UL << 27)      
  413 #define SDMMC_CARD_STATUS_WP_VIOLATION          (1UL << 26)      
  414 #define SDMMC_CARD_STATUS_CARD_IS_LOCKED        (1UL << 25)      
  415 #define SDMMC_CARD_STATUS_LOCK_UNLOCK_FAILED    (1UL << 24)      
  416 #define SDMMC_CARD_STATUS_COM_CRC_ERROR         (1UL << 23)      
  417 #define SDMMC_CARD_STATUS_ILLEGAL_COMMAND       (1UL << 22)      
  418 #define SDMMC_CARD_STATUS_CARD_ECC_FAILED       (1UL << 21)      
  419 #define SDMMC_CARD_STATUS_CC_ERROR              (1UL << 20)      
  420 #define SDMMC_CARD_STATUS_ERROR                 (1UL << 19)      
  421 #define SDMMC_CARD_STATUS_UNDERRUN              (1UL << 18)      
  422 #define SDMMC_CARD_STATUS_OVERRUN               (1UL << 17)      
  423 #define SDMMC_CARD_STATUS_CSD_OVERWRITE         (1UL << 16)      
  424 #define SDMMC_CARD_STATUS_WP_ERASE_SKIP         (1UL << 15)      
  425 #define SDMMC_CARD_STATUS_CARD_ECC_DISABLED     (1UL << 14)      
  426 #define SDMMC_CARD_STATUS_ERASE_RESET           (1UL << 13)      
  427 #define SDMMC_CARD_STATUS_READY_FOR_DATA        (1UL << 8)       
  428 #define SDMMC_CARD_STATUS_SWITCH_ERROR          (1UL << 7)       
  429 #define SDMMC_CARD_STATUS_FX_EVENT              (1UL << 6)       
  430 #define SDMMC_CARD_STATUS_APP_CMD               (1UL << 5)       
  431 #define SDMMC_CARD_STATUS_AKE_SEQ_ERROR         (1UL << 3)       
  434 #define SDMMC_CARD_STATUS_ERRORS   (SDMMC_CARD_STATUS_OUT_OF_RANGE | \ 
  435                                     SDMMC_CARD_STATUS_ADDRESS_ERROR | \ 
  436                                     SDMMC_CARD_STATUS_BLOCK_LEN_ERROR | \ 
  437                                     SDMMC_CARD_STATUS_ERASE_SEQ_ERROR | \ 
  438                                     SDMMC_CARD_STATUS_ERASE_PARAM | \ 
  439                                     SDMMC_CARD_STATUS_WP_VIOLATION | \ 
  440                                     SDMMC_CARD_STATUS_LOCK_UNLOCK_FAILED | \ 
  441                                     SDMMC_CARD_STATUS_COM_CRC_ERROR | \ 
  442                                     SDMMC_CARD_STATUS_ILLEGAL_COMMAND | \ 
  443                                     SDMMC_CARD_STATUS_CARD_ECC_FAILED | \ 
  444                                     SDMMC_CARD_STATUS_CC_ERROR | \ 
  445                                     SDMMC_CARD_STATUS_ERROR | \ 
  446                                     SDMMC_CARD_STATUS_UNDERRUN | \ 
  447                                     SDMMC_CARD_STATUS_OVERRUN | \ 
  448                                     SDMMC_CARD_STATUS_CSD_OVERWRITE | \ 
  449                                     SDMMC_CARD_STATUS_WP_ERASE_SKIP | \ 
  450                                     SDMMC_CARD_STATUS_SWITCH_ERROR | \ 
  451                                     SDMMC_CARD_STATUS_AKE_SEQ_ERROR) 
  454 #define SDMMC_CARD_STATUS_CURRENT_STATE(n)  (((n) >> SDMMC_CARD_STATUS_CURRENT_STATE_Pos) & 0x0f) 
  455 #define SDMMC_CARD_STATUS_CURRENT_STATE_Pos (9)  
  518 #define SDMMC_SD_STATUS_SIZE    (64) 
  532 typedef struct __attribute__((packed)) {
 
  558 #define SDMMC_CID_REG_SIZE      (16) 
  560 #define SDMMC_CID_OID_SIZE_SD   (2)    
  561 #define SDMMC_CID_PNM_SIZE_SD   (5)    
  562 #define SDMMC_CID_PNM_SIZE_MMC  (6)    
  570 typedef struct __attribute__((packed)) {
 
  587 typedef struct __attribute__((packed)) {
 
  629 #define SDMMC_CSD_REG_SIZE  (16) 
  637 typedef struct __attribute__((packed)) {
 
  686 typedef struct __attribute__((packed)) {
 
  726 typedef struct __attribute__((packed)) {
 
  775 #define SDMMC_EXT_CSD_REG_SIZE  (512) 
  806 #define SDMMC_SCR_REG_SIZE          (8) 
  836 #define SDMMC_SCR_ACMD_53_54_SUPPORT    (0b10000)    
  838 #define SDMMC_SCR_ACMD_58_59_SUPPORT    (0b01000)    
  840 #define SDMMC_SCR_ACMD_48_49_SUPPORT    (0b00100)    
  842 #define SDMMC_SCR_ACMD_23_SUPPORT       (0b00010)    
  844 #define SDMMC_SCR_ACMD_20_SUPPORT       (0b00001)    
  865 #define SDMMC_SCR_SD_SPEC(scr)  \ 
  866     (scr.SD_SPEC + scr.SD_SPEC3 + (scr.SD_SPECX ? scr.SD_SPECX + 1 : scr.SD_SPEC4)) 
  874 #define SDMMC_DEV(x)          (sdmmc_get_dev(x)) 
  917     SDMMC_AUTO_CMD_NONE = 0x00,
 
  918     SDMMC_AUTO_CMD12 = 0x01,
 
  919     SDMMC_AUTO_CMD23 = 0x02,
 
  920     SDMMC_AUTO_CMD_BOTH = 0x03,
 
  927     SDMMC_EVENT_CARD_INSERTED,
 
  928     SDMMC_EVENT_CARD_REMOVED,
 
 1138 #if !IS_USED(MODULE_PERIPH_SDMMC_AUTO_CLK) || DOXYGEN 
 1226                         const void *data_wr, 
void *data_rd,
 
 1312 #if IS_USED(MODULE_SDMMC_MMC) 
 1439 #define SDMMC_NUMOF   XFA_LEN(sdmmc_dev_t *, sdmmc_devs) 
 1750                uint16_t block_size, uint16_t block_num,
 
 1751                const void *data_wr, 
void *data_rd, uint16_t *done);
 
 1807                       uint32_t block_addr, uint16_t block_size,
 
 1808                       uint16_t block_num, 
void *data, uint16_t *done);
 
 1864                        uint16_t block_size, uint16_t block_num,
 
 1865                        const void *data, uint16_t *done);
 
 1901                        uint32_t block_addr, uint16_t block_num);
 
POSIX.1-2008 compliant version of the assert macro.
 
#define assert(cond)
abort the program if assertion is false
 
Functions to work with different byte orders.
 
sdmmc_cmd_t
SDIO/SD/MMC Commands.
 
sdmmc_xfer_type_t
Data transfer types.
 
sdmmc_auto_cmd_t
Auto Command features supported by the SDIO/SD/MMC peripheral.
 
int sdmmc_read_blocks(sdmmc_dev_t *dev, uint32_t block_addr, uint16_t block_size, uint16_t block_num, void *data, uint16_t *done)
Read a number of blocks.
 
int sdmmc_xfer(sdmmc_dev_t *dev, sdmmc_cmd_t cmd_idx, uint32_t arg, uint16_t block_size, uint16_t block_num, const void *data_wr, void *data_rd, uint16_t *done)
Perform a data transfer with the selected card or embedded device.
 
struct sdmmc_dev sdmmc_dev_t
sdmmc_dev_t forward declaration
 
#define SDMMC_CID_OID_SIZE_SD
OID (OEM/Application ID) size in byte (SD)
 
sdmmc_resp_t
SDIO/SD/MMC Response types.
 
static void sdmmc_init(sdmmc_dev_t *dev)
Basic initialization of the given SDIO/SD/MMC device.
 
int sdmmc_erase_blocks(sdmmc_dev_t *dev, uint32_t block_addr, uint16_t block_num)
Erase a number of blocks.
 
#define SDMMC_CMD(n)
Command index.
 
sdmmc_dev_t sdmmc_devs[]
SDIO/SD/MMC device descriptor references as read-only XFA.
 
#define SDMMC_ACMD(n)
Application specific command index.
 
sdmmc_clock_rate_t
SDIO/SD/MMC Card clock rate types.
 
#define SDMMC_RESP_BUSY
Mask to check whether the response includes busy status from card.
 
int sdmmc_read_sds(sdmmc_dev_t *dev, sdmmc_sd_status_t *sds)
Read SD Status Register.
 
sdmmc_card_type_t
SDIO/SD/MMC Card types.
 
int sdmmc_card_init(sdmmc_dev_t *dev)
Card Initialization and Identification.
 
void(* sdmmc_event_cb_t)(sdmmc_dev_t *dev, sdmmc_event_t event)
Event callback function type.
 
#define SDMMC_NUMOF
Number of SDIO/SD/MMC devices defined.
 
#define SDMMC_CID_PNM_SIZE_MMC
PNM (Product name) size in byte (MMC)
 
uint64_t sdmmc_get_capacity(sdmmc_dev_t *dev)
Get Capacity of SD/MMC Card.
 
int sdmmc_send_acmd(sdmmc_dev_t *dev, sdmmc_cmd_t cmd_idx, uint32_t arg, sdmmc_resp_t resp_type, uint32_t *resp)
Send application specific command optionally wait for response.
 
int sdmmc_write_blocks(sdmmc_dev_t *dev, uint32_t block_addr, uint16_t block_size, uint16_t block_num, const void *data, uint16_t *done)
Write a number of blocks.
 
#define SDMMC_RESP_CRC
Mask to check whether the response type uses CRC7.
 
sdmmc_csd_version_t
CSD Register Versions (SD Memory Card and MMC)
 
sdmmc_event_t
Events generated by SDIO/SD/MMC high level API.
 
static sdmmc_dev_t * sdmmc_get_dev(unsigned num)
Retrieve SDIO/SD/MMC device descriptor reference from device index.
 
#define SDMMC_CID_PNM_SIZE_SD
PNM (Product name) size in byte (SD)
 
int sdmmc_send_cmd(sdmmc_dev_t *dev, sdmmc_cmd_t cmd_idx, uint32_t arg, sdmmc_resp_t resp_type, uint32_t *resp)
Send command to SDIO/SD/MMC Card and optionally wait for response.
 
sdmmc_bus_width_t
SDIO/SD/MMC Card data bus widths.
 
@ SDMMC_CMD5
SD_APP_OP_COND (SDIO only)
 
@ SDMMC_CMD58
READ_OCR (SPI mode only)
 
@ SDMMC_CMD16
SET_BLOCKLEN.
 
@ SDMMC_CMD33
ERASE_WR_BLK_END.
 
@ SDMMC_CMD25
WRITE_MULTIPLE_BLOCK.
 
@ SDMMC_ACMD41
SD_APP_OP_COND.
 
@ SDMMC_CMD7
SELECT/DESELECT_CARD.
 
@ SDMMC_CMD32
ERASE_WR_BLK_START.
 
@ SDMMC_CMD17
READ_SINGLE_BLOCK.
 
@ SDMMC_CMD8
SEND_IF_COND (SD), SEND_EXT_CSD (MMC)
 
@ SDMMC_CMD24
WRITE_BLOCK.
 
@ SDMMC_CMD59
CRC_ON_OFF (SPI mode only)
 
@ SDMMC_CMD13
SEND_STATUS.
 
@ SDMMC_CMD3
SET_RELATIVE_ADDR.
 
@ SDMMC_CMD52
IO_RW_DIRECT (SDIO only)
 
@ SDMMC_CMD53
IO_RW_EXTENDED (SDIO only)
 
@ SDMMC_ACMD23
SET_WR_BLK_ERASE_COUNT.
 
@ SDMMC_CMD12
STOP_TRANSMISSION.
 
@ SDMMC_CMD23
SET_BLOCK_COUNT.
 
@ SDMMC_ACMD6
SET_BUS_WIDTH.
 
@ SDMMC_CMD2
ALL_SEND_CID.
 
@ SDMMC_CMD18
READ_MULTIPLE_BLOCK.
 
@ SDMMC_CMD1
SEND_OP_COND.
 
@ SDMMC_CMD0
GO_IDLE_STATE.
 
@ SDMMC_BLOCK
Transfer block with size of READ_BL_LEN/WRITE_BL_LEN.
 
@ SDMMC_MULTIBYTE
Transfer 1 to READ_BL_LEN/WRITE_BL_LEN bytes.
 
@ SDMMC_STREAM
Transfer until CMD12 is sent (MMC and 1-bit bus only)
 
@ SDMMC_CARD_STATE_IDLE
Idle.
 
@ SDMMC_CARD_STATE_READY
Ready.
 
@ SDMMC_CARD_STATE_DATA
Data.
 
@ SDMMC_CARD_STATE_RCV
Receive.
 
@ SDMMC_CARD_STATE_PRG
Programming.
 
@ SDMMC_CARD_STATE_BTST
Bus Test.
 
@ SDMMC_CARD_STATE_TRAN
Transfer.
 
@ SDMMC_CARD_STATE_IDENT
Identification.
 
@ SDMMC_CARD_STATE_DIS
Disconnect.
 
@ SDMMC_CARD_STATE_STBY
Stand-by.
 
@ SDMMC_R4
Fast I/O [48 bit (16 bit RCA, 1 bit status, 7 bit addr, 8 bit reg)].
 
@ SDMMC_R3
OCR Resister [48 bit (32 bit OCR)].
 
@ SDMMC_NO_R
No response expected.
 
@ SDMMC_R1
Normal Response [48 bit (32 bit card status)].
 
@ SDMMC_R6
Published RCA Response [48 bit (16 bit RCA, 16 bit card status)
 
@ SDMMC_R1B
Normal Response [48 bit (R1 with optional busy signal on DAT0)].
 
@ SDMMC_R7
Card Interface Condition [48 bit (32 bit data)], see section 4.9.6)
 
@ SDMMC_R2
CID/CSD [136 bit (128 bit CID or CSD)].
 
@ SDMMC_R5
Interrupt Request [48 bit (16 bit RCA, 16 bit not defined)
 
@ SDMMC_CLK_20M
MMC Card in Data Transfer Mode (Backward Compatibility)
 
@ SDMMC_CLK_400K
Identification Mode f_OD (400 kHz)
 
@ SDMMC_CLK_52M
MMC/eMMC in Data Transfer Mode (High Speed)
 
@ SDMMC_CLK_26M
MMC/eMMC Card in Data Transfer Mode (Default Speed)
 
@ SDMMC_CLK_25M
SD/SDIO Card in Data Transfer Mode (Default Speed)
 
@ SDMMC_CLK_50M
SD/SDIO Card in Data Transfer Mode (High Speed)
 
@ SDMMC_CARD_TYPE_SDSC_V2_V3
SD Memory Card Standard Capacity (SDSC) Version 2.x+.
 
@ SDMMC_CARD_TYPE_MMC
MultiMedia Card.
 
@ SDMMC_CARD_TYPE_SDIO
SDIO Card.
 
@ SDMMC_CARD_TYPE_SDHC_SDXC
SD Memory Card High or Extended Capacity (SDHC/SDXC)
 
@ SDMMC_CARD_TYPE_SDSC_V1
SD Memory Card Standard Capacity (SDSC) Version 1.x.
 
@ SDMMC_CARD_TYPE_UNKNOWN
Card type unknown.
 
@ SDMMC_CSD_V1
CSD Version 1.0 (SDSC and MMC)
 
@ SDMMC_CSD_V3
CSD Version 3.0 (SDUC) or Version 1.2 (MMC)
 
@ SDMMC_CSD_V2
CSD Version 2.0 (SDHC/SDXC) or Version 1.1 (MMC)
 
@ SDMMC_CSD_Vx
Reserved (SD) or Version in EXT_CSD (MMC)
 
@ SDMMC_BUS_WIDTH_1BIT
Data bus width is 1 bit (default)
 
@ SDMMC_BUS_WIDTH_4BIT
Data bus width is 4 bit.
 
@ SDMMC_BUS_WIDTH_8BIT
Data bus width is 8 bit.
 
CID register structure (MMC)
 
be_uint32_t PSN
Product serial number in big-endian order.
 
uint8_t MDT
Manufacturing date.
 
be_uint16_t OID
OEM/Application ID in big-endian order.
 
uint8_t PRV
Product revision.
 
uint8_t CID_CRC
CRC7 checksum including bit 0.
 
uint8_t MID
Manufacturer ID.
 
CID register structure (SD Memory Cards)
 
be_uint32_t PSN
Product serial number in big-endian order.
 
uint8_t CID_CRC
CRC7 checksum including bit 0.
 
uint8_t MID
Manufacturer ID.
 
uint8_t PRV
Product revision.
 
be_uint16_t MDT
Manufacturing date in big-endian order.
 
CSD register structure for MMC.
 
uint32_t R2W_FACTOR
Write speed factor [28:26].
 
uint32_t reserved4
reserved [20:17]
 
uint32_t WP_GRP_SIZE
Write protect group size [36:32].
 
uint32_t TMP_WRITE_PROTECT
Temporary write protection [12].
 
uint32_t DEFAULT_ECC
Manufacturer default ECC [30:29].
 
uint32_t CSD_STRUCTURE
CSD structure [127:126].
 
uint32_t CONTENT_PROT_APP
Content protection application [16].
 
uint32_t WRITE_BL_LEN
Max.
 
uint32_t VDD_W_CURR_MIN
Max.
 
uint32_t FILE_FORMAT
File format [11:10].
 
uint32_t DSR_IMP
DSR implemented [76].
 
uint32_t WP_GRP_ENABLE
write protect group enable [31]
 
uint32_t reserved2
reserved [75:74]
 
uint32_t NSAC
Data read access-time-2 in CLK cycles [111:104].
 
uint32_t VDD_R_CURR_MAX
Max.
 
uint32_t CCC
Card command classes [95:84].
 
uint32_t WRITE_BL_PARTIAL
partial blocks for write allowed [21]
 
uint32_t reserved1
reserved [121:120]
 
uint32_t FILE_FORMAT_GRP
File format group [15].
 
uint32_t ERASE_GRP_MULT
Erase group size multiplier [41:37].
 
uint32_t TAAC
Data read access-time-1 [119:112].
 
uint32_t WRITE_BLK_MISALIGN
Write block misalignment [78].
 
uint32_t CSD_CRC
CRC including End bit 1b [7:0].
 
uint32_t COPY
Copy flag [14].
 
uint32_t SPEC_VERS
Specification version [125:122].
 
uint32_t ERASE_GRP_SIZE
Erase group size [46:42].
 
uint16_t C_SIZE
Device size [73:62].
 
uint32_t VDD_W_CURR_MAX
Max.
 
uint32_t VDD_R_CURR_MIN
Max.
 
uint32_t PERM_WRITE_PROTECT
Permanent write protection [13].
 
uint32_t ECC
ECC code [9:8].
 
uint32_t READ_BLK_MISALIGN
Read block misalignment [77].
 
uint32_t C_SIZE_MULT
Device size multiplier [49:47].
 
uint32_t READ_BL_PARTIAL
Partial blocks for read allowed [79].
 
CSD register structure Version 1.0.
 
uint32_t WRITE_BL_LEN
max.
 
uint32_t FILE_FORMAT_GRP
File format group [15].
 
uint32_t READ_BL_PARTIAL
partial blocks for read allowed [79]
 
uint32_t PERM_WRITE_PROTECT
permanent write protection [13]
 
uint32_t VDD_R_CURR_MIN
max.
 
uint32_t TMP_WRITE_PROTECT
temporary write protection [12]
 
uint32_t WP_GRP_SIZE
write protect group size [38:32]
 
uint32_t R2W_FACTOR
write speed factor [28:26]
 
uint32_t reserved2
reserved [75:74]
 
uint32_t FILE_FORMAT
File format [11:10].
 
uint32_t CSD_CRC
CRC including End bit 1b [7:0].
 
uint32_t VDD_W_CURR_MAX
max.
 
uint32_t TAAC
data read access-time-1 [119:112]
 
uint32_t C_SIZE
device size [73:62]
 
uint32_t WRITE_BL_PARTIAL
partial blocks for write allowed [21]
 
uint32_t SECTOR_SIZE
erase sector size [45:39]
 
uint32_t READ_BLK_MISALIGN
read block misalignment [77]
 
uint32_t DSR_IMP
DSR implemented [76].
 
uint32_t VDD_R_CURR_MAX
max.
 
uint32_t WP_GRP_ENABLE
write protect group enable [31]
 
uint32_t CSD_STRUCTURE
CSD structure [127:126].
 
uint32_t reserved4
reserved [20:16]
 
uint32_t reserved3
reserved [30:29]
 
uint32_t reserved1
reserved [125:120]
 
uint32_t NSAC
data read access-time-2 in CLK cycles [111:104]
 
uint32_t WP_UPC
write protection until power cycle [9]
 
uint32_t WRITE_BLK_MISALIGN
write block misalignment [78]
 
uint32_t VDD_W_CURR_MIN
max.
 
uint32_t COPY
copy flag [14]
 
uint32_t ERASE_BLK_EN
erase single block enable [46]
 
uint32_t reserved5
reserved [8]
 
uint32_t C_SIZE_MULT
device size multiplier [49:47]
 
uint32_t CCC
card command classes [95:84]
 
CSD register structure Version 2.0 and Version 3.0.
 
uint32_t WRITE_BL_LEN
max.
 
uint32_t reserved2
reserved [47]
 
uint32_t WP_GRP_ENABLE
write protect group enable [31]
 
uint32_t SECTOR_SIZE
erase sector size [45:39]
 
uint32_t TMP_WRITE_PROTECT
temporary write protection [12]
 
uint32_t FILE_FORMAT_GRP
File format group [15].
 
uint32_t reserved4
reserved [20:16]
 
uint32_t READ_BLK_MISALIGN
read block misalignment [77]
 
uint32_t PERM_WRITE_PROTECT
permanent write protection [13]
 
uint32_t WP_UPC
write protection until power cycle [9]
 
uint32_t TAAC
data read access-time-1 [119:112]
 
uint32_t DSR_IMP
DSR implemented [76].
 
uint32_t ERASE_BLK_EN
erase single block enable [46]
 
uint32_t CCC
card command classes [95:84]
 
uint32_t WRITE_BL_PARTIAL
partial blocks for write allowed [21]
 
uint32_t FILE_FORMAT
File format [11:10].
 
uint32_t CSD_CRC
CRC including End bit 1b [7:0].
 
uint32_t CSD_STRUCTURE
CSD structure [127:126].
 
uint32_t reserved3
reserved [30:29]
 
uint32_t reserved5
reserved [8]
 
uint32_t reserved1
reserved [125:120]
 
uint32_t WP_GRP_SIZE
write protect group size [38:32]
 
uint32_t COPY
copy flag [14]
 
uint32_t C_SIZE
device size v2.0 [69:48], v3.0 [75:48]
 
uint32_t WRITE_BLK_MISALIGN
write block misalignment [78]
 
uint32_t NSAC
data read access-time-2 in CLK cycles [111:104]
 
uint32_t READ_BL_PARTIAL
partial blocks for read allowed [79]
 
uint32_t R2W_FACTOR
write speed factor [28:26]
 
SDIO/SD/MMC device descriptor.
 
bool init_done
Indicates whether the card is initialized (default false).
 
uint16_t rca
Relative Card Address (RCA) of the SDIO/SD/MMC Card as determined during the initialization and ident...
 
sdmmc_scr_t scr
SCR register of the SD Card, read during the initialization and identification procedure in the sdmmc...
 
sdmmc_cid_t cid
CID register of the SD/MMC Card, read during the initialization and identification procedure in the s...
 
bool s18v_allowed
Indicates whether the card supports the switching to 1.8V (default false).
 
bool spi_mode
Indicates whether SPI mode is used by the SDIO/SD/MMC device (default false).
 
uint32_t status
Last SDIO/SD/MMC Card status reported in R1 response.
 
sdmmc_card_type_t type
Type of the SDIO/SD/MMC Card as identified during the initialization and identification procedure in ...
 
const sdmmc_driver_t * driver
Low-level SDIO/SD/MMC peripheral driver.
 
sdmmc_event_cb_t event_cb
The application can register an event callback function of type sdmmc_event_cb_t which is called when...
 
sdmmc_csd_t csd
CSD register of the SD/MMC Card, read during the initialization and identification procedure in the s...
 
sdmmc_bus_width_t bus_width
Data bus width supported by the SDIO/SD/MMC device (default SDMMC_BUS_WIDTH_1BIT).
 
bool present
Indicates whether a card is present.
 
bool s18v_support
Indicates whether the SDIO/SD/MMC peripheral supports the switching to 1.8V (default false).
 
Low-level SDIO/SD/MMC peripheral driver.
 
void(* init)(sdmmc_dev_t *dev)
Basic initialization of the given SDIO/SD/MMC device.
 
Extended CSD (EXT_CSD) register structure (MMC only)
 
uint32_t SEC_COUNT
Sector Count [215:212].
 
uint8_t CSD_STRUCTURE
CSD Structure Version [194].
 
uint8_t CARD_TYPE
Card Type [196].
 
uint8_t BUS_WIDTH
Bus Width Mode [183].
 
SCR register structure (SD Memory Card only)
 
uint32_t reserved0
Reserved for manufacturer usage [31:0].
 
uint32_t SD_BUS_WIDTHS
DAT Bus widths supported [51:48].
 
uint32_t SCR_STRUCTURE
SCR Structure [63:60].
 
uint32_t SD_SECURITY
CPRM Security Support [54:52].
 
uint32_t SD_SPEC
SD Memory Card - Spec.
 
uint32_t DATA_STAT_AFTER_ERASE
Data status after erases [55].
 
uint32_t EX_SECURITY
Extended Security Support [46:43].
 
uint32_t CMD_SUPPORT
Command Support bits [36:32].
 
uint32_t reserved37
Reserved [37].
 
SD Status (SD Memory Card only)
 
uint16_t SD_CARD_TYPE
[495:480] Section 4.10.2, Table 4-44
 
uint8_t AU_SIZE
[431:428] Section 4.10.2.4, Table 4-47
 
uint32_t VSC_AU_SIZE
[377:368] Section 4.10.2.11, Table 4-56
 
uint8_t VIDEO_SPEED_CLASS
[391:384] Section 4.10.2.10, Table 4-54
 
uint32_t SIZE_OF_PROTECTED_AREA
[479:448] Section 4.10.2.1
 
uint8_t ERASE_TIMEOUT
[407:402] Section 4.10.2.6, Table 4-50
 
uint8_t PERFORMANCE_MOVE
[439:432] Section 4.10.2.3, Table 4-46
 
uint8_t ERASE_OFFSET
[401:400] Section 4.10.2.7, Table 4-51
 
uint8_t SECURED_MODE
[509] Section 4.10.2, Table 4-44
 
uint16_t ERASE_SIZE
[423:408] Section 4.10.2.5, Table 4-49
 
uint32_t SUS_ADDR
[367:346] Section 4.10.2.12, Table 4-57
 
uint8_t SPEED_CLASS
[447:440] Section 4.10.2.2, Table 4-45
 
uint8_t DAT_BUS_WIDTH
[511:510] Section 4.10.2, Table 4-44
 
uint8_t UHS_AU_SIZE
[395:392] Section 4.10.2.9, Table 4-3
 
uint8_t UHS_SPEED_GRADE
[399:396] Section 4.10.2.8, Table 4-52
 
sdmmc_xfer_type_t type
Type of the transfer.
 
uint32_t arg
Command argument used for the transfer.
 
uint16_t block_num
Number of blocks to be transferred, 1 for Byte transfer.
 
sdmmc_cmd_t cmd_idx
Command index used for the transfer.
 
uint16_t block_size
Size of a block or number of bytes for Byte transfer.
 
sdmmc_resp_t resp_type
Type of expected response for the transfer.
 
bool write
Indicate a write transfer.
 
A 16 bit integer in big endian aka network byte order.
 
A 32 bit integer in big endian aka network byte order.
 
SD/MMC Card status as structure.
 
uint32_t BLOCK_LEN_ERROR
[29] SD and MMC
 
uint32_t AKE_SEQ_ERROR
[3] SD only, Reserved in MMC
 
uint32_t SWITCH_ERROR
[7] MMC only, reserved in SD/SDIO
 
uint32_t OVERRUN
[17] MMC only, DEFERRED_RESPONSE in SD
 
uint32_t reserved4
[4] Reserved
 
uint32_t ERASE_SEQ_ERROR
[28] SD and MMC
 
uint32_t ILLEGAL_COMMAND
[22] SD/SDIO and MMC
 
uint32_t OUT_OF_RANGE
[31] SD/SDIO and MMC
 
uint32_t reserved2
[2] Reserved for appl.
 
uint32_t CC_ERROR
[20] SD and MMC
 
uint32_t CURRENT_STATE
[12:9] SD and MMC
 
uint32_t UNDERRUN
[18] MMC only, reserved in SD
 
uint32_t ERASE_RESET
[13] SD and MMC
 
uint32_t LOCK_UNLOCK_FAILED
[24] SD and MMC
 
uint32_t CARD_IS_LOCKED
[25] SD and MMC
 
uint32_t READY_FOR_DATA
[8] SD and MMC
 
uint32_t FX_EVENT
[6] SD only, Reserved in MMC
 
uint32_t COM_CRC_ERROR
[23] SD/SDIO and MMC
 
uint32_t ADDRESS_ERROR
[30] SD and MMC
 
uint32_t ERROR
[19] SD/SDIO and MMC
 
uint32_t ERASE_PARAM
[27] SD and MMC
 
uint32_t CARD_ECC_FAILED
[21] SD and MMC
 
uint32_t CSD_OVERWRITE
[16] SD (CSD), MMC (CSD and CID)
 
uint32_t reserved0
[1:0] Reserved for appl.
 
uint32_t WP_ERASE_SKIP
[15] SD and MMC
 
uint32_t WP_VIOLATION
[26] SD and MMC
 
uint32_t APP_CMD
[5] SD and MMC
 
uint32_t value
SD/MMC Card status as 32 bit value.
 
uint32_t CARD_ECC_DISABLED
[14] SD only, reserved in MMC
 
CID register structure (SD Memory and MMC Cards)
 
sdmmc_cid_mmc_t mmc
CID register of MMC.
 
sdmmc_cid_sd_t sd
CID register of SD Memory Cards.
 
CSD register (SD Memory Card and MMC)
 
sdmmc_csd_v1_t v1
CSD Version 1.0.
 
sdmmc_csd_mmc_t mmc
CSD Version for MMC.
 
sdmmc_csd_v2_t v2
CSD Version 2.0 and 3.0.
 
#define MHZ(x)
A macro to return the Hz in x MHz.
 
#define KHZ(x)
A macro to return the Hz in x kHz.
 
#define XFA_USE_CONST(type, name)
Declare an external read-only cross-file array.