Configuration Examples

This section provides examples of configuration for µC/USB-Device stack based on some typical usages. This section will only give examples of static stack configuration, as the application-specific configuration greatly depends on your application. Also, the device configuration is related to your product’s context, and the device controller driver configuration depends on the hardware you use.

The examples of typical usage that will be treated are the following:

Simple Full-Speed USB Device

This device uses Micrium’s vendor class.

Table - Configuration Example of a Simple Full-Speed USB Device shows the values that should be set for the different configuration constants described earlier if you build a simple full-speed USB device using Micrium’s vendor class.

Table - Configuration Example of a Simple Full-Speed USB Device
ConfigurationValueExplanation
USBD_CFG_MAX_NBR_CFG1Since the device is full speed, only one configuration is needed.
USBD_CFG_MAX_NBR_IF1Since the device only uses the vendor class, only one interface is needed.
USBD_CFG_MAX_NBR_IF_ALT1No alternate interfaces are needed, but this value must at least be equal to USBD_CFG_MAX_NBR_IF.
USBD_CFG_MAX_NBR_IF_GRP0No interface association needed.
USBD_CFG_MAX_NBR_EP_DESC2 or 4Two bulk endpoints and two optional interrupt endpoints.
USBD_CFG_MAX_NBR_EP_OPEN4 or 6Two control endpoints for the device’s standard requests.
Two bulk endpoints and two optional interrupt endpoints.
USBD_VENDOR_CFG_MAX_NBR_DEV1Only one instance of vendor class is needed.
USBD_VENDOR_CFG_MAX_NBR_CFG1Vendor class instance will only be used in one configuration.


Composite High-Speed USB Device

This device uses Micrium’s PHDC and MSC classes.

Table - Configuration Example of a Composite High-Speed USB Device shows the values that should be set for the different configuration constants described earlier if you build a composite high-speed USB device using Micrium’s PHDC and MSC classes. The structure of this device is described in Figure - Composite High-Speed USB Device Structure.

Figure - Composite High-Speed USB Device Structure

Composite High-Speed USB Device Structure

Table - Configuration Example of a Composite High-Speed USB Device
ConfigurationValueExplanation
USBD_CFG_MAX_NBR_CFG2One configuration for full/low-speed and another for high-speed.
USBD_CFG_MAX_NBR_IF4One interface for PHDC and another for MSC. A different interface for each configuration is also needed.
USBD_CFG_MAX_NBR_IF_ALT4No alternate interface needed, but this value must at least be equal to USBD_CFG_MAX_NBR_IF.
USBD_CFG_MAX_NBR_IF_GRP0No interface association needed.
USBD_CFG_MAX_NBR_EP_DESC4 or 5Two bulk endpoints for MSC.
Two bulk plus one optional interrupt endpoint for PHDC.
USBD_CFG_MAX_NBR_EP_OPEN6 or 7Two control endpoints for device’s standard requests.
Two bulk endpoints for MSC.
Two bulk plus 1 optional interrupt endpoint for PHDC.
USBD_PHDC_CFG_MAX_NBR_DEV1Only one instance of PHDC is needed. It will be shared between all the configurations.
USBD_PHDC_CFG_MAX_NBR_CFG2PHDC instance can be used in both of device’s configurations.
USBD_MSC_CFG_MAX_NBR_DEV1Only one instance of MSC is needed. It will be shared between all the configurations.
USBD_MSC_CFG_MAX_NBR_CFG2MSC instance can be used in both of device’s configurations.


Complex Composite High-Speed USB Device

This device uses an instance of Micrium’s HID class in two different configurations plus a different instance of Micrium’s CDC-ACM class in each configuration. This device also uses an instance of Micrium’s vendor class in the second configuration.

Table - Configuration Example of a Complex Composite High-Speed USB Device shows the values that should be set for the different configuration constants described earlier if you build a composite high-speed USB device using a single instance of Micrium’s HID class in two different configurations plus a different instance of Micrium’s CDC-ACM class in each configuration. The device also uses an instance of Micrium’s vendor class in its second configuration. See Figure - Complex Composite High-Speed USB Device Structure for a graphical description of this USB device.

Figure - Complex Composite High-Speed USB Device Structure

Complex Composite High-Speed USB Device Structure

Table - Configuration Example of a Complex Composite High-Speed USB Device
ConfigurationValueExplanation
USBD_CFG_MAX_NBR_CFG4Two configurations for full/low-speed and two others for high-speed.
USBD_CFG_MAX_NBR_IF7First configuration:
- One interface for HID.
- Two interfaces for CDC-ACM.

Second configuration:
- One interface for HID.
- Two interfaces for CDC-ACM.
- One interface for vendor.
USBD_CFG_MAX_NBR_IF_ALT7No alternate interface needed, but this value must at least be equal to USBD_CFG_MAX_NBR_IF.
USBD_CFG_MAX_NBR_IF_GRP2CDC-ACM needs to group its communication and data interfaces into a single USB function. Since there are two CDC-ACM class instances, there will be two interface groups.
USBD_CFG_MAX_NBR_EP_DESC9, 10, 11 or 12One IN and (optional) OUT interrupt endpoint for HID.
Three endpoints for first CDC-ACM class instance.
Three endpoints for second CDC-ACM class instance.
Two bulk plus two optional interrupt endpoints for vendor.
USBD_CFG_MAX_NBR_EP_OPEN8, 9, 10 or 11In the worst case (host enables second configuration):
Two control endpoints for device’s standard requests.
One IN and (optional) OUT interrupt endpoint for HID.
Three endpoints for second CDC-ACM class instance.
Two bulk plus two optional interrupt endpoints for vendor.
USBD_HID_CFG_MAX_NBR_DEV1Only one instance of HID class is needed. It will be shared between all the configurations.
USBD_HID_CFG_MAX_NBR_CFG4HID class instance can be used in all of device’s configurations.
USBD_CDC_CFG_MAX_NBR_DEV2Two CDC base class instances are used.
USBD_CDC_CFG_MAX_NBR_CFG2Each CDC base class instance can be used in one full-speed and one high-speed configuration.
USBD_ACM_SERIAL_CFG_MAX_NBR_DEV2Two ACM subclass instances are used.
USBD_VENDOR_CFG_MAX_NBR_DEV1Only one vendor class instance is used.
USBD_VENDOR_CFG_MAX_NBR_CFG2The vendor class instance can be used in one full-speed and one high-speed configuration.