完整的还应该包括对GET_SECTOR_COUNT,GET_SECTOR_SIZE,GET_BLOCK_SIZE的响应。代码如下:
- DRESULT disk_ioctl(BYTE drv, BYTE ctrl, void *buff)
- {
- if(USBStat & STA_NOINIT)
- {
- return(RES_NOTRDY);
- }
- switch(ctrl)
- {
- /* Make sure that no pending write process */
- case CTRL_SYNC:
- return(RES_OK);
- /* Get number of sectors on the disk (DWORD) */
- case GET_SECTOR_COUNT:
- *(DWORD*)buff = 0;
- return(RES_OK);
- /* Get R/W sector size (WORD) */
- case GET_SECTOR_SIZE: // 扇区大小固定为512
- *(WORD*)buff = 512;
- return(RES_OK);
- /* Get erase block size in unit of sector (DWORD) */
- case GET_BLOCK_SIZE:
- *(DWORD*)buff = 512;
- return(RES_OK);
- default:
- return(RES_PARERR);
- }
- }
复制代码
已知GET_SECTOR_SIZE和GET_BLOCK_SIZE固定为扇区大小,即512。
我现在遇到的问题是,对GET_SECTOR_COUNT的响应。其功能是获取总扇区数。
切盼高人指点!
这个应该是需要 USB 读卡器返回相关信息的@Lewis 熊工 来看下吧
完整的还应该包括对GET_SECTOR_COUNT,GET_SECTOR_SIZE,GET_BLOCK_SIZE的响应。代码如下:
- DRESULT disk_ioctl(BYTE drv, BYTE ctrl, void *buff)
- {
- if(USBStat & STA_NOINIT)
- {
- return(RES_NOTRDY);
- }
- switch(ctrl)
- {
- /* Make sure that no pending write process */
- case CTRL_SYNC:
- return(RES_OK);
- /* Get number of sectors on the disk (DWORD) */
- case GET_SECTOR_COUNT:
- *(DWORD*)buff = 0;
- return(RES_OK);
- /* Get R/W sector size (WORD) */
- case GET_SECTOR_SIZE: // 扇区大小固定为512
- *(WORD*)buff = 512;
- return(RES_OK);
- /* Get erase block size in unit of sector (DWORD) */
- case GET_BLOCK_SIZE:
- *(DWORD*)buff = 512;
- return(RES_OK);
- default:
- return(RES_PARERR);
- }
- }
复制代码
已知GET_SECTOR_SIZE和GET_BLOCK_SIZE固定为扇区大小,即512。
我现在遇到的问题是,对GET_SECTOR_COUNT的响应。其功能是获取总扇区数。
切盼高人指点!
这个应该是需要 USB 读卡器返回相关信息的@Lewis 熊工 来看下吧
举报