Configuration of the USB Device Core.
Configuration of the USB Device Core.
The configuration file USBD_Config_n.h contains generic settings for the USB Device and parameters that are necessary to create USB Descriptors . Some parts of the USB descriptors are configured in the respective device class configuration files (USBD_Config_ADC.h, USBD_Config_CDC.h, USBD_Config_CustomClass.h, USBD_Config_HID.h and USBD_Config_MSC.h).
USB Device Core Configuration File
The configuration file USBD_Config_n.h contains the following settings:
- Connect to hardware via Driver_USBD# sets the CMSIS-Driver Number to be used (according to the selected USB controller). For devices with single USB Device Controller it will typically be '0'.
- High-Speed may be selected if supported by the USB controller.
- Device Settings are used to create the Device Descriptor.
- Max Endpoint 0 Packet Size sets the maximum packet size for Endpoint 0.
- The Vendor ID (VID) needs to be set to a private VID. The default Vendor ID is owned by Keil and must not be used for actual products. Please visit USB-IF for more information on how to apply for a valid Vendor ID.
- Every device variant needs an unique Product ID. Together with the VID, it is used by the Host computer's operating system to find a driver for your device.
- The Device Release Number will be shown in Windows and Linux systems as “Firmware Revision”. The number will be interpreted as “binary coded decimal”, meaning that 0x0101 will be shown as firmware revision 1.01.
- Configuration Settings are used to create the Configuration Descriptor.
- Power determines whether the device is self- or bus-powered.
- Enable Remote Wakeup if the device supports a remote wakeup functionality.
- Maximum Power Consumption (in mA) advertises the maximum current drawn from the bus in this specific configuration when the USB Device is fully operational.
- String Settings are used to create the string descriptor within the Device Descriptor.
- Language ID set the product's language.
- Manufacturer String describes the product's manufacturer.
- Product String describes the product.
- Enable Serial Number String to be able to assign a serial number string to the product.
- Default value describes the device's default serial number string when enabled.
- Maximum Length (in characters) describes the maximum number of serial number string characters that can be set at run-time.
- Microsoft OS Descriptor Settings are used to create the Microsoft OS Descriptors.
- Enable OS String for device to contain Microsoft OS string descriptor.
- Vendor Code specifies the vendor code used to retrieve associated feature descriptors.
- Control Transfer Buffer Size specifies the maximum size of control transfer.
- Data Buffers is used for locating the USB data buffers in memory.
- Locate specifies if the USB data buffers are located in a specific memory (via the linker script). This is usually necessary in case that USB Controller has some specific requirements regarding memory for USB transfers. For example if USB Controller can only access specific memory, or if this memory needs to be non-cacheable.
- Section Name specifies the section name for the USB data buffers that is used by the linker script to position it in memory. Default section name is
.driver.usbd<instance>
, for example for USB Device 0 the default section name is .driver.usbd0
.
- Use the OS Resources Settings to optimize the usage of OS resources.
- The default Core Thread Stack Size is 1024 bytes.
- The default Core Thread priority is osPriorityAboveNormal. This priority can be changed by changing USBDn_CORE_THREAD_PRIORITY define in this configuration file. This priority needs to be high enough so that USB Stack can react to USB events in a timely manner. Due to this requirement it is recommended to keep this setting at default.