From d368611ea6bd4584b3492b18b179edbb9bb8b07b Mon Sep 17 00:00:00 2001 From: Dave Hylands Date: Mon, 29 Sep 2014 20:12:01 -0700 Subject: Proposed fix for USB Mass Storage. --- stmhal/usbdev/class/cdc_msc_hid/inc/usbd_cdc_msc_hid.h | 2 +- stmhal/usbdev/class/cdc_msc_hid/src/usbd_msc_scsi.c | 7 ++----- 2 files changed, 3 insertions(+), 6 deletions(-) (limited to 'stmhal/usbdev') diff --git a/stmhal/usbdev/class/cdc_msc_hid/inc/usbd_cdc_msc_hid.h b/stmhal/usbdev/class/cdc_msc_hid/inc/usbd_cdc_msc_hid.h index 7eca900ee..48d260bc2 100644 --- a/stmhal/usbdev/class/cdc_msc_hid/inc/usbd_cdc_msc_hid.h +++ b/stmhal/usbdev/class/cdc_msc_hid/inc/usbd_cdc_msc_hid.h @@ -58,7 +58,7 @@ typedef struct _USBD_STORAGE { int8_t (* GetCapacity) (uint8_t lun, uint32_t *block_num, uint16_t *block_size); int8_t (* IsReady) (uint8_t lun); int8_t (* IsWriteProtected) (uint8_t lun); - int8_t (* StopUnit)(uint8_t lun); + int8_t (* StartStopUnit)(uint8_t lun, uint8_t started); int8_t (* PreventAllowMediumRemoval)(uint8_t lun, uint8_t param0); int8_t (* Read) (uint8_t lun, uint8_t *buf, uint32_t blk_addr, uint16_t blk_len); int8_t (* Write)(uint8_t lun, uint8_t *buf, uint32_t blk_addr, uint16_t blk_len); diff --git a/stmhal/usbdev/class/cdc_msc_hid/src/usbd_msc_scsi.c b/stmhal/usbdev/class/cdc_msc_hid/src/usbd_msc_scsi.c index 894812c18..366f1f00e 100644 --- a/stmhal/usbdev/class/cdc_msc_hid/src/usbd_msc_scsi.c +++ b/stmhal/usbdev/class/cdc_msc_hid/src/usbd_msc_scsi.c @@ -450,13 +450,10 @@ static int8_t SCSI_StartStopUnit(USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t hmsc->bot_data_length = 0; // On Mac OS X, when the device is ejected a SCSI_START_STOP_UNIT command is sent. - // params[1]==0 means stop, param[1]==1 seems to be something else (happens after the - // device is plugged in and mounted for some time, probably a keep alive). + // Bit 0 of params[4] is the START bit. // If we get a stop, we must really stop the device so that the Mac does not // automatically remount it. - if (params[1] == 0) { - ((USBD_StorageTypeDef *)pdev->pUserData)->StopUnit(lun); - } + ((USBD_StorageTypeDef *)pdev->pUserData)->StartStopUnit(lun, params[4] & 1); return 0; } -- cgit v1.2.3