فهرست منبع

update msc example

hathach 7 سال پیش
والد
کامیت
93db46292a
2فایلهای تغییر یافته به همراه9 افزوده شده و 2 حذف شده
  1. 8 2
      examples/device/nrf52840/src/msc_device_app.c
  2. 1 0
      src/class/msc/msc.h

+ 8 - 2
examples/device/nrf52840/src/msc_device_app.c

@@ -97,12 +97,18 @@ int32_t tud_msc_scsi_cb (uint8_t lun, uint8_t const scsi_cmd[16], void* buffer,
     break;
 
     case SCSI_CMD_TEST_UNIT_READY:
-      ptr = NULL;
+      // Command that host uses to check our readiness before sending other commands
       len = 0;
     break;
 
     case SCSI_CMD_PREVENT_ALLOW_MEDIUM_REMOVAL:
-      ptr = NULL;
+      // Host is about to read/write etc ... better not to disconnect disk
+      len = 0;
+    break;
+
+    case SCSI_CMD_START_STOP_UNIT:
+      // Host try to eject/safe remove/powerof us. We could safely disconnect with disk storage, or go into lower power
+      // scsi_start_stop_unit_t const * cmd_start_stop = (scsi_start_stop_unit_t const *) scsi_cmd
       len = 0;
     break;
 

+ 1 - 0
src/class/msc/msc.h

@@ -133,6 +133,7 @@ typedef enum
   SCSI_CMD_INQUIRY                      = 0x12, ///< The SCSI Inquiry command is used to obtain basic information from a target device.
   SCSI_CMD_MODE_SELECT_6                = 0x15, ///<  provides a means for the application client to specify medium, logical unit, or peripheral device parameters to the device server. Device servers that implement the MODE SELECT(6) command shall also implement the MODE SENSE(6) command. Application clients should issue MODE SENSE(6) prior to each MODE SELECT(6) to determine supported mode pages, page lengths, and other parameters.
   SCSI_CMD_MODE_SENSE_6                 = 0x1A, ///< provides a means for a device server to report parameters to an application client. It is a complementary command to the MODE SELECT(6) command. Device servers that implement the MODE SENSE(6) command shall also implement the MODE SELECT(6) command.
+  SCSI_CMD_START_STOP_UNIT              = 0x1B,
   SCSI_CMD_PREVENT_ALLOW_MEDIUM_REMOVAL = 0x1E,
   SCSI_CMD_READ_CAPACITY_10             = 0x25, ///< The SCSI Read Capacity command is used to obtain data capacity information from a target device.
   SCSI_CMD_REQUEST_SENSE                = 0x03, ///< The SCSI Request Sense command is part of the SCSI computer protocol standard. This command is used to obtain sense data -- status/error information -- from a target device.