程序乍都跑不对,读不出123。TXT的数据,这个是我的disk_read
DRESULT disk_read (
BYTE_fat drv, /* Physical drive nmuber (0..) */
BYTE_fat *buff, /* Data buffer to store read data */
DWORD_fat sector, /* Sector address (LBA) */
BYTE_fat count /* Number of sectors to read (1..255) */
)
{
int status;
BYTE rd_cnt;
DRESULT res;
int result;
rd_cnt = 0;
Uart_Printf("Block read test[ Polling read ]\n");
rSDIFSTA = rSDIFSTA|(1<<16); // FIFO reset
rSDIDCON=(2<<22)|(1<<19)|(1<<17)|(1<<16)|(1<<14)|(2<<12)|((count)<<0); //YH 040220
rSDICARG=sector;//0x0; // CMD17/18(addr)
RERDCMD:
if(count<2) // SINGLE_READ
{
rSDICCON=(0x1<<9)|(0x1<<8)|0x51; // sht_resp, wait_resp, dat, start, CMD17
if(!Chk_CMDend(17, 1)) //-- Check end of CMD17
{
goto RERDCMD;
}
}
else // MULTI_READ
{
rSDICCON=(0x1<<9)|(0x1<<8)|0x52; // sht_resp, wait_resp, dat, start, CMD18
if(!Chk_CMDend(18, 1)) //-- Check end of CMD18
{
goto RERDCMD;
}
}
rSDICSTA=0xa00; // Clear cmd_end(with rsp)
while(rd_cnt < count) // 512*block bytes
{
if((rSDIDSTA&0x20)==0x20) // Check timeout
{
rSDIDSTA=(0x1<<0x5); // Clear timeout flag
break;
}
status=rSDIFSTA;
if((status&0x1000)==0x1000) // Is Rx data?
{
*buff++=rSDIDAT;
rd_cnt++;
}
}
//-- Check end of DATA
//if(!Chk_DATend())
{
// return 0;
}
rSDIDCON=rSDIDCON&~(7<<12);
rSDIFSTA=rSDIFSTA&0x200; //Clear Rx FIFO Last data Ready, YH 040221
rSDIDSTA=0x10; // Clear data Tx/Rx end detect
if(count>1)
{
RERCMD12:
//--Stop cmd(CMD12)
rSDICARG=0x0; //CMD12(stuff bit)
rSDICCON=(0x1<<9)|(0x1<<8)|0x4c;//sht_resp, wait_resp, start, CMD12
//-- Check end of CMD12
if(!Chk_CMDend(12, 1))
{
goto RERCMD12;
}
rSDICSTA=0xa00; // Clear cmd_end(with rsp)
}
return 0;
}