//文件体系与SD卡驱动接口文件diskio.c
#include “diskio.h”
#include “ffconf.h”
#include
#include “MMC_SD.h”
DSTATUS disk_initialize (
BYTE drv
)
{
int Status;
switch (drv)
{
case 0 :
// Status = MSD0_Init();
Status = SD_Init();
if(Status==0){
return RES_OK;
}else{
return STA_NOINIT;
}
case 1 :
return RES_OK;
case 2 :
return RES_OK;
case 3 :
return RES_OK;
default:
return STA_NOINIT;
}
}
DSTATUS disk_status (
BYTE drv
)
{
switch (drv)
{
case 0 :
return RES_OK;
case 1 :
return RES_OK;
case 2 :
return RES_OK;
default:
return STA_NOINIT;
}
}
DRESULT disk_read (
BYTE drv,
BYTE *buff,
DWORD sector,
BYTE count
)
{
int Status;
if( !count )
{
return RES_PARERR;
}
switch (drv)
{
case 0:
if(count==1)
{
Status =SD_ReadSingleBlock( sector ,buff );
if(Status == 0){
return RES_OK;
}else{
return RES_ERROR;
}
}
else
{
Status = SD_ReadMultiBlock( sector , buff ,count);
if(Status == 0){
return RES_OK;
}else{
return RES_ERROR;
}
}
case 1:
if(count==1)
{
return RES_OK;
}
else
{
return RES_OK;
}
default:
return RES_ERROR;
}
}
#if _READONLY == 0
DRESULT disk_write (
BYTE drv,
const BYTE *buff,
DWORD sector,
BYTE count
)
{
int Status;
if( !count )
{
return RES_PARERR;
}
switch (drv)
{
case 0:
if(count==1)
{
Status = SD_WriteSingleBlock( sector , (uint8_t *)(&buff[0]) );
if(Status == 0){
return RES_OK;
}else{
return RES_ERROR;
}
}
else
{
Status = SD_WriteMultiBlock( sector , (uint8_t *)(&buff[0]) , count );
if(Status == 0){
return RES_OK;
}else{
return RES_ERROR;
}
}
case 1:
if(count==1)
{
return RES_OK;
}
else
{
return RES_OK;
}
default:return RES_ERROR;
}
}
#endif
DRESULT disk_ioctl (
BYTE drv,
BYTE ctrl,
void *buff
)
{
if (drv==0)
{
switch (ctrl)
{
case CTRL_SYNC :
return RES_OK;
case GET_SECTOR_COUNT :
*(DWORD*)buff = 4096;
return RES_OK;
case GET_SECTOR_SIZE :
*(WORD*)buff = 512;
return RES_OK;
case GET_BLOCK_SIZE :
*(WORD*)buff = 512;
return RES_OK;
case CTRL_POWER :
break;
case CTRL_LOCK :
break;
case CTRL_EJECT :
break;
case MMC_GET_TYPE :
break;
case MMC_GET_CSD :
break;
case MMC_GET_CID :
break;
case MMC_GET_OCR :
break;
case MMC_GET_SDSTAT :
break;
}
}
else{
return RES_PARERR;
}
return RES_PARERR;
}
DWORD get_fattime (void)
{
return 0;
}
声明:本文内容来自网络转载或用户投稿,文章版权归原作者和原出处所有。文中观点,不代表本站立场。若有侵权请联系本站删除(kf@86ic.com)https://www.86ic.net/xinpin/yuanjian/258413.html