Description
Add a Vendor class instance into the specified configuration. The Vendor class instance was previously created by the function USBD_Vendor_Add()
.
Files
usbd_vendor.h / usbd_vendor.c
Prototype
Arguments
class_nbr
Class instance number.
dev_nbr
Device number.
cfg_nbr
Configuration index to add Vendor class 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
None.
Callers
Application.
Notes / Warnings
USBD_Vendor_CfgAdd()
basically adds an Interface descriptor and its associated Endpoint descriptor(s) to the Configuration descriptor. One call toUSBD_Vendor_CfgAdd()
builds the Configuration descriptor corresponding to a Vendor-specific device with the following format:Configuration Descriptor
|-- Interface Descriptor (Vendor class)
|-- Endpoint Descriptor (Bulk OUT)
|-- Endpoint Descriptor (Bulk IN)
|-- Endpoint Descriptor (Interrupt OUT) - optional
|-- Endpoint Descriptor (Interrupt IN) - optional
The pair of Interrupt endpoints are optional. They can be added to the Interface descriptor by setting the parameter
intr_en
toDEF_TRUE
.If
USBD_Vendor_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 (Vendor 0)
|-- Configuration 1
|-- Interface 0 (Vendor 0)
|-- Interface 1 (Vendor 1)
In that example, there are two instances of Vendor class: 'Vendor 0' and 'Vendor 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.