Delay GetMaxLUN command by 100ms.

Conflicts:
	Downstream/Middlewares/ST/STM32_USB_Host_Library/Class/MSC/Src/usbh_msc.c
USG_1.0
Robert Fisk 5 years ago
parent f0fcead718
commit 1ea38b2150

@ -72,8 +72,9 @@ MSC_ErrorTypeDef;
typedef enum
{
MSC_REQ_IDLE = 0,
MSC_REQ_RESET,
MSC_REQ_STARTUP_DELAY,
MSC_REQ_GET_MAX_LUN,
MSC_REQ_RESET,
MSC_REQ_ERROR,
}
MSC_ReqStateTypeDef;
@ -138,8 +139,8 @@ MSC_HandleTypeDef;
#define USB_REQ_BOT_RESET 0xFF
#define USB_REQ_GET_MAX_LUN 0xFE
//#define MSC_TIMEOUT_FRAMES_PER_BLOCK 1000
#define MSC_TIMEOUT_FIXED 10000 //Some flash drives take 2 seconds to write a single block!
#define MSC_TIMEOUT_FIXED_MS 10000 //Some flash drives take 2 seconds to write a single block!
#define MSC_SAMSUNG_STARTUP_DELAY_MS 100 //Samsung FIT Plus 32GB USB 3.1 flash drive was here
/* MSC Class Codes */
#define USB_MSC_CLASS 0x08

@ -277,12 +277,22 @@ static USBH_StatusTypeDef USBH_MSC_ClassRequest(USBH_HandleTypeDef *phost)
{
MSC_HandleTypeDef *MSC_Handle = (MSC_HandleTypeDef *) phost->pActiveClass->pData;
USBH_StatusTypeDef status = USBH_BUSY;
uint8_t i;
/* Switch MSC REQ state machine */
switch (MSC_Handle->req_state)
{
case MSC_REQ_IDLE:
MSC_Handle->timeout = HAL_GetTick();
MSC_Handle->req_state = MSC_REQ_STARTUP_DELAY;
break;
case MSC_REQ_STARTUP_DELAY:
if ((HAL_GetTick() - MSC_Handle->timeout) > MSC_SAMSUNG_STARTUP_DELAY_MS)
{
MSC_Handle->req_state = MSC_REQ_GET_MAX_LUN;
}
break;
case MSC_REQ_GET_MAX_LUN:
/* Issue GetMaxLUN request */
status = USBH_MSC_BOT_REQ_GetMaxLUN(phost, (uint8_t *)&MSC_Handle->max_lun);
@ -304,11 +314,7 @@ static USBH_StatusTypeDef USBH_MSC_ClassRequest(USBH_HandleTypeDef *phost)
{
MSC_Handle->max_lun = MAX_SUPPORTED_LUN;
}
for(i = 0; i < MSC_Handle->max_lun; i++)
{
MSC_Handle->unit[i].prev_ready_state = USBH_FAIL;
MSC_Handle->unit[i].state_changed = 0;
}
MSC_Handle->req_state = MSC_REQ_IDLE;
}
break;
@ -355,6 +361,7 @@ static USBH_StatusTypeDef USBH_MSC_Process(USBH_HandleTypeDef *phost)
USBH_UsrLog ("LUN #%d: ", MSC_Handle->current_lun);
MSC_Handle->unit[MSC_Handle->current_lun].state = MSC_READ_INQUIRY;
MSC_Handle->timeout = phost->Timer;
//Fallthrough
case MSC_READ_INQUIRY:
scsi_status = USBH_MSC_SCSI_Inquiry(phost, MSC_Handle->current_lun, &MSC_Handle->unit[MSC_Handle->current_lun].inquiry);
@ -752,7 +759,7 @@ USBH_StatusTypeDef USBH_MSC_Read(USBH_HandleTypeDef *phost,
MSC_Handle->unit[lun].state = MSC_READ;
MSC_Handle->rw_lun = lun;
MSC_Handle->RdWrCompleteCallback = callback;
MSC_Handle->timeout = phost->Timer + MSC_TIMEOUT_FIXED;
MSC_Handle->timeout = HAL_GetTick() + MSC_TIMEOUT_FIXED_MS;
USBH_MSC_SCSI_Read(phost,
lun,
@ -794,7 +801,7 @@ USBH_StatusTypeDef USBH_MSC_Write(USBH_HandleTypeDef *phost,
MSC_Handle->unit[lun].state = MSC_WRITE;
MSC_Handle->rw_lun = lun;
MSC_Handle->RdWrCompleteCallback = callback;
MSC_Handle->timeout = phost->Timer + MSC_TIMEOUT_FIXED;
MSC_Handle->timeout = HAL_GetTick() + MSC_TIMEOUT_FIXED_MS;
USBH_MSC_SCSI_Write(phost,
lun,

Loading…
Cancel
Save