主要是在该函数 ,返回值一定要设置成 RES_OK
DRESULT disk_ioctl (
BYTE pdrv, /* Physical drive nmuber (0..) */
BYTE cmd, /* Control code */
void *buff /* Buffer to send/receive control data */
)
{
DRESULT res;
// int result;
switch (pdrv) {
case SD_CARD :
// Process of the command for the RAM drive
return res;
case SPI_FLASH :
// Process of the command for the MMC/SD card
switch(cmd)
{
//上层获取扇区计数
case GET_SECTOR_COUNT:
*(DWORD *)buff = 2048;
break;
//上层获取扇区大小
case GET_SECTOR_SIZE:
*(WORD *)buff = 4096;
break;
//返回擦除扇区的最小个数(单位扇区)
case GET_BLOCK_SIZE:
*(DWORD *)buff = 1;
break;
}
**return RES_OK; //这样在挂载文件的时候就不会出现错误**
case DEV_USB :
return res;
}
return RES_PARERR;
}
编译后显示成功