Microchip® Advanced Software Framework

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
USB Device Interface (UDI) for Mass Storage Class (MSC)

USB Device Interface (UDI) for Mass Storage Class (MSC) provides an interface for the configuration and management of USB MSC storage device.

The outline of this documentation is as follows:

For more details for Atmel® Software Framework (ASF) USB Device Stack, refer to following application notes:

API Overview

Data Structures

struct  udi_msc_desc_t
 Interface descriptor structure for MSC. More...
 

Functions

bool udi_msc_process_trans (void)
 Process the background read/write commands. More...
 
bool udi_msc_trans_block (bool b_read, uint8_t *block, iram_size_t block_size, void(*callback)(udd_ep_status_t status, iram_size_t n, udd_ep_id_t ep))
 Transfers data to/from USB MSC endpoints. More...
 

UDI MSC Interface for UDC

UDC_DESC_STORAGE udi_api_t udi_api_msc
 Global structure which contains standard UDI interface for UDC. More...
 

USB Interface Descriptors

The following structures provide predefined USB interface descriptors.

It must be used to define the final USB descriptors.

#define UDI_MSC_STRING_ID   0
 By default no string is associated to this interface. More...
 
#define UDI_MSC_EPS_SIZE_FS   64
 MSC endpoints size for full speed. More...
 
#define UDI_MSC_EPS_SIZE_HS   512
 MSC endpoints size for high speed. More...
 
#define UDI_MSC_DESC
 Content of MSC interface descriptor for all speeds. More...
 
#define UDI_MSC_DESC_FS
 Content of MSC interface descriptor for full speed only. More...
 
#define UDI_MSC_DESC_HS
 Content of MSC interface descriptor for high speed only. More...
 

#define UDI_MSC_DESC
Value:
.iface.bLength = sizeof(usb_iface_desc_t),\
.iface.bDescriptorType = USB_DT_INTERFACE,\
.iface.bInterfaceNumber = UDI_MSC_IFACE_NUMBER,\
.iface.bAlternateSetting = 0,\
.iface.bNumEndpoints = 2,\
.iface.bInterfaceClass = MSC_CLASS,\
.iface.bInterfaceSubClass = MSC_SUBCLASS_TRANSPARENT,\
.iface.bInterfaceProtocol = MSC_PROTOCOL_BULK,\
.iface.iInterface = UDI_MSC_STRING_ID,\
.ep_in.bLength = sizeof(usb_ep_desc_t),\
.ep_in.bDescriptorType = USB_DT_ENDPOINT,\
.ep_in.bEndpointAddress = UDI_MSC_EP_IN,\
.ep_in.bmAttributes = USB_EP_TYPE_BULK,\
.ep_in.bInterval = 0,\
.ep_out.bLength = sizeof(usb_ep_desc_t),\
.ep_out.bDescriptorType = USB_DT_ENDPOINT,\
.ep_out.bEndpointAddress = UDI_MSC_EP_OUT,\
.ep_out.bmAttributes = USB_EP_TYPE_BULK,\
.ep_out.bInterval = 0,
#define UDI_MSC_STRING_ID
By default no string is associated to this interface.
Definition: udi_msc_doc.h:89
#define MSC_CLASS
Definition: usb_protocol_msc.h:52
#define UDI_MSC_EP_OUT
Definition: common/services/usb/class/composite/device/example4/conf_usb.h:230
#define UDI_MSC_EP_IN
USB MSC low level configuration In standalone these configurations are defined by the MSC module...
Definition: common/services/usb/class/composite/device/example4/conf_usb.h:229
Definition: usb_protocol.h:194
Definition: usb_protocol.h:193
#define MSC_PROTOCOL_BULK
Bulk-only.
Definition: usb_protocol_msc.h:79
Standard USB interface descriptor structure.
Definition: usb_protocol.h:446
Definition: usb_protocol.h:251
Standard USB endpoint descriptor structure.
Definition: usb_protocol.h:461
#define UDI_MSC_IFACE_NUMBER
Interface number.
Definition: common/services/usb/class/composite/device/example4/conf_usb.h:233
#define MSC_SUBCLASS_TRANSPARENT
Determined by INQUIRY.
Definition: usb_protocol_msc.h:69

Content of MSC interface descriptor for all speeds.

#define UDI_MSC_DESC_FS
Value:
{\
.ep_in.wMaxPacketSize = LE16(UDI_MSC_EPS_SIZE_FS),\
.ep_out.wMaxPacketSize = LE16(UDI_MSC_EPS_SIZE_FS),\
}
#define UDI_MSC_EPS_SIZE_FS
MSC endpoints size for full speed.
Definition: udi_msc_doc.h:93
#define UDI_MSC_DESC
Content of MSC interface descriptor for all speeds.
Definition: udi_msc_doc.h:98
#define LE16(x)
Definition: compiler.h:773

Content of MSC interface descriptor for full speed only.

#define UDI_MSC_DESC_HS
Value:
{\
.ep_in.wMaxPacketSize = LE16(UDI_MSC_EPS_SIZE_HS),\
.ep_out.wMaxPacketSize = LE16(UDI_MSC_EPS_SIZE_HS),\
}
#define UDI_MSC_EPS_SIZE_HS
MSC endpoints size for high speed.
Definition: udi_msc_doc.h:95
#define UDI_MSC_DESC
Content of MSC interface descriptor for all speeds.
Definition: udi_msc_doc.h:98
#define LE16(x)
Definition: compiler.h:773

Content of MSC interface descriptor for high speed only.

#define UDI_MSC_EPS_SIZE_FS   64

MSC endpoints size for full speed.

#define UDI_MSC_EPS_SIZE_HS   512

MSC endpoints size for high speed.

#define UDI_MSC_STRING_ID   0

By default no string is associated to this interface.

bool udi_msc_process_trans ( void  )

Process the background read/write commands.

Routine called by the main loop.

Routine called by the main loop

References CTRL_BUSY, CTRL_FAIL, CTRL_GOOD, CTRL_NO_PRESENT, memory_2_usb(), status, udi_msc_csw_process(), udi_msc_sense_fail_busy_or_change(), udi_msc_sense_fail_hardware(), udi_msc_sense_fail_not_present(), udi_msc_sense_pass(), and usb_2_memory().

Referenced by main(), and run_usb_msc_test().

bool udi_msc_trans_block ( bool  b_read,
uint8_t *  block,
iram_size_t  block_size,
void(*)(udd_ep_status_t status, iram_size_t n, udd_ep_id_t ep)  callback 
)

Transfers data to/from USB MSC endpoints.

Parameters
[in]b_readMemory to USB, if true
[in,out]blockBuffer on Internal RAM to send or fill
[in]block_sizeBuffer size to send or fill
[in]callbackFunction to call at the end of transfer. If NULL then the routine exit when transfer is finish.
Returns
1 if function was successfully done, otherwise 0.
Parameters
b_readMemory to USB, if true
blockBuffer on Internal RAM to send or fill
block_sizeBuffer size to send or fill
callbackFunction to call at the end of transfer. If NULL then the routine exit when transfer is finish.
Returns
1 if function was successfully done, otherwise 0.

References callback, NULL, udd_ep_run(), UDI_MSC_EP_IN, UDI_MSC_EP_OUT, and udi_msc_trans_ack().

Referenced by sd_mmc_usb_read_10(), sd_mmc_usb_write_10(), and virtual_usb_trans().

Global structure which contains standard UDI interface for UDC.

Global structure which contains standard UDI interface for UDC.