Data Structures |
struct | USB_ClassInfo_MS_Host_t |
struct | SCSI_Request_Sense_Response_t |
struct | SCSI_Inquiry_Response_t |
struct | SCSI_Capacity_t |
Defines |
#define | MS_ERROR_LOGICAL_CMD_FAILED 0x80 |
Enumerations |
enum | MSHost_EnumerationFailure_ErrorCodes_t {
MS_ENUMERROR_NoError = 0,
MS_ENUMERROR_InvalidConfigDescriptor = 1,
MS_ENUMERROR_NoMSInterfaceFound = 2,
MS_ENUMERROR_EndpointsNotFound = 3
} |
Functions |
void | MS_Host_USBTask (USB_ClassInfo_MS_Host_t *const MSInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1) |
uint8_t | MS_Host_ConfigurePipes (USB_ClassInfo_MS_Host_t *const MSInterfaceInfo, uint16_t ConfigDescriptorSize, uint8_t *DeviceConfigDescriptor) ATTR_NON_NULL_PTR_ARG(1 |
uint8_t uint8_t | MS_Host_ResetMSInterface (USB_ClassInfo_MS_Host_t *const MSInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1) |
uint8_t | MS_Host_GetMaxLUN (USB_ClassInfo_MS_Host_t *const MSInterfaceInfo, uint8_t *const MaxLUNIndex) ATTR_NON_NULL_PTR_ARG(1 |
uint8_t uint8_t | MS_Host_GetInquiryData (USB_ClassInfo_MS_Host_t *const MSInterfaceInfo, const uint8_t LUNIndex, SCSI_Inquiry_Response_t *const InquiryData) ATTR_NON_NULL_PTR_ARG(1 |
uint8_t uint8_t uint8_t | MS_Host_TestUnitReady (USB_ClassInfo_MS_Host_t *const MSInterfaceInfo, const uint8_t LUNIndex) ATTR_NON_NULL_PTR_ARG(1) |
uint8_t | MS_Host_ReadDeviceCapacity (USB_ClassInfo_MS_Host_t *const MSInterfaceInfo, const uint8_t LUNIndex, SCSI_Capacity_t *const DeviceCapacity) ATTR_NON_NULL_PTR_ARG(1 |
uint8_t uint8_t | MS_Host_RequestSense (USB_ClassInfo_MS_Host_t *const MSInterfaceInfo, const uint8_t LUNIndex, SCSI_Request_Sense_Response_t *const SenseData) ATTR_NON_NULL_PTR_ARG(1 |
uint8_t uint8_t uint8_t | MS_Host_PreventAllowMediumRemoval (USB_ClassInfo_MS_Host_t *const MSInterfaceInfo, const uint8_t LUNIndex, const bool PreventRemoval) ATTR_NON_NULL_PTR_ARG(1) |
uint8_t | MS_Host_ReadDeviceBlocks (USB_ClassInfo_MS_Host_t *const MSInterfaceInfo, const uint8_t LUNIndex, const uint32_t BlockAddress, const uint8_t Blocks, const uint16_t BlockSize, void *BlockBuffer) ATTR_NON_NULL_PTR_ARG(1 |
uint8_t uint8_t | MS_Host_WriteDeviceBlocks (USB_ClassInfo_MS_Host_t *const MSInterfaceInfo, const uint8_t LUNIndex, const uint32_t BlockAddress, const uint8_t Blocks, const uint16_t BlockSize, void *BlockBuffer) ATTR_NON_NULL_PTR_ARG(1 |
Detailed Description
The following files must be built with any user project that uses this module:
- LUFA/Drivers/USB/Class/Host/MassStorage.c
Host Mode USB Class driver framework interface, for the Mass Storage USB Class driver.
Define Documentation
#define MS_ERROR_LOGICAL_CMD_FAILED 0x80 |
Error code for some Mass Storage Host functions, indicating a logical (and not hardware) error
Enumeration Type Documentation
- Enumerator:
MS_ENUMERROR_NoError |
Configuration Descriptor was processed successfully
|
MS_ENUMERROR_InvalidConfigDescriptor |
The device returned an invalid Configuration Descriptor
|
MS_ENUMERROR_NoMSInterfaceFound |
A compatible Mass Storage interface was not found in the device's Configuration Descriptor
|
MS_ENUMERROR_EndpointsNotFound |
Compatible Mass Storage endpoints were not found in the device's interfaces
|
Function Documentation
uint8_t MS_Host_ConfigurePipes |
( |
USB_ClassInfo_MS_Host_t *const |
MSInterfaceInfo, |
|
|
uint16_t |
ConfigDescriptorSize, |
|
|
uint8_t * |
DeviceConfigDescriptor | |
|
) |
| | |
Host interface configuration routine, to configure a given Mass Storage host interface instance using the Configuration Descriptor read from an attached USB device. This function automatically updates the given Mass Storage Host instance's state values and configures the pipes required to communicate with the interface if it is found within the device. This should be called once after the stack has enumerated the attached device, while the host state machine is in the Addressed state.
- Parameters:
-
[in,out] | MSInterfaceInfo | Pointer to a structure containing an MS Class host configuration and state |
[in] | ConfigDescriptorSize | Length of the attached device's Configuration Descriptor |
[in] | DeviceConfigDescriptor | Pointer to a buffer containing the attached device's Configuration Descriptor |
- Returns:
- A value from the MSHost_EnumerationFailure_ErrorCodes_t enum
Retrieves the Mass Storage device's inquiry data for the specified LUN, indicating the device characteristics and properties.
- Parameters:
-
[in,out] | MSInterfaceInfo | Pointer to a structure containing a MS Class host configuration and state |
[in] | LUNIndex | LUN index within the device the command is being issued to |
[out] | InquiryData | Location where the read inquiry data should be stored |
- Returns:
- A value from the Pipe_Stream_RW_ErrorCodes_t enum or MS_ERROR_LOGICAL_CMD_FAILED
Sends a GET MAX LUN control request to the attached device, retrieving the index of the highest LUN (Logical UNit, a logical drive) in the device. This value can then be used in the other functions of the Mass Storage Host mode Class driver to address a specific LUN within the device.
- Parameters:
-
[in,out] | MSInterfaceInfo | Pointer to a structure containing a MS Class host configuration and state |
[out] | MaxLUNIndex | Pointer to a location where the highest LUN index value should be stored |
- Returns:
- A value from the USB_Host_SendControlErrorCodes_t enum
uint8_t uint8_t uint8_t MS_Host_PreventAllowMediumRemoval |
( |
USB_ClassInfo_MS_Host_t *const |
MSInterfaceInfo, |
|
|
const uint8_t |
LUNIndex, |
|
|
const bool |
PreventRemoval | |
|
) |
| | |
Issues a PREVENT MEDIUM REMOVAL command, to logically (or, depending on the type of device, physically) lock the device from removal so that blocks of data on the medium can be read or altered.
- Parameters:
-
[in,out] | MSInterfaceInfo | Pointer to a structure containing a MS Class host configuration and state |
[in] | LUNIndex | LUN index within the device the command is being issued to |
[in] | PreventRemoval | Boolean true if the device should be locked from removal, false otherwise |
- Returns:
- A value from the Pipe_Stream_RW_ErrorCodes_t enum or MS_ERROR_LOGICAL_CMD_FAILED if not ready
uint8_t MS_Host_ReadDeviceBlocks |
( |
USB_ClassInfo_MS_Host_t *const |
MSInterfaceInfo, |
|
|
const uint8_t |
LUNIndex, |
|
|
const uint32_t |
BlockAddress, |
|
|
const uint8_t |
Blocks, |
|
|
const uint16_t |
BlockSize, |
|
|
void * |
BlockBuffer | |
|
) |
| | |
Reads blocks of data from the attached Mass Storage device's medium.
- Parameters:
-
[in,out] | MSInterfaceInfo | Pointer to a structure containing a MS Class host configuration and state |
[in] | LUNIndex | LUN index within the device the command is being issued to |
[in] | BlockAddress | Starting block address within the device to read from |
[in] | Blocks | Total number of blocks to read |
[in] | BlockSize | Size in bytes of each block within the device |
[out] | BlockBuffer | Pointer to where the read data from the device should be stored |
- Returns:
- A value from the Pipe_Stream_RW_ErrorCodes_t enum or MS_ERROR_LOGICAL_CMD_FAILED if not ready
Retrieves the total capacity of the attached USB Mass Storage device, in blocks, and block size.
- Parameters:
-
[in,out] | MSInterfaceInfo | Pointer to a structure containing a MS Class host configuration and state |
[in] | LUNIndex | LUN index within the device the command is being issued to |
[out] | DeviceCapacity | Pointer to the location where the capacity information should be stored |
- Returns:
- A value from the Pipe_Stream_RW_ErrorCodes_t enum or MS_ERROR_LOGICAL_CMD_FAILED if not ready
Retrieves the device sense data, indicating the current device state and error codes for the previously issued command.
- Parameters:
-
[in,out] | MSInterfaceInfo | Pointer to a structure containing a MS Class host configuration and state |
[in] | LUNIndex | LUN index within the device the command is being issued to |
[out] | SenseData | Pointer to the location where the sense information should be stored |
- Returns:
- A value from the Pipe_Stream_RW_ErrorCodes_t enum or MS_ERROR_LOGICAL_CMD_FAILED if not ready
Sends a MASS STORAGE RESET control request to the attached device, resetting the Mass Storage Interface and readying it for the next Mass Storage command.
- Parameters:
-
[in,out] | MSInterfaceInfo | Pointer to a structure containing a MS Class host configuration and state |
- Returns:
- A value from the USB_Host_SendControlErrorCodes_t enum
uint8_t uint8_t uint8_t MS_Host_TestUnitReady |
( |
USB_ClassInfo_MS_Host_t *const |
MSInterfaceInfo, |
|
|
const uint8_t |
LUNIndex | |
|
) |
| | |
Sends a TEST UNIT READY command to the device, to determine if it is ready to accept other SCSI commands.
- Parameters:
-
[in,out] | MSInterfaceInfo | Pointer to a structure containing a MS Class host configuration and state |
[in] | LUNIndex | LUN index within the device the command is being issued to |
- Returns:
- A value from the Pipe_Stream_RW_ErrorCodes_t enum or MS_ERROR_LOGICAL_CMD_FAILED if not ready
General management task for a given Mass Storage host class interface, required for the correct operation of the interface. This should be called frequently in the main program loop, before the master USB management task USB_USBTask().
- Parameters:
-
[in,out] | MSInterfaceInfo | Pointer to a structure containing an MS Class host configuration and state |
uint8_t uint8_t MS_Host_WriteDeviceBlocks |
( |
USB_ClassInfo_MS_Host_t *const |
MSInterfaceInfo, |
|
|
const uint8_t |
LUNIndex, |
|
|
const uint32_t |
BlockAddress, |
|
|
const uint8_t |
Blocks, |
|
|
const uint16_t |
BlockSize, |
|
|
void * |
BlockBuffer | |
|
) |
| | |
Writes blocks of data to the attached Mass Storage device's medium.
- Parameters:
-
[in,out] | MSInterfaceInfo | Pointer to a structure containing a MS Class host configuration and state |
[in] | LUNIndex | LUN index within the device the command is being issued to |
[in] | BlockAddress | Starting block address within the device to write to |
[in] | Blocks | Total number of blocks to read |
[in] | BlockSize | Size in bytes of each block within the device |
[in] | BlockBuffer | Pointer to where the data to write should be sourced from |
- Returns:
- A value from the Pipe_Stream_RW_ErrorCodes_t enum or MS_ERROR_LOGICAL_CMD_FAILED if not ready