背景:选用2Mflash,一部分给fatfs用,剩余用于其它系统参数存储
问题:f_mkfs(1,0,512);格式化后,总大小对,可用空间不对,不知为何?请熟悉的朋友指点一二,谢谢
1480 KiB total drive space.
170 KiB available.
#define FLASH_SECTOR_SIZE 512//0x1000
#define FLASH_SECTOR_COUNT 3072 //2048*2 //2M=2048*512*2 1.5M=3072
#define FLASH_BLOCK_SIZE 8 //4096/512 6=3072/512
DRESULT disk_ioctl (
BYTE drv, /* Physical drive nmuber (0..) */
BYTE ctrl, /* Control code */
void *buff /* Buffer to send/receive control data */
)
{
DRESULT res = RES_OK;
switch (ctrl)
{
case CTRL_SYNC:
break;
case GET_SECTOR_COUNT : // Get number of sectors on the disk (DWORD)
*(DWORD*)buff = FLASH_SECTOR_COUNT; // 4*1024*32 = 131072
res = RES_OK;
break;
case GET_SECTOR_SIZE : // Get R/W sector size (WORD)
*(WORD*)buff = FLASH_SECTOR_SIZE;
res = RES_OK;
break;
case GET_BLOCK_SIZE : // Get erase block size in unit of sector (DWORD)
*(DWORD*)buff =FLASH_BLOCK_SIZE;
res = RES_OK;
default :
res = RES_OK;
break;
}
return res;
}
|