LUFA Library
Common Class Definitions

Data Structures

struct  MS_CommandBlockWrapper_t
 Mass Storage Class Command Block Wrapper. More...
 
struct  MS_CommandStatusWrapper_t
 Mass Storage Class Command Status Wrapper. More...
 
struct  SCSI_Inquiry_Response_t
 Mass Storage Class SCSI Inquiry Structure. More...
 
struct  SCSI_Request_Sense_Response_t
 Mass Storage Class SCSI Sense Structure. More...
 

Macros

#define MS_CBW_SIGNATURE   0x43425355UL
 
#define MS_COMMAND_DIR_DATA_IN   (1 << 7)
 
#define MS_COMMAND_DIR_DATA_OUT   (0 << 7)
 
#define MS_CSW_SIGNATURE   0x53425355UL
 

Enumerations

enum  MS_ClassRequests_t {
  MS_REQ_GetMaxLUN = 0xFE,
  MS_REQ_MassStorageReset = 0xFF
}
 
enum  MS_CommandStatusCodes_t {
  MS_SCSI_COMMAND_Pass = 0,
  MS_SCSI_COMMAND_Fail = 1,
  MS_SCSI_COMMAND_PhaseError = 2
}
 
enum  MS_Descriptor_ClassSubclassProtocol_t {
  MS_CSCP_MassStorageClass = 0x08,
  MS_CSCP_SCSITransparentSubclass = 0x06,
  MS_CSCP_BulkOnlyTransportProtocol = 0x50
}
 

SCSI Commands

#define SCSI_CMD_INQUIRY   0x12
 
#define SCSI_CMD_REQUEST_SENSE   0x03
 
#define SCSI_CMD_TEST_UNIT_READY   0x00
 
#define SCSI_CMD_READ_CAPACITY_10   0x25
 
#define SCSI_CMD_START_STOP_UNIT   0x1B
 
#define SCSI_CMD_SEND_DIAGNOSTIC   0x1D
 
#define SCSI_CMD_PREVENT_ALLOW_MEDIUM_REMOVAL   0x1E
 
#define SCSI_CMD_WRITE_10   0x2A
 
#define SCSI_CMD_READ_10   0x28
 
#define SCSI_CMD_WRITE_6   0x0A
 
#define SCSI_CMD_READ_6   0x08
 
#define SCSI_CMD_VERIFY_10   0x2F
 
#define SCSI_CMD_MODE_SENSE_6   0x1A
 
#define SCSI_CMD_MODE_SENSE_10   0x5A
 

SCSI Sense Key Values

#define SCSI_SENSE_KEY_GOOD   0x00
 
#define SCSI_SENSE_KEY_RECOVERED_ERROR   0x01
 
#define SCSI_SENSE_KEY_NOT_READY   0x02
 
#define SCSI_SENSE_KEY_MEDIUM_ERROR   0x03
 
#define SCSI_SENSE_KEY_HARDWARE_ERROR   0x04
 
#define SCSI_SENSE_KEY_ILLEGAL_REQUEST   0x05
 
#define SCSI_SENSE_KEY_UNIT_ATTENTION   0x06
 
#define SCSI_SENSE_KEY_DATA_PROTECT   0x07
 
#define SCSI_SENSE_KEY_BLANK_CHECK   0x08
 
#define SCSI_SENSE_KEY_VENDOR_SPECIFIC   0x09
 
#define SCSI_SENSE_KEY_COPY_ABORTED   0x0A
 
#define SCSI_SENSE_KEY_ABORTED_COMMAND   0x0B
 
#define SCSI_SENSE_KEY_VOLUME_OVERFLOW   0x0D
 
#define SCSI_SENSE_KEY_MISCOMPARE   0x0E
 

SCSI Additional Sense Codes

#define SCSI_ASENSE_NO_ADDITIONAL_INFORMATION   0x00
 
#define SCSI_ASENSE_LOGICAL_UNIT_NOT_READY   0x04
 
#define SCSI_ASENSE_INVALID_FIELD_IN_CDB   0x24
 
#define SCSI_ASENSE_NOT_READY_TO_READY_CHANGE   0x28
 
#define SCSI_ASENSE_WRITE_PROTECTED   0x27
 
#define SCSI_ASENSE_FORMAT_ERROR   0x31
 
#define SCSI_ASENSE_INVALID_COMMAND   0x20
 
#define SCSI_ASENSE_LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE   0x21
 
#define SCSI_ASENSE_MEDIUM_NOT_PRESENT   0x3A
 

SCSI Additional Sense Key Code Qualifiers

#define SCSI_ASENSEQ_NO_QUALIFIER   0x00
 
#define SCSI_ASENSEQ_FORMAT_COMMAND_FAILED   0x01
 
#define SCSI_ASENSEQ_INITIALIZING_COMMAND_REQUIRED   0x02
 
#define SCSI_ASENSEQ_OPERATION_IN_PROGRESS   0x07
 

Detailed Description

Module Description

Constants, Types and Enum definitions that are common to both Device and Host modes for the USB Mass Storage Class.

Macro Definition Documentation

◆ MS_CBW_SIGNATURE

#define MS_CBW_SIGNATURE   0x43425355UL

Magic signature for a Command Block Wrapper used in the Mass Storage Bulk-Only transport protocol.

◆ MS_COMMAND_DIR_DATA_IN

#define MS_COMMAND_DIR_DATA_IN   (1 << 7)

Mask for a Command Block Wrapper's flags attribute to specify a command with data sent from device-to-host.

◆ MS_COMMAND_DIR_DATA_OUT

#define MS_COMMAND_DIR_DATA_OUT   (0 << 7)

Mask for a Command Block Wrapper's flags attribute to specify a command with data sent from host-to-device.

◆ MS_CSW_SIGNATURE

#define MS_CSW_SIGNATURE   0x53425355UL

Magic signature for a Command Status Wrapper used in the Mass Storage Bulk-Only transport protocol.

◆ SCSI_ASENSE_FORMAT_ERROR

#define SCSI_ASENSE_FORMAT_ERROR   0x31

SCSI Additional Sense Code to indicate an error whilst formatting the device medium.

◆ SCSI_ASENSE_INVALID_COMMAND

#define SCSI_ASENSE_INVALID_COMMAND   0x20

SCSI Additional Sense Code to indicate an invalid command was issued.

◆ SCSI_ASENSE_INVALID_FIELD_IN_CDB

#define SCSI_ASENSE_INVALID_FIELD_IN_CDB   0x24

SCSI Additional Sense Code to indicate an invalid field was encountered while processing the issued command.

◆ SCSI_ASENSE_LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE

#define SCSI_ASENSE_LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE   0x21

SCSI Additional Sense Code to indicate a write to a block out outside of the medium's range was issued.

◆ SCSI_ASENSE_LOGICAL_UNIT_NOT_READY

#define SCSI_ASENSE_LOGICAL_UNIT_NOT_READY   0x04

SCSI Additional Sense Code to indicate that the logical unit (LUN) addressed is not ready.

◆ SCSI_ASENSE_MEDIUM_NOT_PRESENT

#define SCSI_ASENSE_MEDIUM_NOT_PRESENT   0x3A

SCSI Additional Sense Code to indicate that no removable medium is inserted into the device.

◆ SCSI_ASENSE_NO_ADDITIONAL_INFORMATION

#define SCSI_ASENSE_NO_ADDITIONAL_INFORMATION   0x00

SCSI Additional Sense Code to indicate no additional sense information is available.

◆ SCSI_ASENSE_NOT_READY_TO_READY_CHANGE

#define SCSI_ASENSE_NOT_READY_TO_READY_CHANGE   0x28

SCSI Additional Sense Code to indicate that a medium that was previously indicated as not ready has now become ready for use.

◆ SCSI_ASENSE_WRITE_PROTECTED

#define SCSI_ASENSE_WRITE_PROTECTED   0x27

SCSI Additional Sense Code to indicate that an attempt to write to a protected area was made.

◆ SCSI_ASENSEQ_FORMAT_COMMAND_FAILED

#define SCSI_ASENSEQ_FORMAT_COMMAND_FAILED   0x01

SCSI Additional Sense Qualifier Code to indicate that a medium format command failed to complete.

◆ SCSI_ASENSEQ_INITIALIZING_COMMAND_REQUIRED

#define SCSI_ASENSEQ_INITIALIZING_COMMAND_REQUIRED   0x02

SCSI Additional Sense Qualifier Code to indicate that an initializing command must be issued before the issued command can be executed.

◆ SCSI_ASENSEQ_NO_QUALIFIER

#define SCSI_ASENSEQ_NO_QUALIFIER   0x00

SCSI Additional Sense Qualifier Code to indicate no additional sense qualifier information is available.

◆ SCSI_ASENSEQ_OPERATION_IN_PROGRESS

#define SCSI_ASENSEQ_OPERATION_IN_PROGRESS   0x07

SCSI Additional Sense Qualifier Code to indicate that an operation is currently in progress.

◆ SCSI_CMD_INQUIRY

#define SCSI_CMD_INQUIRY   0x12

SCSI Command Code for an INQUIRY command.

◆ SCSI_CMD_MODE_SENSE_10

#define SCSI_CMD_MODE_SENSE_10   0x5A

SCSI Command Code for a MODE SENSE (10) command.

◆ SCSI_CMD_MODE_SENSE_6

#define SCSI_CMD_MODE_SENSE_6   0x1A

SCSI Command Code for a MODE SENSE (6) command.

◆ SCSI_CMD_PREVENT_ALLOW_MEDIUM_REMOVAL

#define SCSI_CMD_PREVENT_ALLOW_MEDIUM_REMOVAL   0x1E

SCSI Command Code for a PREVENT ALLOW MEDIUM REMOVAL command.

◆ SCSI_CMD_READ_10

#define SCSI_CMD_READ_10   0x28

SCSI Command Code for a READ (10) command.

◆ SCSI_CMD_READ_6

#define SCSI_CMD_READ_6   0x08

SCSI Command Code for a READ (6) command.

◆ SCSI_CMD_READ_CAPACITY_10

#define SCSI_CMD_READ_CAPACITY_10   0x25

SCSI Command Code for a READ CAPACITY (10) command.

◆ SCSI_CMD_REQUEST_SENSE

#define SCSI_CMD_REQUEST_SENSE   0x03

SCSI Command Code for a REQUEST SENSE command.

◆ SCSI_CMD_SEND_DIAGNOSTIC

#define SCSI_CMD_SEND_DIAGNOSTIC   0x1D

SCSI Command Code for a SEND DIAGNOSTIC command.

◆ SCSI_CMD_START_STOP_UNIT

#define SCSI_CMD_START_STOP_UNIT   0x1B

SCSI Command Code for a START STOP UNIT command.

◆ SCSI_CMD_TEST_UNIT_READY

#define SCSI_CMD_TEST_UNIT_READY   0x00

SCSI Command Code for a TEST UNIT READY command.

◆ SCSI_CMD_VERIFY_10

#define SCSI_CMD_VERIFY_10   0x2F

SCSI Command Code for a VERIFY (10) command.

◆ SCSI_CMD_WRITE_10

#define SCSI_CMD_WRITE_10   0x2A

SCSI Command Code for a WRITE (10) command.

◆ SCSI_CMD_WRITE_6

#define SCSI_CMD_WRITE_6   0x0A

SCSI Command Code for a WRITE (6) command.

◆ SCSI_SENSE_KEY_ABORTED_COMMAND

#define SCSI_SENSE_KEY_ABORTED_COMMAND   0x0B

SCSI Sense Code to indicate that the device has aborted the issued command.

◆ SCSI_SENSE_KEY_BLANK_CHECK

#define SCSI_SENSE_KEY_BLANK_CHECK   0x08

SCSI Sense Code to indicate an error while trying to write to a write-once medium.

◆ SCSI_SENSE_KEY_COPY_ABORTED

#define SCSI_SENSE_KEY_COPY_ABORTED   0x0A

SCSI Sense Code to indicate that an EXTENDED COPY command has aborted due to an error.

◆ SCSI_SENSE_KEY_DATA_PROTECT

#define SCSI_SENSE_KEY_DATA_PROTECT   0x07

SCSI Sense Code to indicate that a write attempt on a protected block has been made.

◆ SCSI_SENSE_KEY_GOOD

#define SCSI_SENSE_KEY_GOOD   0x00

SCSI Sense Code to indicate no error has occurred.

◆ SCSI_SENSE_KEY_HARDWARE_ERROR

#define SCSI_SENSE_KEY_HARDWARE_ERROR   0x04

SCSI Sense Code to indicate a hardware error has occurred.

◆ SCSI_SENSE_KEY_ILLEGAL_REQUEST

#define SCSI_SENSE_KEY_ILLEGAL_REQUEST   0x05

SCSI Sense Code to indicate that an illegal request has been issued.

◆ SCSI_SENSE_KEY_MEDIUM_ERROR

#define SCSI_SENSE_KEY_MEDIUM_ERROR   0x03

SCSI Sense Code to indicate an error whilst accessing the medium.

◆ SCSI_SENSE_KEY_MISCOMPARE

#define SCSI_SENSE_KEY_MISCOMPARE   0x0E

SCSI Sense Code to indicate that the source data did not match the data read from the medium.

◆ SCSI_SENSE_KEY_NOT_READY

#define SCSI_SENSE_KEY_NOT_READY   0x02

SCSI Sense Code to indicate that the device is not ready for a new command.

◆ SCSI_SENSE_KEY_RECOVERED_ERROR

#define SCSI_SENSE_KEY_RECOVERED_ERROR   0x01

SCSI Sense Code to indicate that the device has recovered from an error.

◆ SCSI_SENSE_KEY_UNIT_ATTENTION

#define SCSI_SENSE_KEY_UNIT_ATTENTION   0x06

SCSI Sense Code to indicate that the unit requires attention from the host to indicate a reset event, medium removal or other condition.

◆ SCSI_SENSE_KEY_VENDOR_SPECIFIC

#define SCSI_SENSE_KEY_VENDOR_SPECIFIC   0x09

SCSI Sense Code to indicate a vendor specific error has occurred.

◆ SCSI_SENSE_KEY_VOLUME_OVERFLOW

#define SCSI_SENSE_KEY_VOLUME_OVERFLOW   0x0D

SCSI Sense Code to indicate an attempt to write past the end of a partition has been made.

Enumeration Type Documentation

◆ MS_ClassRequests_t

Enum for the Mass Storage class specific control requests that can be issued by the USB bus host.

Enumerator
MS_REQ_GetMaxLUN 

Mass Storage class-specific request to retrieve the total number of Logical Units (drives) in the SCSI device.

MS_REQ_MassStorageReset 

Mass Storage class-specific request to reset the Mass Storage interface, ready for the next command.

◆ MS_CommandStatusCodes_t

Enum for the possible command status wrapper return status codes.

Enumerator
MS_SCSI_COMMAND_Pass 

Command completed with no error

MS_SCSI_COMMAND_Fail 

Command failed to complete - host may check the exact error via a SCSI REQUEST SENSE command.

MS_SCSI_COMMAND_PhaseError 

Command failed due to being invalid in the current phase.

◆ MS_Descriptor_ClassSubclassProtocol_t

Enum for possible Class, Subclass and Protocol values of device and interface descriptors relating to the Mass Storage device class.

Enumerator
MS_CSCP_MassStorageClass 

Descriptor Class value indicating that the device or interface belongs to the Mass Storage class.

MS_CSCP_SCSITransparentSubclass 

Descriptor Subclass value indicating that the device or interface belongs to the SCSI Transparent Command Set subclass of the Mass storage class.

MS_CSCP_BulkOnlyTransportProtocol 

Descriptor Protocol value indicating that the device or interface belongs to the Bulk Only Transport protocol of the Mass Storage class.