本帖最后由 Feeling_MCU 于 2019-5-24 22:55 编辑
执行f_read 正常。
执行f_write 失败
rtn = f_write(&fil, "Hello, World!
", 15, &bw);
运行到 while (USBH_MSC_RdWrProcess(phost, lun) == USBH_BUSY) 会一直死循环超时,导致写失败。
请教下是什么情况呢?
USBH_StatusTypeDef USBH_MSC_Read(USBH_HandleTypeDef *phost,
uint8_t lun,
uint32_t address,
uint8_t *pbuf,
uint32_t length)
{
uint32_t timeout;
MSC_HandleTypeDef *MSC_Handle = (MSC_HandleTypeDef *) phost->pActiveClass->pData;
if ((phost->device.is_connected == 0U) ||
(phost->gState != HOST_CLASS) ||
(MSC_Handle->unit[lun].state != MSC_IDLE))
{
return USBH_FAIL;
}
MSC_Handle->state = MSC_READ;
MSC_Handle->unit[lun].state = MSC_READ;
MSC_Handle->rw_lun = lun;
USBH_MSC_SCSI_Read(phost, lun, address, pbuf, length);
timeout = phost->Timer;
while (USBH_MSC_RdWrProcess(phost, lun) == USBH_BUSY)
{
if(((phost->Timer - timeout) > (10000U * length)) || (phost->device.is_connected == 0U))
{
MSC_Handle->state = MSC_IDLE;
return USBH_FAIL;
}
}
MSC_Handle->state = MSC_IDLE;
return USBH_OK;
}
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
获取磁盘的剩余容量 怎么做的?
一周热门 更多>