Status = SD_Init();
if (Status == SD_OK)
{
/*----------------- Read CSD/CID MSD registers ------------------*/
printf("If SD card initialized, get card info.\n");
Status = SD_GetCardInfo(&SDCardInfo);
}
if (Status == SD_OK)
{
/*----------------- Select Card --------------------------------*/
//printf("CSD:0x%x ,CID:0x%x, Capacity:%d,Blocksize:%d,RCA:0x%x,CardType:%d\n",SDCardInfo->SD_csd,SDCardInfo->SD_cid,SDCardInfo->CardCapacity,SDCardInfo->CardBlockSize,SDCardInfo->RCA,SDCardInfo->CardType);
SD_ShowCID(&SDCardInfo);
SD_ShowCSD(&SDCardInfo);
Status = SD_SelectDeselect((u32) (SDCardInfo.RCA << 16));
}
// if (Status == SD_OK)
// {
// Status = SD_EnableWideBusOperation(SDIO_BusWide_1b);
// }
if (Status == SD_OK)
{
Status = SD_SetDeviceMode(SD_DMA_MODE);
printf("In DMA mode.\n\r");
}
if (Status == SD_OK)
{
SD_SetBlockLen(256);
if( Status== SD_OK)
printf("Block Length set to 16 bytes.\n\r");
}
// Status = SD_Erase(0x00, 10240);
//Status = SD_WriteBlock(0x00, Buffer_Block_Tx, BlockSize);
Status = SD_WriteBlock(0x00, (u32 *)writeBuffer, 512);
if (Status==SD_OK)
{
printf("Read from 0x00~0x1f:\n\r");
//Status=SD_WriteBlock(0<<9, (u32 *)writeBuffer, 32);
Status=SD_ReadBlock(0x00, (u32 *)readBuffer, 32);
}
if(Status==SD_OK)
{
pt=(u8 *)readBuffer;
for(i=0;i<32;i++)
printf("\t %d \t",*pt++);
}
printf("\n\r");
if (Status==SD_OK)
{
printf("Read from 0x20~0x3f:\n\r");
//Status=SD_WriteBlock(0<<9, (u32 *)writeBuffer, 32);
Status=SD_ReadBlock(0x20, (u32 *)readBuffer, 32);
}
if(Status==SD_OK)
{
pt=(u8 *)readBuffer;
for(i=0;i<32;i++)
printf("\t %d \t",*pt++);
}
|