FATFS R0.13a ÒÆÖ²
µÚÒ»²½£ºÏÂÔØFATFS R0.13aµÄÔ´Âë http://elm-chan.org/fsw/ff/00index_e.html
µÚ¶þ²½£º½«ÏÂÔص½µÄÔ´ÂëÈ«²¿Ìí¼Óµ½¹¤³ÌÀïÃæ
µÚÈý²½£º¸ù¾Ýʵ¼ÊʹÓÃÇé¿öÐÞ¸Äffconf.h ÀïÃæµÄºê¿ª¹ØÑ¡ÏÔÚ±¾Àý×ÓÖÐÐ޸ĵÄÑ¡ÏîÓÐ
#define_USE_STRFUNC1//ʹÄÜf_gets(), f_putc(), f_puts() and f_printf()º¯Êý
#define_USE_MKFS1//ʹÄܸñʽº¯Êýf_mkfs()
#define FF_USE_LFN2//ʹÓó¤ÎļþÃû,¶¯Ì¬ÄÚ´æÔÚÕ»Çø
#define FF_FS_EXFAT1//ʹÄÜexFATÎļþϵͳ
#define FF_FS_NORTC1//²»Ê¹ÓÃrtc£¬Ò²¾ÍÊDz»Ê¹ÓÃʱ¼ä»ñÈ¡º¯Êý¡£
µÚËIJ½£ºÐÞ¸Ädiskio.cÀïÃæµÄ5¸öº¯Êý·Ö±ðÊÇdisk_status()¡¢disk_initialize()¡¢disk_read()¡¢disk_write() ¡¢
disk_ioctl()¡£
±¾ÎÄÊÇÒÔSD¿¨ÎªÀý£¬½øÐÐFATFSµÄÒÆÖ²£¬ËùÓÐÖ»ÓÃSD¿¨×÷Ϊ´ÅÅÌ¡£Èç¹ûÏëÒªÔö¼ÓÆäËû´æ´¢Æ÷
×÷Ϊ´ÅÅ̵Ļ°ÔÚdisk_read()¡¢disk_write()¡¢disk_initialize()º¯ÊýÀïÃæÌí¼Ó¶ÔÓ¦µÄ´æ´¢Æ÷µÄ³õʼ»¯¡¢
¶Á¡¢Ð´º¯Êý¾Í¿ÉÒÔÁË¡£ÔÚ±¾ÎÄÖÐûÓÐÓõ½disk_ioctlºÍdisk_status£¬µÄ¹¦ÄÜËùÒÔÕâÁ½¸öº¯ÊýÖ±½Ó
·µ»ØFR_OK(¾ÍÊÇ0)¡£
µ½ÕâÀïFATFSµÄÒÆÖ²¾Í´ó¹¦¸æ³ÉÁË£¬disk_status()¡¢disk_initialize()¡¢disk_read()¡¢disk_write() ¡¢
disk_ioctl()¡£µÄ´úÂëÈçÏ£¨ÆäÖÐ×¢Ê͵ôµÄ¾ÍÊÇÔÀ´µÄÔ´Â룩£º
DSTATUS disk_initialize ( BYTE pdrv/* Physical drive nmuber to identify the drive */ ) { //DSTATUS stat; int result;
switch (pdrv) { case SDCARD : result = SDInit(); printf("result = %d\t%s,%d\r\n",result,__FILE__,__LINE__);//²âÊÔ // translate the reslut code here
break;;
//case DEV_MMC : //result = MMC_disk_initialize();
//// translate the reslut code here
//return stat;
//case DEV_USB : //result = USB_disk_initialize();
//// translate the reslut code here
//return stat; } if(result) { return STA_NOINIT; } return STA_OK; }
DRESULT disk_read ( BYTE pdrv,/* Physical drive nmuber to identify the drive */ BYTE *buff,/* Data buffer to store read data */ DWORD sector,/* Start sector in LBA */ UINT count/* Number of sectors to read */ ) { DRESULT res = RES_ERROR;
switch (pdrv) { case SDCARD : // translate the arguments here
res = (DRESULT)SDCardReadData(buff, sector, count); break; // translate the reslut code here
//case DEV_MMC : //// translate the arguments here
//result = MMC_disk_read(buff, sector, count);
//// translate the reslut code here
//return res;
//case DEV_USB : //// translate the arguments here
//result = USB_disk_read(buff, sector, count);
//// translate the reslut code here
//return res; }
return res; }
DRESULT disk_write ( BYTE pdrv,/* Physical drive nmuber to identify the drive */ const BYTE *buff,/* Data to be written */ DWORD sector,/* Start sector in LBA */ UINT count/* Number of sectors to write */ ) { DRESULT res = RES_ERROR;; //int result;
switch (pdrv) { case SDCARD : // translate the arguments here
res = (DRESULT)SDCardWriteData((u8*)buff, sector, count); break; //// translate the reslut code here
//return res;
//case DEV_MMC : //// translate the arguments here
//result = MMC_disk_write(buff, sector, count);
//// translate the reslut code here
//return res;
//case DEV_USB : //// translate the arguments here
//result = USB_disk_write(buff, sector, count);
//// translate the reslut code here
//return res; }
return res; }
/*-----------------------------------------------------------------------*/ /* Miscellaneous Functions */ /*-----------------------------------------------------------------------*/
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 DEV_RAM :
//// Process of the command for the RAM drive
//return res;
//case DEV_MMC :
//// Process of the command for the MMC/SD card
//return res;
//case DEV_USB :
//// Process of the command the USB drive
//return res; //}
return RES_OK;; } |
²âÊÔ£ºÀûÓÃÎļþϵͳÌṩµÄAPI½øÐвâÊÔ£¬É¨ÃèĿ¼ÏµÄÎļþ¡¢¶ÁÈ¡0:/test/diskio.hµÄÇ°20¸ö×Ö·û¡¢²åÈë×Ö·û´®
"!!!Write string test!!!\r\n"¡¢µ÷ÕûÎļþλÖ㬶Á³ö¸Õ²Åд½øÈ¥µÄÄÚÈÝ¡£