summaryrefslogtreecommitdiff
path: root/tinyusb/class/msc_device.c
diff options
context:
space:
mode:
authorhathach <[email protected]>2013-11-01 22:00:39 +0700
committerhathach <[email protected]>2013-11-01 22:00:39 +0700
commitd02ef073376d3f57cbaf9e494ffd27ee113f1cf6 (patch)
tree158914164dc735b1d1374400c6d273da7969655e /tinyusb/class/msc_device.c
parentf2ae5b541faba4b0ea28b010cbf9eda53ff59d70 (diff)
added support for
- sense data scsi_sense_fixed_data_t - read format capacity scsi_read_format_capacity_data_t change msc device callback to support actual response fix dcd_pipe_clear_stall also reset toggle
Diffstat (limited to 'tinyusb/class/msc_device.c')
-rw-r--r--tinyusb/class/msc_device.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/tinyusb/class/msc_device.c b/tinyusb/class/msc_device.c
index f02a1584c..d1c225242 100644
--- a/tinyusb/class/msc_device.c
+++ b/tinyusb/class/msc_device.c
@@ -141,13 +141,15 @@ void mscd_isr(endpoint_handle_t edpt_hdl, tusb_event_t event, uint32_t xferred_b
p_msc->cbw.signature == MSC_CBW_SIGNATURE, VOID_RETURN );
void *p_buffer = NULL;
+ uint16_t actual_length = p_msc->cbw.xfer_bytes;
- p_msc->csw.signature = MSC_CSW_SIGNATURE;
- p_msc->csw.tag = p_msc->cbw.tag;
-
- p_msc->csw.status = tusbd_msc_scsi_received_isr(edpt_hdl.coreid, p_msc->cbw.lun, p_msc->cbw.command, &p_buffer, p_msc->cbw.xfer_bytes);
+ p_msc->csw.signature = MSC_CSW_SIGNATURE;
+ p_msc->csw.tag = p_msc->cbw.tag;
+ p_msc->csw.status = tusbd_msc_scsi_received_isr(edpt_hdl.coreid, p_msc->cbw.lun, p_msc->cbw.command, &p_buffer, &actual_length);
p_msc->csw.data_residue = 0; // TODO expected length, response length
+ ASSERT( p_msc->cbw.xfer_bytes >= actual_length, VOID_RETURN );
+
//------------- Data Phase -------------//
if ( BIT_TEST_(p_msc->cbw.dir, 7) && p_buffer == NULL )
{ // application does not provide data to response --> possibly unsupported SCSI command
@@ -156,7 +158,7 @@ void mscd_isr(endpoint_handle_t edpt_hdl, tusb_event_t event, uint32_t xferred_b
}else
{
ASSERT( dcd_pipe_queue_xfer( BIT_TEST_(p_msc->cbw.dir, 7) ? p_msc->edpt_in : p_msc->edpt_out,
- p_buffer, p_msc->cbw.xfer_bytes) == TUSB_ERROR_NONE, VOID_RETURN);
+ p_buffer, actual_length) == TUSB_ERROR_NONE, VOID_RETURN);
}
//------------- Status Phase -------------//