只挂了一个spi nandflash 没挂sd卡, 能识别盘符,读不出东西,让格式化,而且格式化不成功,有知道的大神吗?
//´Ó´æ´¢É豸¶ÁÈ¡Êý¾Ý
//lun:Âß¼µ¥Ôª±àºÅ,0,SD¿¨;1,SPI FLASH
//buf:Êý¾Ý´æ´¢ÇøÊ×µØÖ·Ö¸Õë
//blk_addr:Òª¶ÁÈ¡µÄµØÖ·(ÉÈÇøµØÖ·)
//blk_len:Òª¶ÁÈ¡µÄ¿éÊý(ÉÈÇøÊý)
//·µ»ØÖµ:0,³É¹¦;
// ÆäËû,´íÎó´úÂë
//int8_t STORAGE_Read (uint8_t lun,uint8_t *buf,uint32_t blk_addr,uint16_t blk_len)
int8_t STORAGE_Read (uint8_t lun,uint8_t *buf,uint32_t blk_addr,uint16_t blk_len)
{
NAND_ADDRESS a;
a.Block=blk_addr/64;
a.Page=blk_addr%64;
// int8_t res=0;
USB_STATUS_REG|=0X02;//±ê¼ÇÕýÔÚ¶ÁÊý¾Ý
if(lun==0)
{
SPI_NAND_ReadToCatch(a);
SPI_NAND_ReadFromCatch(buf,0,blk_len*4096);
}
// if(lun==1)
// {
// res=SD_ReadDisk(buf,blk_addr,blk_len);
// if(res)USB_STATUS_REG|=0X08;//SD¿¨¶Á´íÎó!
// }else
// {
// W25QXX_Read(buf,blk_addr*512,blk_len*512);
// }
return 0;
}
//Ïò´æ´¢É豸дÊý¾Ý
//lun:Âß¼µ¥Ôª±àºÅ,0,SD¿¨;1,SPI FLASH
//buf:Êý¾Ý´æ´¢ÇøÊ×µØÖ·Ö¸Õë
//blk_addr:ҪдÈëµÄµØÖ·(ÉÈÇøµØÖ·)
//blk_len:ҪдÈëµÄ¿éÊý(ÉÈÇøÊý)
//·µ»ØÖµ:0,³É¹¦;
// ÆäËû,´íÎó´úÂë
int8_t STORAGE_Write (uint8_t lun,uint8_t *buf,uint32_t blk_addr,uint16_t blk_len)
{
NAND_ADDRESS a;
a.Block=blk_addr/64;
a.Page=blk_addr%64;
// int8_t res=0;
USB_STATUS_REG|=0X01;//±ê¼ÇÕýÔÚдÊý¾Ý
if(lun==0)
{
SPI_NAND_SetRegs(0xa0,0x00);
SPI_NAND_EraseBlock(a);
SPI_NAND_Write(buf,a,blk_len*4096);
// SPI_NAND_WriteToCatch(buf,0,blk_len*4096);
// SPI_NAND_ProgramExecute(a);
}
// if(lun==1)
// {
// res=SD_WriteDisk (buf,blk_addr,blk_len);
// if(res)USB_STATUS_REG|=0X04;//SD¿¨Ð´´íÎó!
// }else
// {
// W25QXX_Write(buf,blk_addr*512,blk_len*512);
// }
return 0;
} |