初中生
最后登录1970-1-1
在线时间 小时
注册时间2019-4-26
|
在调用挂在函数f_mount时,返回值是 FR_DISK_ERR, /* (1) A hard error occurred in the low level disk I/O layer */
所以应该是底层函数挂了,spi_flash的函数都是正常的,测试过。求大佬帮忙看看是哪儿出错了!!!!
我的底层函数如下:
[mw_shl_code=c,true]DSTATUS disk_status (
BYTE pdrv /* Physical drive nmuber to identify the drive */
)
{
uint32_t result;
switch (pdrv) {
case SD_CARD:
// result = ATA_disk_status();
// translate the reslut code here
case FLASH_MEMORY:
// result = MMC_disk_status();
result = SPI_FLASH_ReadId();
// translate the reslut code here
if(result == 0xef4017)
{
return 0;
}
else
{
return STA_NOINIT;
}
default:
return STA_NOINIT;
}
}
/*-----------------------------------------------------------------------*/
/* Inidialize a Drive */
/*-----------------------------------------------------------------------*/
DSTATUS disk_initialize (
BYTE pdrv /* Physical drive nmuber to identify the drive */
)
{
switch (pdrv) {
case SD_CARD:
// result = ATA_disk_initialize();
// translate the reslut code here
case FLASH_MEMORY:
// result = MMC_disk_initialize();
// translate the reslut code here
SPI_FALSH_GPIO_Config();
SPI_FLASH_Config();
SPI_Flash_WAKEUP();
return disk_status(FLASH_MEMORY);
default:
return STA_NOINIT;
}
}
/*-----------------------------------------------------------------------*/
/* Read Sector(s) */
/*-----------------------------------------------------------------------*/
DRESULT disk_read (
BYTE pdrv, /* Physical drive nmuber to identify the drive */
BYTE *buff, /* Data buffer to store read data */
DWORD sector, /* Sector address in LBA */
UINT count /* Number of sectors to read */
)
{
DRESULT res;
switch (pdrv) {
case SD_CARD:
// translate the arguments here
// result = ATA_disk_read(buff, sector, count);
// translate the reslut code here
case FLASH_MEMORY:
// translate the arguments here
// result = MMC_disk_read(buff, sector, count);
// translate the reslut code here
SPI_FLASH_ReadByte(sector << 12, buff, count << 12);
res = RES_OK;
return res;
default :
return RES_PARERR;
}
}
/*-----------------------------------------------------------------------*/
/* Write Sector(s) */
/*-----------------------------------------------------------------------*/
#if _USE_WRITE
DRESULT disk_write (
BYTE pdrv, /* Physical drive nmuber to identify the drive */
const BYTE *buff, /* Data to be written */
DWORD sector, /* Sector address in LBA */
UINT count /* Number of sectors to write */
)
{
DRESULT res;
switch (pdrv) {
case SD_CARD :
// translate the arguments here
// result = ATA_disk_write(buff, sector, count);
// translate the reslut code here
return res;
case FLASH_MEMORY :
// translate the arguments here
// result = MMC_disk_write(buff, sector, count);
// translate the reslut code here
SPI_FALSH_Erase_Sector(sector<< 12);
SPI_FLASH_WritBytes(sector<< 12, (uint8_t*)buff, count<< 12);
res = RES_OK;
return res;
default :
return RES_PARERR;
}
}
#endif
/*-----------------------------------------------------------------------*/
/* Miscellaneous Functions */
/*-----------------------------------------------------------------------*/
#if _USE_IOCTL
DRESULT disk_ioctl (
BYTE pdrv, /* Physical drive nmuber (0..) */
BYTE cmd, /* Control code */
void *buff /* Buffer to send/receive control data */
)
{
DRESULT res;
switch (pdrv) {
case SD_CARD :
// Process of the command for the ATA drive
return res;
case FLASH_MEMORY :
// 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;
default :
return RES_PARERR;
}
}
#endif[/mw_shl_code]
|
|