Data Structures | Typedefs | Enumerations | Functions

usb/include/usb_msc.h File Reference

USB Mass Storage Class Enumerations and Structures. More...

Go to the source code of this file.

Data Structures

struct  msc_command_block_wrapper
 MSC Bulk-Only Data Command Block Wrapper. More...
struct  msc_command_status_wrapper
 MSC Bulk-Only Data Command Block Wrapper. More...
struct  msc_scsi_inquiry_command
struct  msc_scsi_request_sense_command
struct  msc_scsi_mode_sense_6_command
struct  msc_scsi_start_stop_unit
struct  msc_scsi_read_10_command
struct  msc_scsi_write_10_command
struct  scsi_inquiry_response
struct  scsi_capacity_response
struct  scsi_mode_sense_response
struct  scsi_sense_response
class  msc_application_data
 MSC Applicaiton Data. More...

Typedefs

typedef uint8_t msc_lun_mask_t
typedef void(* msc_completion_callback )(struct msc_application_data *app_data, bool transfer_ok)
 MSC Transmission Complete Callback.

Enumerations

enum  MSCRequests { MSC_GET_MAX_LUN = 0xfe, MSC_BULK_ONLY_MASS_STORAGE_RESET = 0xff }
 

MSC Class Requests.

More...
enum  MSCStatus { MSC_STATUS_PASSED = 0, MSC_STATUS_FAILED = 1, MSC_STATUS_PHASE_ERROR = 2 }
 

MSC Command Block Status Values.

More...
enum  MSCDirection { MSC_DIRECTION_OUT = 0x0, MSC_DIRECTION_IN_BIT = 0x80 }
 

MSC Command Block Flags (Direction is the only used bit)

More...
enum  MSCSCSICommands {
  MSC_SCSI_FORMAT_UNIT = 0x04, MSC_SCSI_INQUIRY = 0x12, MSC_SCSI_MODE_SELECT_6 = 0x15, MSC_SCSI_MODE_SELECT_10 = 0x55,
  MSC_SCSI_MODE_SENSE_6 = 0x1a, MSC_SCSI_MODE_SENSE_10 = 0x5a, MSC_SCSI_START_STOP_UNIT = 0x1b, MSC_SCSI_READ_6 = 0x08,
  MSC_SCSI_READ_10 = 0x28, MSC_SCSI_READ_CAPACITY_10 = 0x25, MSC_SCSI_REPORT_LUNS = 0xa0, MSC_SCSI_REQUEST_SENSE = 0x03,
  MSC_SCSI_SEND_DIAGNOSTIC = 0x1d, MSC_SCSI_TEST_UNIT_READY = 0x00, MSC_SCSI_VERIFY = 0x2f, MSC_SCSI_WRITE_6 = 0x0a,
  MSC_SCSI_WRITE_10 = 0x2a
}
enum  MSCSCSIVersion { MSC_SCSI_SPC_VERSION_2 = 4, MSC_SCSI_SPC_VERSION_3 = 5 }
enum  SCSISenseResponseCode { SCSI_SENSE_CURRENT_ERRORS = 0x70, SCSI_SENSE_DEFERRED_ERRORS = 0x71, SCSI_SENSE_INFORMATION_VALID = 0x80 }
enum  SCSISenseFlags { SCSI_SENSE_FILEMARK = 0x80, SCSI_SENSE_EOM = 0x40, SCSI_SENSE_ILI = 0x20, SCSI_SENSE_KEY_MASK = 0x0f }
enum  SCSISenseKeys {
  SCSI_SENSE_KEY_NOT_READY = 0x2, SCSI_SENSE_KEY_MEDIUM_ERROR = 0x3, SCSI_SENSE_KEY_ILLEGAL_REQUEST = 0x5, SCSI_SENSE_KEY_UNIT_ATTENTION = 0x6,
  SCSI_SENSE_KEY_DATA_PROTECT = 0x7
}
enum  SCSIAdditionalSenseCodes {
  SCSI_ASC_LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE = 0x21, SCSI_ASC_INVALID_COMMAND_OPERATION_CODE = 0x20, SCSI_ASC_INVALID_FIELD_IN_COMMAND_PACKET = 0x24, SCSI_ASC_LOGICAL_UNIT_NOT_SUPPORTED = 0x25,
  SCSI_ASC_PERIPHERAL_DEVICE_WRITE_FAULT = 0x03, SCSI_ASC_UNRECOVERED_READ_ERROR = 0x11, SCSI_ASC_WRITE_ERROR = 0x0c, SCSI_ASC_MEDIUM_NOT_PRESENT = 0x3a,
  SCSI_ASC_WRITE_PROTECTED = 0x27
}
enum  MSCApplicationStates {
  MSC_IDLE, MSC_DATA_TRANSPORT_IN, MSC_DATA_TRANSPORT_OUT, MSC_STALL,
  MSC_CSW, MSC_NEEDS_RESET_RECOVERY
}
 

MSC Application States.

More...
enum  MSCReturnCodes {
  MSC_SUCCESS = 0, MSC_ERROR_MEDIUM_NOT_PRESENT = -1, MSC_ERROR_INVALID_LUN = -2, MSC_ERROR_INVALID_ADDRESS = -3,
  MSC_ERROR_WRITE_PROTECTED = -4, MSC_ERROR_READ = -5, MSC_ERROR_WRITE = -6, MSC_ERROR_MEDIUM = -7
}
 

Return codes used by application callbacks.

More...

Functions

uint8_t msc_init (struct msc_application_data *app_data, uint8_t count)
int8_t process_msc_setup_request (const struct setup_packet *setup)
 Process MSC Setup Request.
void msc_clear_halt (uint8_t endpoint_num, uint8_t direction)
 Clear Halt on MSC Endpoint.
void msc_in_transaction_complete (uint8_t endpoint_num)
 Notify of a transaction completing on the Data-IN endpoint.
void msc_out_transaction_complete (uint8_t endpoint_num)
 Notify of a transaction completing on the Data-OUT endpoint.
uint8_t msc_start_send_to_host (struct msc_application_data *app_data, const uint8_t *data, uint16_t len, msc_completion_callback completion_callback)
 Send data read from the medium to the host.
void msc_notify_read_operation_complete (struct msc_application_data *app_data, bool passed)
 Notify the MSC class that a Read Operation has Completed.
void msc_notify_write_data_handled (struct msc_application_data *app_data)
 Notify Write Data Handled.
void msc_notify_write_operation_complete (struct msc_application_data *app_data, bool passed, uint32_t bytes_processed)
 Notify Write Operation Complete.
int8_t MSC_BULK_ONLY_MASS_STORAGE_RESET_CALLBACK (uint8_t interface)
 MSC Bulk-Only Mass Storage Reset callback.
int8_t MSC_GET_STORAGE_INFORMATION (const struct msc_application_data *app_data, uint8_t lun, uint32_t *block_size, uint32_t *num_blocks, bool *write_protect)
 MSC Get Storage Information Callback.
int8_t MSC_UNIT_READY (const struct msc_application_data *app_data, uint8_t lun)
 MSC Check if Medium is Ready Callback.
int8_t MSC_START_STOP_UNIT (const struct msc_application_data *app_data, uint8_t lun, bool start, bool load_eject)
 Start or Stop an MSC Unit.
int8_t MSC_START_READ (struct msc_application_data *app_data, uint8_t lun, uint32_t lba_address, uint16_t num_blocks)
 MSC Read Callback.
int8_t MSC_START_WRITE (struct msc_application_data *app_data, uint8_t lun, uint32_t lba_address, uint16_t num_blocks, uint8_t **buffer, size_t *buffer_len, msc_completion_callback *callback)
 MSC Write Callback.

Detailed Description

USB Mass Storage Class Enumerations and Structures.

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator