MSC_REQ_GET_MAX_LUN=254,///< The Get Max LUN device request is used to determine the number of logical units supported by the device. Logical Unit Numbers on the device shall be numbered contiguously starting from LUN 0 to a maximum LUN of 15
MSC_REQ_RESET=255///< This request is used to reset the mass storage device and its associated interface. This class-specific request shall ready the device for the next CBW from the host.
}msc_request_type_t;
/// \brief Command Block Status Values
/// \details Indicates the success or failure of the command. The device shall set this byte to zero if the command completed
/// successfully. A non-zero value shall indicate a failure during command execution according to the following
uint32_tsignature;///< Signature that helps identify this data packet as a CBW. The signature field shall contain the value 43425355h (little endian), indicating a CBW.
uint32_ttag;///< Tag sent by the host. The device shall echo the contents of this field back to the host in the dCSWTagfield of the associated CSW. The dCSWTagpositively associates a CSW with the corresponding CBW.
uint32_ttotal_bytes;///< The number of bytes of data that the host expects to transfer on the Bulk-In or Bulk-Out endpoint (as indicated by the Direction bit) during the execution of this command. If this field is zero, the device and the host shall transfer no data between the CBW and the associated CSW, and the device shall ignore the value of the Direction bit in bmCBWFlags.
uint8_tdir;///< Bit 7 of this field define transfer direction \n - 0 : Data-Out from host to the device. \n - 1 : Data-In from the device to the host.
uint8_tlun;///< The device Logical Unit Number (LUN) to which the command block is being sent. For devices that support multiple LUNs, the host shall place into this field the LUN to which this command block is addressed. Otherwise, the host shall set this field to zero.
uint8_tcmd_len;///< The valid length of the CBWCBin bytes. This defines the valid length of the command block. The only legal values are 1 through 16
uint8_tcommand[16];///< The command block to be executed by the device. The device shall interpret the first cmd_len bytes in this field as a command block
}msc_cbw_t;
TU_VERIFY_STATIC(sizeof(msc_cbw_t)==31,"size is not correct");
/// Command Status Wrapper
typedefstructTU_ATTR_PACKED
{
uint32_tsignature;///< Signature that helps identify this data packet as a CSW. The signature field shall contain the value 53425355h (little endian), indicating CSW.
uint32_ttag;///< The device shall set this field to the value received in the dCBWTag of the associated CBW.
uint32_tdata_residue;///< For Data-Out the device shall report in the dCSWDataResiduethe difference between the amount of data expected as stated in the dCBWDataTransferLength, and the actual amount of data processed by the device. For Data-In the device shall report in the dCSWDataResiduethe difference between the amount of data expected as stated in the dCBWDataTransferLengthand the actual amount of relevant data sent by the device
uint8_tstatus;///< indicates the success or failure of the command. Values from \ref msc_csw_status_t
}msc_csw_t;
TU_VERIFY_STATIC(sizeof(msc_csw_t)==13,"size is not correct");
SCSI_CMD_TEST_UNIT_READY=0x00,///< The SCSI Test Unit Ready command is used to determine if a device is ready to transfer data (read/write), i.e. if a disk has spun up, if a tape is loaded and ready etc. The device does not perform a self-test operation.
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.
SCSI_CMD_READ_FORMAT_CAPACITY=0x23,///< The command allows the Host to request a list of the possible format capacities for an installed writable media. This command also has the capability to report the writable capacity for a media when it is installed
SCSI_CMD_READ_10=0x28,///< The READ (10) command requests that the device server read the specified logical block(s) and transfer them to the data-in buffer.
SCSI_CMD_WRITE_10=0x2A,///< The WRITE (10) command requests thatthe device server transfer the specified logical block(s) from the data-out buffer and write them.
}scsi_cmd_type_t;
/// SCSI Sense Key
typedefenum
{
SCSI_SENSE_NONE=0x00,///< no specific Sense Key. This would be the case for a successful command
SCSI_SENSE_RECOVERED_ERROR=0x01,///< ndicates the last command completed successfully with some recovery action performed by the disc drive.
SCSI_SENSE_NOT_READY=0x02,///< Indicates the logical unit addressed cannot be accessed.
SCSI_SENSE_MEDIUM_ERROR=0x03,///< Indicates the command terminated with a non-recovered error condition.
SCSI_SENSE_HARDWARE_ERROR=0x04,///< Indicates the disc drive detected a nonrecoverable hardware failure while performing the command or during a self test.
SCSI_SENSE_ILLEGAL_REQUEST=0x05,///< Indicates an illegal parameter in the command descriptor block or in the additional parameters
SCSI_SENSE_UNIT_ATTENTION=0x06,///< Indicates the disc drive may have been reset.
SCSI_SENSE_DATA_PROTECT=0x07,///< Indicates that a command that reads or writes the medium was attempted on a block that is protected from this operation. The read or write operation is not performed.
SCSI_SENSE_FIRMWARE_ERROR=0x08,///< Vendor specific sense key.
SCSI_SENSE_ABORTED_COMMAND=0x0b,///< Indicates the disc drive aborted the command.
SCSI_SENSE_EQUAL=0x0c,///< Indicates a SEARCH DATA command has satisfied an equal comparison.
SCSI_SENSE_VOLUME_OVERFLOW=0x0d,///< Indicates a buffered peripheral device has reached the end of medium partition and data remains in the buffer that has not been written to the medium.
SCSI_SENSE_MISCOMPARE=0x0e///< ndicates that the source data did not match the data read from the medium.
uint8_tcmd_code;///< SCSI OpCode for \ref SCSI_CMD_TEST_UNIT_READY
uint8_tlun;///< Logical Unit
uint8_treserved[3];
uint8_tcontrol;
}scsi_test_unit_ready_t;
TU_VERIFY_STATIC(sizeof(scsi_test_unit_ready_t)==6,"size is not correct");
/// SCSI Inquiry Command
typedefstructTU_ATTR_PACKED
{
uint8_tcmd_code;///< SCSI OpCode for \ref SCSI_CMD_INQUIRY
uint8_treserved1;
uint8_tpage_code;
uint8_treserved2;
uint8_talloc_length;///< specifies the maximum number of bytes that USB host has allocated in the Data-In Buffer. An allocation length of zero specifies that no data shall be transferred.
uint8_tcontrol;
}scsi_inquiry_t,scsi_request_sense_t;
TU_VERIFY_STATIC(sizeof(scsi_inquiry_t)==6,"size is not correct");
/// SCSI Inquiry Response Data
typedefstructTU_ATTR_PACKED
{
uint8_tperipheral_device_type:5;
uint8_tperipheral_qualifier:3;
uint8_t:7;
uint8_tis_removable:1;
uint8_tversion;
uint8_tresponse_data_format:4;
uint8_thierarchical_support:1;
uint8_tnormal_aca:1;
uint8_t:2;
uint8_tadditional_length;
uint8_tprotect:1;
uint8_t:2;
uint8_tthird_party_copy:1;
uint8_ttarget_port_group_support:2;
uint8_taccess_control_coordinator:1;
uint8_tscc_support:1;
uint8_taddr16:1;
uint8_t:3;
uint8_tmulti_port:1;
uint8_t:1;// vendor specific
uint8_tenclosure_service:1;
uint8_t:1;
uint8_t:1;// vendor specific
uint8_tcmd_que:1;
uint8_t:2;
uint8_tsync:1;
uint8_twbus16:1;
uint8_t:2;
uint8_tvendor_id[8];///< 8 bytes of ASCII data identifying the vendor of the product.
uint8_tproduct_id[16];///< 16 bytes of ASCII data defined by the vendor.
uint8_tproduct_rev[4];///< 4 bytes of ASCII data defined by the vendor.
}scsi_inquiry_resp_t;
TU_VERIFY_STATIC(sizeof(scsi_inquiry_resp_t)==36,"size is not correct");
typedefstructTU_ATTR_PACKED
{
uint8_tresponse_code:7;///< 70h - current errors, Fixed Format 71h - deferred errors, Fixed Format
uint8_tvalid:1;
uint8_treserved;
uint8_tsense_key:4;
uint8_t:1;
uint8_tili:1;///< Incorrect length indicator
uint8_tend_of_medium:1;
uint8_tfilemark:1;
uint32_tinformation;
uint8_tadd_sense_len;
uint32_tcommand_specific_info;
uint8_tadd_sense_code;
uint8_tadd_sense_qualifier;
uint8_tfield_replaceable_unit_code;
uint8_tsense_key_specific[3];///< sense key specific valid bit is bit 7 of key[0], aka MSB in Big Endian layout
}scsi_sense_fixed_resp_t;
TU_VERIFY_STATIC(sizeof(scsi_sense_fixed_resp_t)==18,"size is not correct");
typedefstructTU_ATTR_PACKED
{
uint8_tcmd_code;///< SCSI OpCode for \ref SCSI_CMD_MODE_SENSE_6