在移植Fatfs时,提示FR_NO_FILESYSTEM错误,网上有说是底层驱动问题导致的,请问我底层驱动有什么问题(参考战舰)
/* Definitions of physical drive number for each media */
#define EX_FLASH 0 //外部flash,卷标为1
#define FLASH_SECTOR_SIZE 4096
#define FLASH_BLOCK_SIZE 16 //每个BLOCK有16个扇区
//对于W25Q64
//前6M字节给fatfs用,6M字节后~6M+500K给用户用,6M+500K以后,用于存放字库,字库占用1.5M.
SHORT FLASH_SECTOR_COUNT = 512*6;//6M字节,默认为W25Q64
DRESULT disk_read (
BYTE drv, /* Physical drive nmuber (0..) */
BYTE *buff, /* Data buffer to store read data */
DWORD sector, /* Sector address (LBA) */
BYTE count /* Number of sectors to read (1..128) */
)
{
// translate the arguments here
for(;count>0;count--)
{
SPI_Flash_Read((BYTE*)buff,sector*FLASH_SECTOR_SIZE,FLASH_SECTOR_SIZE);
sector++;
buff += FLASH_SECTOR_SIZE;
}
// translate the reslut code here
return RES_OK;
}
#if _USE_WRITE
DRESULT disk_write (
BYTE drv, /* Physical drive nmuber (0..) */
const BYTE *buff, /* Data to be written */
DWORD sector, /* Sector address (LBA) */
BYTE count /* Number of sectors to write (1..128) */
)
{
// translate the arguments here
for(;count>0;count--)
{
SPI_Flash_Write((BYTE*)buff,sector*FLASH_SECTOR_SIZE,FLASH_SECTOR_SIZE);
sector++;
buff += FLASH_SECTOR_SIZE;
}
// translate the reslut code here
return RES_OK;
}
#endif
我测试单独的读写flash时是可以的,移植fatfs后一直不成功
|