cancel
Showing results for 
Search instead for 
Did you mean: 

Custom hid input report descriptor

MHovi.1
Associate II

Hi folks,

I have a stm32f411 with custom hid running smoothly. But if i change a value in the report descriptor data transmission stops working.

I want to change the descriptor cause i want to send more data to the host.

Here is the descriptor which works

char ReportDescriptor[58] = {
    0x05, 0x01,                    // USAGE_PAGE (Generic Desktop)
    0x09, 0x04,                    // USAGE (Joystick)
    0xa1, 0x01,                    // COLLECTION (Application)
    0x05, 0x01,                    //   USAGE_PAGE (Generic Desktop)
    0x09, 0x30,                    //   USAGE (X)
    0x09, 0x31,                    //   USAGE (Y)
    0x15, 0x00,                    //   LOGICAL_MINIMUM (0)
    0x27, 0xff, 0xff, 0x00, 0x00,  //   LOGICAL_MAXIMUM (65535)
    0x75, 0x10,                    //   REPORT_SIZE (16)
    0x95, 0x02,                    //   REPORT_COUNT (2)
    0x81, 0x02,                    //   INPUT (Data,Var,Abs)
    0x05, 0x09,                    //   USAGE_PAGE (Button)
    0x19, 0x01,                    //   USAGE_MINIMUM (Button 1)
    0x29, 0x20,                    //   USAGE_MAXIMUM (Button 32)
    0x15, 0x00,                    //   LOGICAL_MINIMUM (0)
    0x25, 0x01,                    //   LOGICAL_MAXIMUM (1)
    0x75, 0x01,                    //   REPORT_SIZE (1)
    0x95, 0x20,                    //   REPORT_COUNT (32)
    0x81, 0x02,                    //   INPUT (Data,Var,Abs)
    0x09, 0x00,                    //   USAGE (Undefined)
    0x75, 0x08,                    //   REPORT_SIZE (8)
    0x95, 0x14,                    //   REPORT_COUNT (20)
    0x81, 0x02,                    //   INPUT (Data,Var,Abs)
    0x09, 0x00,                    //   USAGE (Undefined)
    0x75, 0x08,                    //   REPORT_SIZE (8)
    0x95, 0x40,                    //   REPORT_COUNT (64)
    0x91, 0x02,                    //   OUTPUT (Data,Var,Abs)
    0xc0                           // END_COLLECTION

Using the USB demo tool tells me the input report byte length is 29

0693W00000Dq1vxQAB.pngNow i want to crank this to the maximum which according to my knowledge is 64 bytes.

If i change the report count in the following line to 35 that should make a input report byte length of 64 in total.

0x09, 0x00,          //  USAGE (Undefined)

  0x75, 0x08,          //  REPORT_SIZE (8)

  0x95, 0x14,          //  REPORT_COUNT (20)

  0x81, 0x02,          //  INPUT (Data,Var,Abs)

Unfortunately a report count of 35 hangs the data transmission.

I sure can need some advice on what i am doing wrong or where it goes wrong.

Thanks in advance

Martijn

1 REPLY 1
MHovi.1
Associate II

Here some related additional info,

usbd_conf.h

/*---------- -----------*/
#define USBD_MAX_NUM_INTERFACES     1U
/*---------- -----------*/
#define USBD_MAX_NUM_CONFIGURATION     1U
/*---------- -----------*/
#define USBD_MAX_STR_DESC_SIZ     512U
/*---------- -----------*/
#define USBD_DEBUG_LEVEL     0U
/*---------- -----------*/
#define USBD_LPM_ENABLED     0U
/*---------- -----------*/
#define USBD_SELF_POWERED     1U
/*---------- -----------*/
#define USBD_CUSTOMHID_OUTREPORT_BUF_SIZE     64U
/*---------- -----------*/
#define USBD_CUSTOM_HID_REPORT_DESC_SIZE     58U
/*---------- -----------*/
#define CUSTOM_HID_FS_BINTERVAL     0x01U//0x5U
 
/****************************************/
/* #define for FS and HS identification */
#define DEVICE_FS 		0
#define DEVICE_HS 		1

and the usbd_customhid.h

#define CUSTOM_HID_EPIN_ADDR                         0x81U
 
#ifndef CUSTOM_HID_EPIN_SIZE
#define CUSTOM_HID_EPIN_SIZE                         0x40U
#endif
 
#define CUSTOM_HID_EPOUT_ADDR                        0x01U
 
#ifndef CUSTOM_HID_EPOUT_SIZE
#define CUSTOM_HID_EPOUT_SIZE                        0x40U
#endif
 
#define USB_CUSTOM_HID_CONFIG_DESC_SIZ               41U
#define USB_CUSTOM_HID_DESC_SIZ                      9U
 
#ifndef CUSTOM_HID_HS_BINTERVAL
#define CUSTOM_HID_HS_BINTERVAL                      0x05U
#endif /* CUSTOM_HID_HS_BINTERVAL */
 
#ifndef CUSTOM_HID_FS_BINTERVAL
#define CUSTOM_HID_FS_BINTERVAL                      0x01U
#endif /* CUSTOM_HID_FS_BINTERVAL */
 
#ifndef USBD_CUSTOMHID_OUTREPORT_BUF_SIZE
#define USBD_CUSTOMHID_OUTREPORT_BUF_SIZE            0x40U
#endif /* USBD_CUSTOMHID_OUTREPORT_BUF_SIZE */
 
#ifndef USBD_CUSTOM_HID_REPORT_DESC_SIZE
#define USBD_CUSTOM_HID_REPORT_DESC_SIZE             58
U
#endif /* USBD_CUSTOM_HID_REPORT_DESC_SIZE */
 
#define CUSTOM_HID_DESCRIPTOR_TYPE                   0x21U
#define CUSTOM_HID_REPORT_DESC                       0x22U
 
#define CUSTOM_HID_REQ_SET_PROTOCOL                  0x0BU
#define CUSTOM_HID_REQ_GET_PROTOCOL                  0x03U
 
#define CUSTOM_HID_REQ_SET_IDLE                      0x0AU
#define CUSTOM_HID_REQ_GET_IDLE                      0x02U
 
#define CUSTOM_HID_REQ_SET_REPORT                    0x09U
#define CUSTOM_HID_REQ_GET_REPORT                    0x01U