我也遇到过这个问题,
DRESULT disk_read (
U8 drv, /* Physical drive nmuber (0..) */
U8 *buff, /* Data buffer to store read data */
U32 sector, /* Sector address (LBA) */
U8 count /* Number of sectors to read (1..255) */
)
{
U16 i;
if (drv || !count)
{
return RES_PARERR; //仅支持单磁盘操作,count不能等于0,否则返回参数错误
}
if(SD_Card_Ready)//SD卡没初始化成功
{
return RES_NOTRDY;
}
//sector *= 512; /* Convert to byte address if needed 注意!!!这里如果这里乘了512, 函数rcvr_datablock(buff,sector, 512))里就别乘了,否则读0 sector是对的,非0sector计算的地址就错了
*/
rsec = sector;
if (count == 1) /* Single block read */
{
//Uart_Printf("SD Single block read--->\n");
if(rcvr_datablock(buff,sector, 512))/* READ_SINGLE_BLOCK */
count = 0;
}
else /* Multiple block read */
{
//Uart_Printf("SD Multiple block read--->\n");
if(rcvr_datablock(buff,sector, count*512))/* READ_SINGLE_BLOCK */
count = 0;
}
for(i=0;i<512;i++)
{
xbuf = buff;
}
return count ? RES_ERROR : RES_OK;
}