Don't spam device while waiting for MSC unit ready

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

@ -52,6 +52,7 @@ typedef enum
MSC_READ_CAPACITY10, MSC_READ_CAPACITY10,
MSC_READ_INQUIRY, MSC_READ_INQUIRY,
MSC_REQUEST_SENSE, MSC_REQUEST_SENSE,
MSC_REQUEST_SENSE_WAIT_RETRY,
MSC_READ, MSC_READ,
MSC_WRITE, MSC_WRITE,
MSC_UNRECOVERED_ERROR, MSC_UNRECOVERED_ERROR,
@ -118,6 +119,7 @@ typedef struct _MSC_Process
uint16_t current_lun; uint16_t current_lun;
uint16_t rw_lun; uint16_t rw_lun;
uint32_t timeout; uint32_t timeout;
uint32_t retry_timeout;
MSC_RdWrCompleteCallback RdWrCompleteCallback; MSC_RdWrCompleteCallback RdWrCompleteCallback;
} }
MSC_HandleTypeDef; MSC_HandleTypeDef;
@ -145,6 +147,10 @@ MSC_HandleTypeDef;
/* Interface Descriptor field values for MSC Protocol */ /* Interface Descriptor field values for MSC Protocol */
#define MSC_BOT 0x50 #define MSC_BOT 0x50
#define MSC_TRANSPARENT 0x06 #define MSC_TRANSPARENT 0x06
#define MSC_STARTUP_TIMEOUT_MS 15000
#define MSC_STARTUP_RETRY_TIME_MS 100
/** /**
* @} * @}
*/ */

@ -453,10 +453,10 @@ static USBH_StatusTypeDef USBH_MSC_Process(USBH_HandleTypeDef *phost)
if((MSC_Handle->unit[MSC_Handle->current_lun].sense.key == SCSI_SENSE_KEY_UNIT_ATTENTION) || if((MSC_Handle->unit[MSC_Handle->current_lun].sense.key == SCSI_SENSE_KEY_UNIT_ATTENTION) ||
(MSC_Handle->unit[MSC_Handle->current_lun].sense.key == SCSI_SENSE_KEY_NOT_READY) ) (MSC_Handle->unit[MSC_Handle->current_lun].sense.key == SCSI_SENSE_KEY_NOT_READY) )
{ {
if((HAL_GetTick() - MSC_Handle->timeout) < MSC_STARTUP_TIMEOUT_MS)
if((phost->Timer - MSC_Handle->timeout) < 10000)
{ {
MSC_Handle->unit[MSC_Handle->current_lun].state = MSC_TEST_UNIT_READY; MSC_Handle->retry_timeout = HAL_GetTick();
MSC_Handle->unit[MSC_Handle->current_lun].state = MSC_REQUEST_SENSE_WAIT_RETRY;
break; break;
} }
} }
@ -479,6 +479,13 @@ static USBH_StatusTypeDef USBH_MSC_Process(USBH_HandleTypeDef *phost)
} }
break; break;
case MSC_REQUEST_SENSE_WAIT_RETRY:
if ((HAL_GetTick() - MSC_Handle->retry_timeout) > MSC_STARTUP_RETRY_TIME_MS)
{
MSC_Handle->unit[MSC_Handle->current_lun].state = MSC_TEST_UNIT_READY;
}
break;
case MSC_UNRECOVERED_ERROR: case MSC_UNRECOVERED_ERROR:
MSC_Handle->current_lun++; MSC_Handle->current_lun++;
break; break;

Loading…
Cancel
Save