![]() |
Modules | |
SD/MMC Spec. definitions | |
SDIO APIs | |
SD/MMC Lib Commands Definitions | |
SD/MMC Status register constants | |
SDIO Status definitions | |
Defines | |
#define | CARD_ADDR(pSd) (pSd->wAddress) |
#define | BLOCK_SIZE(pSd) (pSd->wCurrBlockLen) |
#define | SD_ADDRESS(pSd, address) |
#define | MMC_ADDRESS(pSd, address) |
#define | SD_IsVer1_10(pSd) ( SD_SCR_SD_SPEC(pSd->SCR) >= SD_SCR_SD_SPEC_1_10 ) |
#define | SD_IsHsModeSupported(pSd) ( /*SD_IsVer1_10(pSd)||*/(SD_CSD_STRUCTURE(pSd->CSD)>=1) ) |
#define | SD_IsBusModeSupported(pSd) (1) |
#define | MMC_IsVer4(pSd) ( MMC_CSD_SPEC_VERS(pSd->CSD) >= 4 ) |
#define | MMC_IsCSDVer1_2(pSd) |
#define | MMC_IsBootModeSupported(pSd) ( (MMC_IsVer4(pSd)&&(eMMC_CID_CBX(pSd->CID)==0x01) ) |
#define | MMC_IsBusModeSupported(pSd) (MMC_IsVer4(pSd)) |
#define | MMC_IsHsModeSupported(pSd) (MMC_IsCSDVer1_2(pSd)&&(MMC_EXT_CARD_TYPE(pSd->EXT)&0x2)) |
Functions | |
uint8_t | SD_Init (sSdCard *pSd) |
void | SD_DeInit (sSdCard *pSd) |
uint8_t | SD_SetupBusMode (sSdCard *pSd, uint8_t bMode) |
uint8_t | SD_SetupHSMode (sSdCard *pSd, uint8_t bMode) |
uint8_t | SD_GetCardType (sSdCard *pSd) |
uint32_t | SD_GetNumberBlocks (sSdCard *pSd) |
uint32_t | SD_GetBlockSize (sSdCard *pSd) |
uint32_t | SD_GetTotalSizeKB (sSdCard *pSd) |
uint8_t | SD_ReadBlocks (sSdCard *pSd, uint32_t dwAddr, void *pData, uint32_t dwNbBlocks) |
uint8_t | SD_WriteBlocks (sSdCard *pSd, uint32_t dwAddr, const void *pData, uint32_t dwNbBlocks) |
uint8_t | SD_Read (sSdCard *pSd, uint32_t dwAddr, void *pData, uint32_t dwNbBlocks, fSdmmcCallback fCallback, void *pArg) |
uint8_t | SD_Write (sSdCard *pSd, uint32_t dwAddr, const void *pData, uint32_t dwNbBlocks, fSdmmcCallback fCallback, void *pArg) |
uint8_t | SDIO_ReadDirect (sSdCard *pSd, uint8_t bFunctionNum, uint32_t dwAddress, uint8_t *pData, uint32_t dwSize) |
uint8_t | SDIO_WriteDirect (sSdCard *pSd, uint8_t bFunctionNum, uint32_t dwAddress, uint8_t bDataByte) |
uint8_t | SDIO_ReadBytes (sSdCard *pSd, uint8_t bFunctionNum, uint32_t dwAddress, uint8_t bIsFixedAddress, uint8_t *pData, uint16_t wSize, fSdmmcCallback fCallback, void *pArg) |
uint8_t | SDIO_WriteBytes (sSdCard *pSd, uint8_t bFunctionNum, uint32_t dwAddress, uint8_t bIsFixedAddress, uint8_t *pData, uint16_t wSize, fSdmmcCallback fCallback, void *pArg) |
void | _DumpREG (void *pREG, uint32_t dwSize) |
Dump register. | |
void | SDIO_DumpCardInformation (sSdCard *pSd) |
void | SD_DumpCID (void *pCID) |
void | SD_DumpCSD (void *pCSD) |
void | SD_DumpExtCSD (void *pExtCSD) |
void | SD_DumpSCR (void *pSCR) |
void | SD_DumpSdStatus (void *pSdST) |
void | SDD_Initialize (sSdCard *pSd, const void *pDrv, uint8_t bSlot, const sSdHalFunctions *pHalf) |
Variables | |
uint32_t | switchStatus [512/32] |
Definitions and functions for SD/MMC card access.
#define BLOCK_SIZE | ( | pSd | ) | (pSd->wCurrBlockLen) |
#define CARD_ADDR | ( | pSd | ) | (pSd->wAddress) |
#define MMC_ADDRESS | ( | pSd, | ||
address | ||||
) |
#define MMC_IsBootModeSupported | ( | pSd | ) | ( (MMC_IsVer4(pSd)&&(eMMC_CID_CBX(pSd->CID)==0x01) ) |
#define MMC_IsBusModeSupported | ( | pSd | ) | (MMC_IsVer4(pSd)) |
#define MMC_IsCSDVer1_2 | ( | pSd | ) |
( (SD_CSD_STRUCTURE(pSd->CSD)==2) \ ||(SD_CSD_STRUCTURE(pSd->CSD)>2&&MMC_EXT_CSD_STRUCTURE(pSd->EXT)>=2) )
Check if MMC CSD structure is 1.2 (3.1 or later)
#define MMC_IsHsModeSupported | ( | pSd | ) | (MMC_IsCSDVer1_2(pSd)&&(MMC_EXT_CARD_TYPE(pSd->EXT)&0x2)) |
#define MMC_IsVer4 | ( | pSd | ) | ( MMC_CSD_SPEC_VERS(pSd->CSD) >= 4 ) |
#define SD_ADDRESS | ( | pSd, | ||
address | ||||
) |
#define SD_IsBusModeSupported | ( | pSd | ) | (1) |
#define SD_IsHsModeSupported | ( | pSd | ) | ( /*SD_IsVer1_10(pSd)||*/(SD_CSD_STRUCTURE(pSd->CSD)>=1) ) |
#define SD_IsVer1_10 | ( | pSd | ) | ( SD_SCR_SD_SPEC(pSd->SCR) >= SD_SCR_SD_SPEC_1_10 ) |
void SD_DeInit | ( | sSdCard * | pSd | ) |
void SD_DumpCID | ( | void * | pCID | ) |
void SD_DumpCSD | ( | void * | pCSD | ) |
void SD_DumpExtCSD | ( | void * | pExtCSD | ) |
void SD_DumpSCR | ( | void * | pSCR | ) |
void SD_DumpSdStatus | ( | void * | pSdST | ) |
uint32_t SD_GetBlockSize | ( | sSdCard * | pSd | ) |
uint8_t SD_GetCardType | ( | sSdCard * | pSd | ) |
uint32_t SD_GetNumberBlocks | ( | sSdCard * | pSd | ) |
uint32_t SD_GetTotalSizeKB | ( | sSdCard * | pSd | ) |
uint8_t SD_Init | ( | sSdCard * | pSd | ) |
Run the SDcard initialization sequence. This function runs the initialisation procedure and the identification process, then it sets the SD card in transfer state to set the block length and the bus width.
pSd | Pointer to a SD card driver instance. |
uint8_t SD_Read | ( | sSdCard * | pSd, | |
uint32_t | address, | |||
void * | pData, | |||
uint32_t | length, | |||
fSdmmcCallback | pCallback, | |||
void * | pArgs | |||
) |
Read Blocks of data in a buffer pointed by pData. The buffer size must be at least 512 byte long. This function checks the SD card status register and address the card if required before sending the read command.
pSd | Pointer to a SD card driver instance. | |
address | Address of the block to read. | |
pData | Data buffer whose size is at least the block size, it can be 1,2 or 4-bytes aligned when used with DMA. | |
length | Number of blocks to be read. | |
pCallback | Pointer to callback function that invoked when read done. 0 to start a blocked read. | |
pArgs | Pointer to callback function arguments. |
uint8_t SD_ReadBlocks | ( | sSdCard * | pSd, | |
uint32_t | address, | |||
void * | pData, | |||
uint32_t | nbBlocks | |||
) |
Read Blocks of data in a buffer pointed by pData. The buffer size must be at least 512 byte long. This function checks the SD card status register and address the card if required before sending the read command.
pSd | Pointer to a SD card driver instance. | |
address | Address of the block to read. | |
nbBlocks | Number of blocks to be read. | |
pData | Data buffer whose size is at least the block size, it can be 1,2 or 4-bytes aligned when used with DMA. |
uint8_t SD_Write | ( | sSdCard * | pSd, | |
uint32_t | address, | |||
const void * | pData, | |||
uint32_t | length, | |||
fSdmmcCallback | pCallback, | |||
void * | pArgs | |||
) |
Write Blocks of data in a buffer pointed by pData. The buffer size must be at least 512 byte long. This function checks the SD card status register and address the card if required before sending the read command.
pSd | Pointer to a SD card driver instance. | |
address | Address of the block to write. | |
pData | Data buffer whose size is at least the block size, it can be 1,2 or 4-bytes aligned when used with DMA. | |
length | Number of blocks to be write. | |
pCallback | Pointer to callback function that invoked when write done. 0 to start a blocked write. | |
pArgs | Pointer to callback function arguments. |
uint8_t SD_WriteBlocks | ( | sSdCard * | pSd, | |
uint32_t | address, | |||
const void * | pData, | |||
uint32_t | nbBlocks | |||
) |
Write Block of data pointed by pData. The buffer size must be at least 512 byte long. This function checks the SD card status register and address the card if required before sending the read command.
pSd | Pointer to a SD card driver instance. | |
address | Address of block to write. | |
nbBlocks | Number of blocks to be read | |
pData | Data buffer whose size is at least the block size, it can be 1,2 or 4-bytes aligned when used with DMA. |
void SDD_Initialize | ( | sSdCard * | pSd, | |
const void * | pDrv, | |||
uint8_t | bSlot, | |||
const sSdHalFunctions * | pHalf | |||
) |
void SDIO_DumpCardInformation | ( | sSdCard * | pSd | ) |
uint8_t SDIO_ReadBytes | ( | sSdCard * | pSd, | |
uint8_t | functionNum, | |||
uint32_t | address, | |||
uint8_t | isFixedAddress, | |||
uint8_t * | pData, | |||
uint16_t | size, | |||
fSdmmcCallback | fCallback, | |||
void * | pArg | |||
) |
Read byte by byte from SDIO card, using RW_EXTENDED command.
pSd | Pointer to SdCard instance. | |
functionNum | Function number. | |
address | First byte address of data in SDIO card. | |
isFixedAddress | During transfer the data address is never increased. | |
pData | Pointer to data buffer. | |
size | Size of data to read (1 ~ 512). | |
fCallback | Callback function invoked when transfer finished. | |
pArg | Pointer to callback argument. |
uint8_t SDIO_ReadDirect | ( | sSdCard * | pSd, | |
uint8_t | functionNum, | |||
uint32_t | address, | |||
uint8_t * | pData, | |||
uint32_t | size | |||
) |
Read one or more bytes from SDIO card, using RW_DIRECT command.
pSd | Pointer to SdCard instance. | |
functionNum | Function number. | |
address | First register address to read from. | |
pData | Pointer to data buffer. | |
size | Buffer size, number of bytes to read. |
uint8_t SDIO_WriteBytes | ( | sSdCard * | pSd, | |
uint8_t | functionNum, | |||
uint32_t | address, | |||
uint8_t | isFixedAddress, | |||
uint8_t * | pData, | |||
uint16_t | size, | |||
fSdmmcCallback | fCallback, | |||
void * | pArg | |||
) |
Write byte by byte to SDIO card, using RW_EXTENDED command.
pSd | Pointer to SdCard instance. | |
functionNum | Function number. | |
address | First byte address of data in SDIO card. | |
isFixedAddress | During transfer the data address is never increased. | |
pData | Pointer to data buffer. | |
size | Size of data to write (1 ~ 512). | |
fCallback | Callback function invoked when transfer finished. | |
pArg | Pointer to callback argument. |
uint8_t SDIO_WriteDirect | ( | sSdCard * | pSd, | |
uint8_t | functionNum, | |||
uint32_t | address, | |||
uint8_t | dataByte | |||
) |
Write one byte to SDIO card, using RW_DIRECT command.
pSd | Pointer to SdCard instance. | |
functionNum | Function number. | |
address | Register address to write to. | |
dataByte | Data to write. |