/**************************************************************************************
* FunctionName : MMCReadMultipleBolck()
* Description : 读取一扇区数据到buffer缓冲中
* EntryParameter : NO
* ReturnValue : 返回操作状态:失败-1;成功-0
**************************************************************************************/
uint8_t MMCReadMultipleBolck(uint32_t addr,uint8_t *buf,uint8_t count)
{
uint16_t i;
if (MMCWriteCmd(CMD18,0xFF,addr) != 0x00) // 发送CMD18
{
return 1; // 读取失败
}
do
{
while (SSPTransceiver(0xFF) != 0xFE)
{
; // 等待数据接受开始,受到0xFE表示开始
}
for (i=0; i<512; i++) // 读取数据
{
*buf++ = SSPTransceiver(0xFF);
}
SSPTransceiver(0xFF); // 取走CRC字节
SSPTransceiver(0xFF);
}while (--count);
MMCWriteCmd(CMD12,0xFF,0x00); // CMD12发送停止命令
return 0;
}
|