Initialization and Configuration Using Peripheral APIs
www.ti.com
368
SWRU543–January 2019
Submit Documentation Feedback
Copyright © 2019, Texas Instruments Incorporated
SD Host Controller Interface
return ulRet;
}
The structure used in the API has the following format:
typedef struct
{
unsigned long ulCardType;
unsigned long long ullCapacity;
unsigned long ulVersion;
unsigned long ulCapClass;
unsigned short ulRCA;
}CardAttrib_t;
11.4.4 Block Read
The code that follows shows a block read using peripheral APIs:
unsigned long CardReadBlock(CardAttrib_t *Card, unsigned char *pBuffer,
unsigned long ulBlockNo, unsigned long ulBlockCount)
{
unsigned long ulSize;
unsigned long ulBlkIndx;
ulBlockCount = ulBlockCount + ulBlockNo;
for(ulBlkIndx = ulBlockNo; ulBlkIndx
<ulBlockCount; ulBlkIndx++)
{
ulSize = 128; // 512/4
// Compute linear address from block no. for SDSC cards.
if(Card->ulCapClass == CARD_CAP_CLASS_SDSC)
{
ulBlockNo = ulBlkIndx * 512;
}
if( SendCmd(CMD_READ_SINGLE_BLK, ulBlockNo) == 0 )
{
// Read out the data.
while(ulSize--)
{
MAP_SDHostDataRead(SDHOST_BASE,((unsigned long *)pBuffer);
pBuffer+=4;
}
}
else
{
// Retutn error
return 1;
}
}
// Return success
return 0;
}