SWRU543B January 2019 – June 2025 CC3230S , CC3230SF , CC3235MODS , CC3235MODSF , CC3235S , CC3235SF
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;
}