cancel
Showing results for 
Search instead for 
Did you mean: 

STM32 HAL USB HID Feature Report

TWu.5
Associate II

Hi all

I already follow the STM32 USB training ,

I use Custom HID Device , and my report descriptor like bellow

__ALIGN_BEGIN static uint8_t CUSTOM_HID_ReportDesc_FS[USBD_CUSTOM_HID_REPORT_DESC_SIZE] __ALIGN_END =
{
  /* USER CODE BEGIN 0 */
	0x06, 0x00, 0xff,               //Usage Page(Undefined )
	    0x09, 0x01,                    // USAGE (Undefined)
	    0xa1, 0x01,                    // COLLECTION (Application)
		
	    0x15, 0x00,                    //   LOGICAL_MINIMUM (0)
	    0x26, 0xff, 0x00,              //   LOGICAL_MAXIMUM (255)
	    0x75, 0x08,                    //   REPORT_SIZE (8)
	
           //Report ID
	    0x85,0x02,                     // REPORT_ID(2)
	    0x95, 0x08,                    //   REPORT_COUNT (8))
	    0x09, 0x01,                    //   USAGE (Undefined)
	    0x81, 0x02,                    //   INPUT (Data,Var,Abs)
		
	    0x95, 0x40,                    //   REPORT_COUNT (64)
	    0x09, 0x01,                    //   USAGE (Undefined)
	    0x91, 0x02,                    //   OUTPUT (Data,Var,Abs)
	
	    0x95, 0x01,                    //   REPORT_COUNT (1)
	    0x09, 0x01,                    //   USAGE (Undefined)
	    0xb1, 0x02,                    //   FEATURE (Data,Var,Abs)
  /* USER CODE END 0 */
  0xC0    /*     END_COLLECTION	             */
};

How can I Get or Set my custom Feature Report via Endpoint 0

or is there any sample code can provide for reference ?

thanks a lot

3 REPLIES 3
Lubos KOUDELKA
ST Employee

Hello,

STM32Cube USB libraries for customHID use interrupt endpoint 1 and there would need to be quite a lot modification in the project to use control endpoint 0. What is your motivation to use endpoint 0 instead of endpoint 1?

Because the Customer offer the product spec, include HID Report Descriptor , it contains many FEATURE Report with different report id,

just like bellow

Usage Page(Digitizers)
Usage(Pen)
Collection(Application)
    Report ID(2)
    Usage(Stylus)
    Collection(Physical)
        Usage (Tip Switch)
        Usage (Barrel Switch)
        Usage (Eraser Switch)
        Usage (Invert)
        Usage (Secondary Barrel Switch)
        Usage (In Range)
        Logical Minimum(0)
        Logical Maximum(1)
       Report Size(1)
       Report Count(6)
       Input (Data, Variable, Absolute)
       Report Count(2)
       Input(Const, Variable)
       Usage Page(Generic Desktop)
       Usage(X)
       Logical Maximum(29700)
       Physical Maximum(29700)
       Unit(SI Lin:Distance)
       Unit Exponent(-2)
       Report Size(16)
       Report Count(1)
       Input (Data, Variable, Absolute)
       Usage(Y)
       Logical Maximum(21600)
       Physical Maximum(21600)
       Input (Data, Variable, Absolute)
       Physical Maximum(0)
       Unit(None)
       Unit Exponent(0)
       Usage Page(Digitizers)
       Usage(Tip Pressure)
       Logical Maximum(2047)
       Input (Data, Variable, Absolute)
    End Collection
Usage (Undefiend)
Report Size(8)
Feature(data, var, abs)
Report ID(3)
Usage (Undefiend)
Report Count(16)
Feature(data, var, abs)
Report ID(4)
Usage (Undefiend)
Feature(data, var, abs)
End Collection

Lubos KOUDELKA
ST Employee

Thank you for more details, but still not shows why usage of EP0 should be necessary. I think you can use EP1 (or any other non-control endpoint) as well. EP0 usage you would need to modify by yourself.