cancel
Showing results for 
Search instead for 
Did you mean: 

STM32C071 USBX CustomHID Example

Gregster
Associate II

Hello everyone,

I am looking for a solution for a CustomHID device on a STM32C071.
I would like to implement a CustomHID device, with TreadX and USBX.
Unfortunately I can only find examples for mice in the templates. It is a bit difficult to deduce a CustomHID from these.

The tutorials I have looked at so far have not helped me either.
I already have experience with the “old” USB_Device library (also CustomHID) from STM in conjunction with FreeRTOS.
On the STM32C071 I already got TreadX to work, but when I try to implement CustomHID, nothing works anymore.
Unfortunately I can't find any information on what to look out for when implementing a CustomHID on an STM.

Does anyone have any idea where I can find information on this problem?
A tutorial would be great, but I haven't found one yet.

Greetings Greg

1 REPLY 1
ahsrabrifat
Senior II

 

Inside the USBX stack:
Find and replace the HID report descriptor. It's usually defined like this (for the mouse)

static UCHAR hid_report_descriptor[] = {
    // Mouse descriptor...
};

 

Replace it with your custom HID descriptor. For example, if you want a simple 64-byte IN and OUT report:

 

 
 
static UCHAR hid_report_descriptor[] = {
0x06, 0x00, 0xFF, // Usage Page (Vendor Defined)
0x09, 0x01, // Usage (Vendor Usage 1)
0xA1, 0x01, // Collection (Application)
0x15, 0x00, // Logical Minimum (0)
0x26, 0xFF, 0x00, // Logical Maximum (255)
0x75, 0x08, // Report Size (8)
0x95, 0x40, // Report Count (64)
0x09, 0x01, // Usage (Vendor Usage 1)
0x81, 0x02, // Input (Data, Var, Abs)
0x09, 0x01, // Usage (Vendor Usage 1)
0x91, 0x02, // Output (Data, Var, Abs)
0xC0 // End Collection
};

 Update the descriptor pointer in the HID class initialization structure.