mirror of
https://github.com/hathach/tinyusb.git
synced 2025-01-31 05:52:55 +08:00
invoke scsi complete callback before queue for csw status
there is racing issue with samd + qspi flash testing with arduino otherwise.
This commit is contained in:
parent
2caa1ac078
commit
605129eb66
@ -39,7 +39,8 @@ enum
|
|||||||
{
|
{
|
||||||
MSC_STAGE_CMD = 0,
|
MSC_STAGE_CMD = 0,
|
||||||
MSC_STAGE_DATA,
|
MSC_STAGE_DATA,
|
||||||
MSC_STAGE_STATUS
|
MSC_STAGE_STATUS,
|
||||||
|
MSC_STAGE_STATUS_SENT
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
@ -569,7 +570,11 @@ bool mscd_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t event, uint32_t
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case MSC_STAGE_STATUS:
|
case MSC_STAGE_STATUS:
|
||||||
// Wait for the command status wrapper complete event
|
// processed immediately after this switch, supposedly to be empty
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MSC_STAGE_STATUS_SENT:
|
||||||
|
// Wait for the Status phase to complete
|
||||||
if( (ep_addr == p_msc->ep_in) && (xferred_bytes == sizeof(msc_csw_t)) )
|
if( (ep_addr == p_msc->ep_in) && (xferred_bytes == sizeof(msc_csw_t)) )
|
||||||
{
|
{
|
||||||
TU_LOG2(" SCSI Status: %u\n", p_csw->status);
|
TU_LOG2(" SCSI Status: %u\n", p_csw->status);
|
||||||
@ -598,9 +603,6 @@ bool mscd_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t event, uint32_t
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Send SCSI Status
|
|
||||||
TU_ASSERT(usbd_edpt_xfer(rhport, p_msc->ep_in , (uint8_t*) &p_msc->csw, sizeof(msc_csw_t)));
|
|
||||||
|
|
||||||
// Invoke complete callback if defined
|
// Invoke complete callback if defined
|
||||||
switch(p_cbw->command[0])
|
switch(p_cbw->command[0])
|
||||||
{
|
{
|
||||||
@ -616,6 +618,12 @@ bool mscd_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t event, uint32_t
|
|||||||
if ( tud_msc_scsi_complete_cb ) tud_msc_scsi_complete_cb(p_cbw->lun, p_cbw->command);
|
if ( tud_msc_scsi_complete_cb ) tud_msc_scsi_complete_cb(p_cbw->lun, p_cbw->command);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Move to Status Sent stage
|
||||||
|
p_msc->stage = MSC_STAGE_STATUS_SENT;
|
||||||
|
|
||||||
|
// Send SCSI Status
|
||||||
|
TU_ASSERT(usbd_edpt_xfer(rhport, p_msc->ep_in , (uint8_t*) &p_msc->csw, sizeof(msc_csw_t)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
* \ref CFG_TUSB_MCU must be defined to one of these
|
* \ref CFG_TUSB_MCU must be defined to one of these
|
||||||
* @{ */
|
* @{ */
|
||||||
|
|
||||||
#define OPT_MCU_NONE 0
|
#define OPT_MCU_NONE 0
|
||||||
|
|
||||||
// LPC
|
// LPC
|
||||||
#define OPT_MCU_LPC11UXX 1 ///< NXP LPC11Uxx
|
#define OPT_MCU_LPC11UXX 1 ///< NXP LPC11Uxx
|
||||||
|
Loading…
x
Reference in New Issue
Block a user