请问一下,sd卡是怎么发送命令的,,看到一段代码,,还是没能理解,,求助
uint8 MMC_SD_SendCmd(uint8 Cmd, uint32 arg) { uint8 r1; uint8 retry=0; SPI_SendWreit(0xFF); //发命令前先发送8 个时钟 SPI_SendWreit(Cmd | 0x40); //分别写入命令 SPI_SendWreit(arg>>24); SPI_SendWreit(arg>>16); SPI_SendWreit(arg>>8); SPI_SendWreit(arg); SPI_SendWreit(0x95); //仅本次有效的 CRC 值 while((r1 = SPI_SendByte(0xFF)) == 0xFF) //等待响应 if(retry++ > 8) break; //超时退出 return r1; //返回状态值 }
|