主题中讨论的其他器件:EK-TM4C1294XL、 TM4C123
您好!
我必须为123GX LaunchPad 运行 USB 项目、并且试着将这两个 USB 项目组合成一个复合器件。 阅读了几天的文档和 usblib 源代码后、我遇到了看起来存在冲突的信息-或者我很困惑。
我在这里看到 usblib 用户指南说您需要支持3个有道理的字符串(如下所示):

但当我查看源代码时、它需要的不止这些。 请参见下方的。
//
//! A pointer to the string descriptor array for this device. This array
//! must contain the following string descriptor pointers in this order.
//! Language descriptor, Manufacturer name string (language 1), Product
//! name string (language 1), Serial number string (language 1), Composite
//! device interface description string (language 1), Configuration
//! description string (language 1).
//!
//! If supporting more than 1 language, the descriptor block (except for
//! string descriptor 0) must be repeated for each language defined in the
//! language descriptor.
//!
//
const uint8_t * const *ppui8StringDescriptors;
//
//! The number of descriptors provided in the ppStringDescriptors
//! array. This must be 1 + ((5 + (number of strings)) *
//! (number of languages)).
//
const uint32_t ui32NumStringDescriptors;
上述用户指南屏幕截图和源代码片段涉及如下所示的复合器件结构(可在 usbdcomp.h 中找到)的一部分:

在 usbdcomp.h 中找到的完整结构源
//*****************************************************************************
//
//! The structure used by the application to define operating parameters for
//! the composite device class.
//
//*****************************************************************************
typedef struct
{
//
//! The vendor ID that this device is to present in the device descriptor.
//
const uint16_t ui16VID;
//
//! The product ID that this device is to present in the device descriptor.
//
const uint16_t ui16PID;
//
//! The maximum power consumption of the device, expressed in mA.
//
const uint16_t ui16MaxPowermA;
//
//! Indicates whether the device is self or bus-powered and whether or not
//! it supports remote wake up. Valid values are \b USB_CONF_ATTR_SELF_PWR
//! or \b USB_CONF_ATTR_BUS_PWR, optionally ORed with
//! \b USB_CONF_ATTR_RWAKE.
//
const uint8_t ui8PwrAttributes;
//
//! A pointer to the callback function which will be called to notify
//! the application of events relating to the operation of the composite
//! device.
//
const tUSBCallback pfnCallback;
//
//! A pointer to the string descriptor array for this device. This array
//! must contain the following string descriptor pointers in this order.
//! Language descriptor, Manufacturer name string (language 1), Product
//! name string (language 1), Serial number string (language 1), Composite
//! device interface description string (language 1), Configuration
//! description string (language 1).
//!
//! If supporting more than 1 language, the descriptor block (except for
//! string descriptor 0) must be repeated for each language defined in the
//! language descriptor.
//!
//
const uint8_t * const *ppui8StringDescriptors;
//
//! The number of descriptors provided in the ppStringDescriptors
//! array. This must be 1 + ((5 + (number of strings)) *
//! (number of languages)).
//
const uint32_t ui32NumStringDescriptors;
//
//! The number of devices in the psDevices array.
//
const uint32_t ui32NumDevices;
//
//! This application supplied array holds the the top level device class
//! information as well as the Instance data for that class.
//
tCompositeEntry * const psDevices;
//
//! The private data for this device instance. This memory must remain
//! accessible for as long as the composite device is in use and must
//! not be modified by any code outside the composite class driver.
//
tCompositeInstance sPrivateData;
}
tUSBDCompositeDevice;
Question:
1.我应该只遵循结构源代码中的注释,字符串 desc 指针,说明以下是必需的{language desc, manf name string, product name str, serial num string, composition dev interface desc string, configuration desc string}? 我提出这个问题、因为这超出了用户指南所说的数量。
2.字符串应该是什么格式? 下面显示了一个 hid 字符串描述符示例。 我是否应该复制粘贴这些内容并只更改复合字符串的内容?
//*****************************************************************************
//
// The languages supported by this device.
//
//*****************************************************************************
const uint8_t g_pui8LangDescriptor[] =
{
4,
USB_DTYPE_STRING,
USBShort(USB_LANG_EN_US)
};
//*****************************************************************************
//
// The manufacturer string.
//
//*****************************************************************************
const uint8_t g_pui8ManufacturerString[] =
{
(17 + 1) * 2,
USB_DTYPE_STRING,
'T', 0, 'e', 0, 'x', 0, 'a', 0, 's', 0, ' ', 0, 'I', 0, 'n', 0, 's', 0,
't', 0, 'r', 0, 'u', 0, 'm', 0, 'e', 0, 'n', 0, 't', 0, 's', 0,
};
//*****************************************************************************
//
// The product string.
//
//*****************************************************************************
const uint8_t g_pui8ProductString[] =
{
(19 + 1) * 2,
USB_DTYPE_STRING,
'G', 0, 'e', 0, 'n', 0, 'e', 0, 'r', 0, 'i', 0, 'c', 0, ' ', 0, 'B', 0,
'u', 0, 'l', 0, 'k', 0, ' ', 0, 'D', 0, 'e', 0, 'v', 0, 'i', 0, 'c', 0,
'e', 0
};
//*****************************************************************************
//
// The data interface description string.
//
//*****************************************************************************
const uint8_t g_pui8DataInterfaceString[] =
{
(19 + 1) * 2,
USB_DTYPE_STRING,
'B', 0, 'u', 0, 'l', 0, 'k', 0, ' ', 0, 'D', 0, 'a', 0, 't', 0,
'a', 0, ' ', 0, 'I', 0, 'n', 0, 't', 0, 'e', 0, 'r', 0, 'f', 0,
'a', 0, 'c', 0, 'e', 0
};
//*****************************************************************************
//
// The configuration description string.
//
//*****************************************************************************
const uint8_t g_pui8ConfigString[] =
{
(23 + 1) * 2,
USB_DTYPE_STRING,
'B', 0, 'u', 0, 'l', 0, 'k', 0, ' ', 0, 'D', 0, 'a', 0, 't', 0,
'a', 0, ' ', 0, 'C', 0, 'o', 0, 'n', 0, 'f', 0, 'i', 0, 'g', 0,
'u', 0, 'r', 0, 'a', 0, 't', 0, 'i', 0, 'o', 0, 'n', 0
};
结构中的注释听起来几乎像以下指向这些字符串的指针。
//*****************************************************************************
//
// The descriptor string table.
//
//*****************************************************************************
const uint8_t * const g_ppui8StringDescriptors[] =
{
g_pui8LangDescriptor,
g_pui8ManufacturerString,
g_pui8ProductString,
g_pui8SerialNumberString,
g_pui8DataInterfaceString,
g_pui8ConfigString
};
3. 对于"字符串数"字段(ppui8StringDescriptors 指针) ,结构源说明如下:
//
//! The number of descriptors provided in the ppStringDescriptors
//! array. This must be 1 + ((5 + (number of strings)) *
//! (number of languages)).
//
const uint32_t ui32NumStringDescriptors;
那么、哪些字符串会计入该等式的"字符串数"部分? 前面的幻灯片中提到的所有
const uint8_t * const *ppui8StringDescriptors;
4、 通过 HID-Bulk 设备结构时,是否通过标准结构? 我注意到该示例使用了我不使用的缓冲器吗? 我的两个器件接口仅使用 USBLIB 的标准结构。 例如、我的批量项目中正在工作的批量器件接口仅使用以下结构-我删除了示例项目附带的缓冲支持。
//*****************************************************************************
//
//! The structure used by the application to define operating parameters for
//! the bulk device.
//
//*****************************************************************************
typedef struct
{
//
//! The vendor ID that this device is to present in the device descriptor.
//
const uint16_t ui16VID;
//
//! The product ID that this device is to present in the device descriptor.
//
const uint16_t ui16PID;
//
//! The maximum power consumption of the device, expressed in milliamps.
//
const uint16_t ui16MaxPowermA;
//
//! Indicates whether the device is self- or bus-powered and whether or not
//! it supports remote wakeup. Valid values are USB_CONF_ATTR_SELF_PWR or
//! USB_CONF_ATTR_BUS_PWR, optionally ORed with USB_CONF_ATTR_RWAKE.
//
const uint8_t ui8PwrAttributes;
//
//! A pointer to the callback function which will be called to notify
//! the application of events related to the device's data receive channel.
//
const tUSBCallback pfnRxCallback;
//
//! A client-supplied pointer which will be sent as the first
//! parameter in all calls made to the receive channel callback,
//! pfnRxCallback.
//
void *pvRxCBData;
//
//! A pointer to the callback function which will be called to notify
//! the application of events related to the device's data transmit
//! channel.
//
const tUSBCallback pfnTxCallback;
//
//! A client-supplied pointer which will be sent as the first
//! parameter in all calls made to the transmit channel callback,
//! pfnTxCallback.
//
void *pvTxCBData;
//
//! A pointer to the string descriptor array for this device. This array
//! must contain pointers to the following string descriptors in this
//! order. Language descriptor, Manufacturer name string (language 1),
//! Product name string (language 1), Serial number string (language 1),
//! Interface description string (language 1) and Configuration description
//! string (language 1).
//!
//! If supporting more than 1 language, the strings for indices 1 through 5
//! must be repeated for each of the other languages defined in the
//! language descriptor.
//
const uint8_t * const *ppui8StringDescriptors;
//
//! The number of descriptors provided in the ppStringDescriptors array.
//! This must be 1 + (5 * number of supported languages).
//
const uint32_t ui32NumStringDescriptors;
//
//! The private instance data for this device. This memory must
//! not be modified by any code outside the bulk class driver.
//
tBulkInstance sPrivateData;
}
tUSBDBulkDevice;
可以吗、因为看起来用户指南示例向 CDC 器件传递了我在批量示例中不再使用的缓冲器和东西。


