do{
    	temp=Write_Command_MMC(MMC_INIT,0)		//送入初始化命令,读取返回值;
	    retry++;
    	if(retry==1000)						//循环检测返回值
        {
			printf("MMC_INIT is ERROR!\n ");	//初始化失败
            return(INIT_CMD1_ERROR);        
        }
    }while(temp!=0);
  	printf("MMC_INIT is OK!\n");				//初始化完成
    return (1);
}
uchar MMC_read_sector(ulong sector,uchar *Buffer)		//读卡函数
{
	uchar temp;
	uint i;
	SPI_TransferByte(0xff);					将传输数据线置1
	temp = Write_Command_MMC(MMC_READ_BLOCK,sector<<9);	//将地址送入,读取返回值
	if(temp != 0x00)								//判断是否出错
	{
		return(READ_BLOCK_ERROR);
	}
	while(SPI_TransferByte(0xff) != 0xfe);
	for(i=0;i<512;i++)							//读取数据
	{
		*Buffer++ = SPI_TransferByte(0xff);
	}
	SPI_TransferByte(0xff);							//将传输数据线置高
	SPI_TransferByte(0xff);
	return (1);								//返回1
}
unsigned char MMC_Write_sector(ulong sector, uchar *Buffer)			//写卡函数
{
 	unsigned int i,flag;
 	unsigned char *p, by;
 	unsigned long startadr;
 	p=Buffer; 
 	startadr=sector * (unsigned long)BYTE_PER_SEC;			//计算地址
 	Write_Command_MMC (MMC_WRITE_BLOCK,startadr);		//送入地址