我是用SD卡模拟的,修改模拟U盘的工程,const int8_t STORAGE_Inquirydata[] =
{
/* LUN 0 SD卡 */
0x05, //0x05 CD-ROM
0x80,
0x02,
0x02,
(USBD_STD_INQUIRY_LENGTH - 5),
0x00,
0x00,
0x00,
'S', 'T', 'M', ' ', ' ', ' ', ' ', ' ', /* Manufacturer : 8 bytes */
'm', 'i', 'c', 'r', 'o', 'S', 'D', ' ', /* Product : 16 Bytes */
'F', 'l', 'a', 's', 'h', ' ', ' ', ' ',
'1', '.', '0' ,'0', /* Version : 4 Bytes */
};这样也是枚举成功,在电脑上可以看到CD-ROM就是打不开,网上找了下解决方法,**论坛有个人说还要用Fats文件系统函数result = f_mkfs("0:",1,4096);格式化一下
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 FS_SD :
{
res = RES_ERROR;
switch(cmd) {
case CTRL_SYNC:
res = RES_OK;
break;
case GET_SECTOR_COUNT:
*(DWORD *)buff = (DWORD)SDCardInfo.CardCapacity / 512;
res = RES_OK;
break;
case GET_SECTOR_SIZE:
*(DWORD *)buff = 512;
res = RES_OK;
break;
case GET_BLOCK_SIZE:
*(DWORD *)buff = (DWORD)SDCardInfo.CardBlockSize;
res = RES_OK;
break;
case CTRL_POWER:
res = RES_OK;
break;
case CTRL_LOCK:
res = RES_OK;
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;
}
return res;
}
case FS_NAND :
res = RES_OK;
return res;
}
return RES_PARERR;
}
试了下,真的可以 |