USB Device Configuration

This section discusses how to configure Silicon Labs USB Device. There are three groups of configuration parameters, as follows:

USB Device Core Configuration

Silicon Labs USB Device can be configured at compile time via a set of #defines located in the sl_usbd_core_config.h file. USB Device uses #defines when possible because they allow code and data sizes to be scaled at compile time based on which features are enabled. This allows the read-only memory (ROM) and random-access memory (RAM) footprints of Silicon Labs USB Device to be adjusted based on your application's requirements.

Recommended : Start the configuration process with the default values (highlighted in bold ).

The sections below are organized based on the order in the template configuration file, sl_usbd_core_config.h.

Core Configuration

Table - USB Device Core Configuration Constants
Constant Description Default Value
SL_USBD_TASK_STACK_SIZE Configures the stack size in bytes of USBD core task 4096
SL_USBD_TASK_PRIORITY Configures the priority of USBD core task. This is a CMSIS-RTOS2 priority . osPriorityHigh
SL_USBD_AUTO_START_USB_DEVICE If enabled, the USB device will be automatically started once the kernel is started and that USBD core task is scheduled for the first time. If disabled, your application will need to call sl_usbd_core_start_device() when ready to be detected by the USB host. 1
SL_USBD_CONFIGURATION_QUANTITY The total number of configurations that will be added via the sl_usbd_add_configuration() function. 1
SL_USBD_INTERFACE_QUANTITY The total number of USB interfaces to be added for all your configurations. This greatly depends on the class(es) used. For more information on how many interfaces a class instance requires, refer to the section "Resource Needs from core" of your class(es). 10
SL_USBD_ALT_INTERFACE_QUANTITY The total number of USB alternate interfaces to be added for all your configurations. This greatly depends on the class(es) used. This value must always be equal or greater than SL_USBD_INTERFACE_QUANTITY . For more information on how many alternate interfaces a class instance requires, refer to the section "Resource Needs from Core" of your class(es). 10
SL_USBD_INTERFACE_GROUP_QUANTITY The total number of USB interface groups that will be added for all your configurations. This greatly depends on the class(es) used. For more information on how many interface groups requires a class instance, refer to the section "Resource Needs from Core" of your class(es). 2
SL_USBD_DESCRIPTOR_QUANTITY The total number of Endpoint descriptors that will be added for all your configurations. This greatly depends on the class(es) used. For more information on how many endpoint descriptors a class instance requires, refer to "Number of endpoints" in the section "Resource Needs from Core" of your class(es). Note that the control endpoints don't need to be considered here. 20
SL_USBD_STRING_QUANTITY The total number of USB strings. Setting the quantity to zero will disable the feature. Disabling this will cause the device to not store any USB description strings passed from the application. This means the host will be unable to retrieve the description strings (such as manufacturer and product name). 30
SL_USBD_OPEN_ENDPOINTS_QUANTITY The total number of opened endpoints per configuration. A device requires at least two opened endpoints for control transfers, but you must also add the endpoints of the class(es) used. For more information on how many opened endpoints a class instance requires, refer to "Number of endpoints" in the section "Resource Needs from Core" of your class(es). 20

Classes Configuration

Classes have specific compile-time configurations. Refer to USB Device Classes for more information.

USB Device Information Configuration

The sl_usbd_device_config.h configuration file regroups compile-time #define-s to set basic information regarding your device, such as Vendor/Product ID, device strings, etc.

The table below describes each information configuration define available in this configuration file.

Table - USB Device Information Configuration Defines
Constant Description
SL_USBD_DEVICE_VENDOR_ID Your vendor identification number as delivered by the USB Implementers Forum. For more information on how you can obtain a vendor ID, see http://www.usb.org/developers/vendor/ .
SL_USBD_DEVICE_PRODUCT_ID Your product identification number.
SL_USBD_DEVICE_RELEASE_NUMBER Release number of your device.
SL_USBD_DEVICE_MANUFACTURER_STRING String describing the manufacturer of your device. This configuration is ignored when the configuration SL_USBD_STRING_QUANTITY is set to 0.
SL_USBD_DEVICE_PRODUCT_STRING String describing your product. This configuration is ignored when the configuration SL_USBD_STRING_QUANTITY is set to 0.
SL_USBD_DEVICE_SERIAL_NUMBER_STRING String containing the serial number of your device. This configuration is ignored when the configuration SL_USBD_STRING_QUANTITY is set to 0.
SL_USBD_DEVICE_LANGUAGE_ID Identification number of the language of your device's strings. Possible values are:
- SL_USBD_LANG_ID_ARABIC_SAUDI_ARABIA
- SL_USBD_LANG_ID_CHINESE_TAIWAN
- SL_USBD_LANG_ID_ENGLISH_US
- SL_USBD_LANG_ID_ENGLISH_UK
- SL_USBD_LANG_ID_FRENCH
- SL_USBD_LANG_ID_GERMAN
- SL_USBD_LANG_ID_GREEK
- SL_USBD_LANG_ID_ITALIAN
- SL_USBD_LANG_ID_PORTUGUESE
- SL_USBD_LANG_ID_SANSKRIT
This configuration is ignored when the configuration SL_USBD_STRING_QUANTITY is set to 0.

USB Device Hardware Configuration

Depending on the Silicon Labs device you are using, you will possibly have the GPIO pin and port to configure for USB VBUS Sense signal. The configuration defines are in the sl_usbd_hardware_config.h header file.

Constant Description
SL_USBD_DRIVER_VBUS_SENSE_PORT GPIO Port for the USB VBUS Sense signal on your board.
SL_USBD_DRIVER_VBUS_SENSE_PIN GPIO Pin for the USB VBUS Sense signal on your board.