Skip to end of metadata
Go to start of metadata

This section describes USB device driver configuration. Each newly-added device has an individual configuration, which is specified at run-time.

To add a USB device, you must call the USBD_DevAdd() function. This call requires four configurations arguments, which are described below.

p_task_cfg

Each USB device has a kernel task associated with it. p_task_cfg is a pointer to a configuration structure of type RTOS_TASK_CFG that allows you to configure the priority, stack base pointer, and stack size (in quantity of stack elements) for that task. 

Guidelines on How to Properly Set the Priority and Stack Size

Task Priorities

The priority of a USB device’s task greatly depends on the requirements of your application. If your application requires a lot of tasks and is CPU intensive, it may be best to set the device task to a high priority; otherwise, the task might not be able to process the bus and control requests on time. On the other hand, if you plan on using asynchronous communication, and data throughput is not a priority, you might want to give the core task a low priority.

Task Stack Sizes

A stack size of 1024 is a good starting point for most applications.

Refer to this page for more information on how to properly set the stack size.

p_dev_cfg

p_dev_cfg is a pointer to a configuration structure of type USBD_DEV_CFG. Its purpose is to give the USB device module basic information regarding your device, such as Vendor/Product ID, device strings, etc.

Table - USBD_DEV_CFG configuration structure describes each configuration field available in this configuration structure.

FieldDescription
.VendorIDYour 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/.
.ProductIDYour product identification number.
.DeviceBCDRelease number of your device.
.ManufacturerStrPtr

Pointer to a string describing the manufacturer of your device. 

This configuration is ignored when the configuration USBD_CFG_STR_EN is set to  DEF_DISABLED .
.ProductStrPtr

Pointer to a string describing your product. 

This configuration is ignored when the configuration USBD_CFG_STR_EN is set to DEF_DISABLED.
.SerialNbrStrPtr

Pointer to a string containing the serial number of your device. 

This configuration is ignored when the configuration USBD_CFG_STR_EN is set to DEF_DISABLED.
.LangId

Identification number of the language of your device's strings.

Possible values are:

  • USBD_LANG_ID_ARABIC_SAUDI_ARABIA
  • USBD_LANG_ID_CHINESE_TAIWAN
  • USBD_LANG_ID_ENGLISH_US
  • USBD_LANG_ID_ENGLISH_UK
  • USBD_LANG_ID_FRENCH
  • USBD_LANG_ID_GERMAN
  • USBD_LANG_ID_GREEK
  • USBD_LANG_ID_ITALIAN
  • USBD_LANG_ID_PORTUGUESE
  • USBD_LANG_ID_SANSKRIT
This configuration is ignored when the configuration USBD_CFG_STR_EN is set to DEF_DISABLED.
Table - USBD_DEV_CFG configuration structure

p_dev_drv_cfg

p_dev_drv_cfg is a pointer to a configuration structure of type USBD_DEV_DRV_CFG. Its purpose is to give the USB device controller driver associated with your device basic information regarding the number of resources to allocate.

Table - USBD_DEV_DRV_CFG configuration structure describes each configuration field available in this configuration structure.

FieldDescription
.EP_OpenQtyMaximum number of endpoints that can be opened at any time on this device.
.URB_ExtraQty

Number of extra URB to allocate for this device.

This configuration is ignored when the configuration USBD_CFG_URB_EXTRA_EN is set to DEF_DISABLED.
Table - USBD_DEV_DRV_CFG configuration structure

p_bus_fnct

p_bus_cfg is a pointer to a configuration structure of type USBD_BUS_FNCTS. Its purpose is to give the USB device module a set of optional callback functions to be called when a bus event occurs.

A null pointer (DEF_NULL) can be passed to this argument if no callbacks are needed.

Table - USBD_BUS_FNCTS configuration structure describes each configuration field available in this configuration structure.

FieldDescriptionFunction signature
.ResetFunction called when a reset signal is received from the host.void  Reset  (CPU_INT08U  dev_nbr)
.SuspendFunction called when the device is suspended by the host.void  Suspend(CPU_INT08U  dev_nbr)
.ResumeFunction called when a resume signal is received from the host.void  Resume (CPU_INT08U  dev_nbr)
.CfgSetFunction called when a configuration has been set by the host.void  CfgSet (CPU_INT08U  dev_nbr, CPU_INT08U  cfg_val)
.CfgClrFunction called when a configuration has been cleared by the host.void  CfgClr (CPU_INT08U  dev_nbr, CPU_INT08U  cfg_val)
.ConnFunction called when the device has been connected.void  Conn   (CPU_INT08U  dev_nbr)
.DisconnFunction called when the device has been disconnected.void  Disconn(CPU_INT08U  dev_nbr)
Table - USBD_BUS_FNCTS configuration structure
  • No labels