How to creat a USB HID Custom descriptor for usbx?

明泉 张 20 Reputation points
2023-09-18T08:19:51.05+00:00

Hi,

While i am using the threadx and usbx to develop our products, a problem occurred. We are using ST IC as a USB HID custom device to report data to the Host(PC). The descriptor is created refferring to the USB HID Descriptor standard. The problem is that first i send a package of data to Host(PC), after waiting a moment(set as Time_interval) send another package of data to Host. If the Time_interval is less than about 5s, Host(PC) could receive the data successfully, otherwise, Host couldnot receive the data from the device. After reviewing the project, we tried the standard mouse descriptor. The problem didn't recurrence. The following array is the descriptor that we use in our project:

unsigned char USB_CustomHID_ReportDesc[] =
{ 
    0x06, 0x00, 0xff,              // USAGE_PAGE (Vendor Defined Page 1)
    0x09, 0x01,                    // USAGE (Vendor Usage 1)
    0xa1, 0x01,                    // COLLECTION (Application)
    0x09, 0x01,                    //   USAGE (Vendor Usage 1)
    0x15, 0x00,                    //   LOGICAL_MINIMUM (0)
    0x26, 0xff, 0x00,              //   LOGICAL_MAXIMUM (255)
    0x95, 0x40,                    //   REPORT_COUNT (64)
    0x75, 0x08,                    //   REPORT_SIZE (8)
    0x81, 0x02,                    //   INPUT (Data,Var,Abs)
    0x09, 0x01,                    //   USAGE (Vendor Usage 1)
    0x15, 0x00,                    //   LOGICAL_MINIMUM (0)
    0x26, 0xff, 0x00,              //   LOGICAL_MAXIMUM (255)
    0x95, 0x40,                    //   REPORT_COUNT (64)
    0x75, 0x08,                    //   REPORT_SIZE (8)
    0x91, 0x02,                    //   OUTPUT (Data,Var,Abs)
    0xc0						   // End Collection
}

Could you please tell me if there are some issues that i should consider in usbx?

Azure RTOS
Azure RTOS
An Azure embedded development suite including a small but powerful operating system for resource-constrained devices.
324 questions
{count} votes

Accepted answer
  1. Chaoqiong Xiao 486 Reputation points Microsoft Employee
    2023-09-21T05:18:22.2166667+00:00

    It seems on host side the device is put to suspend after there is nothing returned for a period of time.

    To avoid:

    From host side it may use SET_IDLE to set idle rate, when the idle rate period timeout, the device should send packet even there is nothing changed.

    From device side the easiest way to avoid suspend could be send last packet in specific rate (that's what is done when idle rate is used) to host to keep bus active.

    In general, if a device wants to support remote wakeup, it should have its ConfigurationDescriptor::bmAttributes.D5 set to 1 to inform host it supports remote wakeup. Before suspend device, host issues SetDeviceFeature with remote wakeup enabled to enable remote wakeup, then when device wants to wakeup it issues REMOTE WAKEUP on bus to inform host it should be resumed from suspended state. After host resume the port, ClearDeviceFeature with remote wakeup disabled should be sent by host to disable remote wakeup.


0 additional answers

Sort by: Most helpful