USB Device MSC API

Description

USB Device MSC API.

Data Structures

struct  sl_usbd_msc_subclass_driver_t
 MSC subclass driver.

Functions

sl_status_t sl_usbd_msc_init (void)
 Initialize internal structures and variables used by the Mass Storage Class Bulk Only Transport.
 
sl_status_t sl_usbd_msc_create_instance (uint8_t subclass, uint32_t msc_task_stack_size, osPriority_t msc_task_priority, sl_usbd_msc_subclass_driver_t *p_subclass_drv, void *p_subclass_arg, uint8_t *p_class_nbr)
 Add a new instance of the Mass Storage Class.
 
sl_status_t sl_usbd_msc_add_to_configuration (uint8_t class_nbr, uint8_t config_nbr)
 Add an existing MSC instance to the specified configuration.
 
sl_status_t sl_usbd_msc_lun_add (uint8_t class_nbr, void *p_lu_data, uint8_t *p_lu_nbr)
 Add an MSC logical unit to the MSC interface.
 
sl_status_t sl_usbd_msc_is_enabled (uint8_t class_nbr, bool *p_enabled)
 Get the MSC enable state of the device.

Macros

#define SL_USBD_MSC_LU_NBR_INVALID   255u
 
#define SL_USBD_MSC_SUBCLASS_CODE_RBC   0x01
 
#define SL_USBD_MSC_SUBCLASS_CODE_SFF_8020i   0x02
 
#define SL_USBD_MSC_SUBCLASS_CODE_MMC_2   0x02
 
#define SL_USBD_MSC_SUBCLASS_CODE_QIC_157   0x03
 
#define SL_USBD_MSC_SUBCLASS_CODE_UFI   0x04
 
#define SL_USBD_MSC_SUBCLASS_CODE_SFF_8070i   0x05
 
#define SL_USBD_MSC_SUBCLASS_CODE_SCSI   0x06
 
#define SL_USBD_MSC_PROTOCOL_CODE_CTRL_BULK_INTR_CMD_INTR   0x00
 
#define SL_USBD_MSC_PROTOCOL_CODE_CTRL_BULK_INTR   0x01
 
#define SL_USBD_MSC_PROTOCOL_CODE_BULK_ONLY   0x50

Function Documentation

◆ sl_usbd_msc_init()

sl_status_t sl_usbd_msc_init ( void  )

Initialize internal structures and variables used by the Mass Storage Class Bulk Only Transport.

Returns
Returns SL_STATUS_OK on success or another SL_STATUS code on failure.

◆ sl_usbd_msc_create_instance()

sl_status_t sl_usbd_msc_create_instance ( uint8_t  subclass,
uint32_t  msc_task_stack_size,
osPriority_t  msc_task_priority,
sl_usbd_msc_subclass_driver_t p_subclass_drv,
void *  p_subclass_arg,
uint8_t *  p_class_nbr 
)

Add a new instance of the Mass Storage Class.

Parameters
subclassMSC subclass code.
p_subclass_drvPointer to data structure of functions that implement the subclass driver.
msc_task_stack_sizeThe USB stack creates a task to handle the events of each MSC instance. This parameter specifies the stack size to be used for the newly created task for this instance.
msc_task_priorityThe USB stack creates a task to handle the events of each MSC instance. This parameter specifies the CMSIS priority of that task.
p_subclass_argAn argument that will be passed to the driver when driver functions are called.
p_class_nbrPointer to a variable that will receive the instance number for the created class instance, if no errors are returned. Otherwise, the variable is set to SL_USBD_CLASS_NBR_NONE.
Returns
Returns SL_STATUS_OK on success or another SL_STATUS code on failure.

◆ sl_usbd_msc_add_to_configuration()

sl_status_t sl_usbd_msc_add_to_configuration ( uint8_t  class_nbr,
uint8_t  config_nbr 
)

Add an existing MSC instance to the specified configuration.

Parameters
class_nbrMSC instance number.
config_nbrConfiguration index to which to add the existing MSC interface.
Returns
Returns SL_STATUS_OK on success or another SL_STATUS code on failure.
Note
(1) sl_usbd_msc_add_to_configuration() adds an Interface descriptor and its associated Endpoint descriptor(s) to the Configuration descriptor. One call to sl_usbd_msc_add_to_configuration() builds the Configuration descriptor corresponding to an MSC device with the following format:
*               Configuration Descriptor
*               |-- Interface Descriptor (MSC)
*               |-- Endpoint Descriptor (Bulk OUT)
*               |-- Endpoint Descriptor (Bulk IN)
*               
If sl_usbd_msc_add_to_configuration() is called several times from the application, it creates multiple instances and configurations. For example, the following architecture could be created for a high-speed device:
*               High-speed
*               |-- Configuration 0
*               |-- Interface 0 (MSC 0)
*               |-- Configuration 1
*               |-- Interface 0 (MSC 0)
*               |-- Interface 1 (MSC 1)
*               
In this example, there are two instances of MSC: 'MSC 0' and 'MSC 1', and two possible configurations for the device: 'Configuration 0' and 'Configuration 1'. 'Configuration 1' is composed of two interfaces.
Each class instance has an association with one of the interfaces. If 'Configuration 1' is activated by the host, it allows the host to access two different functionalities offered by the device.

◆ sl_usbd_msc_lun_add()

sl_status_t sl_usbd_msc_lun_add ( uint8_t  class_nbr,
void *  p_lu_data,
uint8_t *  p_lu_nbr 
)

Add an MSC logical unit to the MSC interface.

Parameters
class_nbrMSC instance number.
p_lu_dataPointer to the logical unit data to store in LU data structure.
p_lu_nbrPointer to a variable that will receive Logical Unit Number.
Returns
Returns SL_STATUS_OK on success or another SL_STATUS code on failure.

◆ sl_usbd_msc_is_enabled()

sl_status_t sl_usbd_msc_is_enabled ( uint8_t  class_nbr,
bool *  p_enabled 
)

Get the MSC enable state of the device.

Parameters
class_nbrMSC instance number.
p_enabledPointer to a boolean variable that will receive enable state. The variable is set to true if MSC class is enabled. The variable is set to false if the MSC class is not enabled.
Returns
Returns SL_STATUS_OK on success or another SL_STATUS code on failure.