USBD_MSC_CfgAdd

Description

Add an existing MSC instance to the specified configuration and device. The MSC instance was previously created by the function USBD_MSC_Add().

Files

usbd_msc.h / usbd_msc.c

Prototype

CPU_BOOLEAN  USBD_MSC_CfgAdd (CPU_INT08U   class_nbr,
                              CPU_INT08U   dev_nbr,
                              CPU_INT08U   cfg_nbr,
                              USBD_ERR    *p_err);


Arguments

class_nbr

MSC instance number.

dev_nbr

Device number.

cfg_nbr

Configuration index to add MSC instance to.

p_err

Pointer to variable that will receive the return error code from this function.

USBD_ERR_NONE
USBD_ERR_INVALID_ARG
USBD_ERR_ALLOC
USBD_ERR_NULL_PTR
USBD_ERR_DEV_INVALID_NBR
USBD_ERR_DEV_INVALID_STATE
USBD_ERR_CFG_INVALID_NBR
USBD_ERR_IF_ALLOC
USBD_ERR_IF_ALT_ALLOC
USBD_ERR_IF_INVALID_NBR
USBD_ERR_EP_NONE_AVAIL
USBD_ERR_EP_ALLOC

Returned Value

DEF_YES, if MSC instance is added to USB device configuration successfully.

DEF_NO, otherwise.

Callers

Application.

Notes / Warnings

USBD_MSC_CfgAdd() basically adds an Interface descriptor and its associated Endpoint descriptor(s) to the Configuration descriptor. One call to USBD_MSC_CfgAdd() builds the Configuration descriptor corresponding to a MSC device with the following format:

Configuration Descriptor
|-- Interface Descriptor (MSC)
 |-- Endpoint Descriptor (Bulk OUT)
 |-- Endpoint Descriptor (Bulk IN)

If USBD_MSC_CfgAdd() is called several times from the application, it allows to create multiple instances and multiple configurations. For instance, the following architecture could be created for an high-speed device:

High-speed
|-- Configuration 0
    |-- Interface 0 (MSC 0)
|-- Configuration 1
    |-- Interface 0 (MSC 0)
    |-- Interface 1 (MSC 1)

In that 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.