⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 diskio.c

📁 S64和VS1003的MP3播放实现的源代码/
💻 C
字号:
/*-----------------------------------------------------------------------*/
/* Low level disk I/O module skeleton for FatFs     (C)ChaN, 2007        */
/*-----------------------------------------------------------------------*/
/* This is a stub disk I/O module that acts as front end of the existing */
/* disk I/O modules and attach it to FatFs module with common interface. */
/*-----------------------------------------------------------------------*/


#include "diskio.h"

#define MMC		0	/* Physical drive number for Multi Media Card */
#define USB		1	/* Physical drive number for USB memory */



/*-----------------------------------------------------------------------*/
/* Inidialize a Drive                                                    */

DSTATUS disk_initialize (
	BYTE drv				/* Physical drive nmuber */
)
{
	DSTATUS stat = STA_NOINIT;

	switch (drv) 
    {
	    case MMC :
		    stat = MMC_disk_initialize();
		    // translate the reslut code here
		    break;

	    case USB :
		    stat = USB_disk_initialize();
		    // translate the reslut code here
		    break;
       
        default:
            break;
	}

	return stat;
}



/*-----------------------------------------------------------------------*/
/* Return Disk Status                                                    */

DSTATUS disk_status (
	BYTE drv		/* Physical drive nmuber */
)
{
	DSTATUS stat = STA_NOINIT;

	switch (drv) 
    {
	    case MMC :
		    stat = MMC_disk_status();
            break;

	    case USB :
		    stat = USB_disk_status();
		    break;

        default:
            break;
	}

	return stat;
}



/*-----------------------------------------------------------------------*/
/* Read Sector(s)                                                        */

DRESULT disk_read (
	BYTE drv,		/* Physical drive nmuber (0) */
	BYTE *buff,		/* Data buffer to store read data */
	DWORD sector,	/* Sector number (LBA) */
	BYTE count		/* Sector count (1..255) */
)
{
	DRESULT res = RES_PARERR;

	switch (drv) 
    {
    	case MMC :
    		res = MMC_disk_read(buff, sector, count);
            break;
    
    	case USB :
    		res = USB_disk_read(buff, sector, count);
            break;

        default:
            break;
	}

	return res;
}



/*-----------------------------------------------------------------------*/
/* Write Sector(s)                                                       */

#if _READONLY == 0
DRESULT disk_write (
	BYTE drv,			/* Physical drive nmuber (0) */
	const BYTE *buff,	/* Data to be written */
	DWORD sector,		/* Sector number (LBA) */
	BYTE count			/* Sector count (1..255) */
)
{
	DRESULT res = RES_PARERR;

	switch (drv) 
    {
    	case MMC :
    		res = MMC_disk_write(buff, sector, count);
            break;
    
    	case USB :
    		res = USB_disk_write(buff, sector, count);
            break;

        default:
            break;
	}
	return res;
}
#endif /* _READONLY */



/*-----------------------------------------------------------------------*/
/* Miscellaneous Functions                                               */

DRESULT disk_ioctl (
	BYTE drv,		/* Physical drive nmuber */
	BYTE ctrl,		/* Control code */
	void *buff		/* Buffer to send/receive data block */
)
{
	DRESULT res = RES_PARERR;

	switch (drv) 
    {


	case MMC :
		res = MMC_disk_ioctl(ctrl, buff);
        break;

	case USB :
		res = USB_disk_ioctl(ctrl, buff);
        break;

        default:
            break;
	}
	return res;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -