USB Device MSC API#

USB Device MSC API.

Modules#

sl_usbd_msc_subclass_driver_t

Functions#

sl_status_t

FUNCTION PROTOTYPES.

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

MODULE.

#define
SL_USBD_MSC_SUBCLASS_CODE_RBC 0x01

SUBCLASS CODES.

#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

PROTOCOL CODES.

#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 )

FUNCTION PROTOTYPES.

Parameters
TypeDirectionArgument NameDescription
voidN/A

CONFIGURATION OVERRIDE FUNCTIONS MSC FUNCTIONS

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
TypeDirectionArgument NameDescription
uint8_tN/Asubclass

MSC subclass code.

uint32_tN/Amsc_task_stack_size

Pointer to data structure of functions that implement the subclass driver.

osPriority_tN/Amsc_task_priority

The 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.

sl_usbd_msc_subclass_driver_t *N/Ap_subclass_drv

The USB stack creates a task to handle the events of each MSC instance. This parameter specifies the CMSIS priority of that task.

void *N/Ap_subclass_arg

An argument that will be passed to the driver when driver functions are called.

uint8_t *N/Ap_class_nbr

Pointer 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
TypeDirectionArgument NameDescription
uint8_tN/Aclass_nbr

MSC instance number.

uint8_tN/Aconfig_nbr

Configuration 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
TypeDirectionArgument NameDescription
uint8_tN/Aclass_nbr

MSC instance number.

void *N/Ap_lu_data

Pointer to the logical unit data to store in LU data structure.

uint8_t *N/Ap_lu_nbr

Pointer 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
TypeDirectionArgument NameDescription
uint8_tN/Aclass_nbr

MSC instance number.

bool *N/Ap_enabled

Pointer 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.