cancel
Showing results for 
Search instead for 
Did you mean: 

USB HID descriptor (problem with report id)

idealsim
Associate II
Posted on June 03, 2015 at 22:42

Hi, i'm trying to use USB device HID with a stm32F4 For this i modified the example give by st for HID standalone (not custom HID, didn't work for me !). If i use this descriptor i can send data to the pc :

__ALIGN_BEGIN 
static
uint8_t HID_ReportDesc[USBD_HID_REPORT_DESC_SIZE] __ALIGN_END =
{
0x06, 0xFF, 0x00, 
/* USAGE_PAGE (Vendor Page: 0xFF00) */
0x09, 0x01, 
/* USAGE (Demo Kit) */
0xa1, 0x01, 
/* COLLECTION (Application) */
0x09, 0x01, 
/* USAGE (DATA) */
0x15, 0x00, 
/* LOGICAL_MINIMUM (0) */
0x25, 0xFF, 
/* LOGICAL_MAXIMUM (255) */
0x75, 0x01, 
/* REPORT_SIZE (8) */
0x95, 0x01 
/* REPORT_COUNT (1) */
0x81, 0x82, 
/* INPUT (Data,Var,Abs,Vol) */
0xc0 
/* END_COLLECTION */
};

In the main file i use this to send data :

sendBuffer[0]=0x01;//table with one element
USBD_HID_SendReport (&USBD_Device, SendBuffer, 1);

Now i would like to add more element in my descriptor

__ALIGN_BEGIN 
static
uint8_t HID_ReportDesc[USBD_HID_REPORT_DESC_SIZE] __ALIGN_END =
{
0x06, 0xFF, 0x00, 
/* USAGE_PAGE (Vendor Page: 0xFF00) */
0x09, 0x01, 
/* USAGE (Demo Kit) */
0xa1, 0x01, 
/* COLLECTION (Application) */
0x85, 0x01 
/* REPORT_ID (1) */
0x09, 0x01, 
/* USAGE (DATA 1) */
0x15, 0x00, 
/* LOGICAL_MINIMUM (0) */
0x25, 0xFF, 
/* LOGICAL_MAXIMUM (255) */
0x75, 0x08, 
/* REPORT_SIZE (8) */
0x95, 0x01 
/* REPORT_COUNT (1) */
0x81, 0x82, 
/* INPUT (Data,Var,Abs,Vol) */
0x85, 0x02 
/* REPORT_ID (2) */
0x09, 0x02, 
/* USAGE (DATA 2) */
0x15, 0x00, 
/* LOGICAL_MINIMUM (0) */
0x25, 0xFF, 
/* LOGICAL_MAXIMUM (255) */
0x75, 0x08, 
/* REPORT_SIZE (8) */
0x95, 0x01 
/* REPORT_COUNT (1) */
0x81, 0x82, 
/* INPUT (Data,Var,Abs,Vol) */
0xc0 
/* END_COLLECTION */
};

and in the main :

//send data1
sendBuffer[0]=0x01; 
//report id
sendBuffer[1]=0x7F; 
//data1 to send
USBD_HID_SendReport (&USBD_Device, SendBuffer, 2);

This didn't work, my card is correctly detected by windows (driver install ok) but i ddn't see any data ! Do you know what is wrong ?
1 REPLY 1
idealsim
Associate II
Posted on June 08, 2015 at 18:17

Hi i'm already trying to make my communication with usb hid. I make some progress but i have some problems ! i modified my report descriptor :

__ALIGN_BEGIN static uint8_t HID_MOUSE_ReportDesc[HID_MOUSE_REPORT_DESC_SIZE] __ALIGN_END =
{
0x06, 0xFF, 0x00, // USAGE_PAGE (Vendor Page: 0xFF00) 
0x09, 0x01, // USAGE (Demo Kit) 
0xa1, 0x01, // COLLECTION (Application)
0x85, 0x01, // REPORT_ID (1) 
0x09, 0x02, // USAGE (DATA)
0x15, 0x00, // LOGICAL_MINIMUM (0)
0x26, 0xff,0x00, // LOGICAL_MAXIMUM (255)
0x75, 0x08, // REPORT_SIZE (8)
0x95, 0x04, // REPORT_COUNT (4)
0x81, 0x02, // INPUT (Data,Var,Abs,Vol)
0xc0 // END_COLLECTION // END_COLLECTION
};

and the struct that i send :

typedef __packed struct
{
uint8_t id;
uint32_t adrrEth1;
}structUsb;
structUsb sUsb;
sUsb.id=0x01; //report id
sUsb.adrrEth1=0x;ac160978; //ip adress
USBD_HID_SendReport(&hUsbDeviceHS,(uint8_t*)&sUsb,5);

It works 1 minute but after i can't receive anything pc side ! I'm trying to declare 16 or 32 bit data in my descriptor but if i do that windows don't recognize the card :

__ALIGN_BEGIN static uint8_t HID_MOUSE_ReportDesc[HID_MOUSE_REPORT_DESC_SIZE] __ALIGN_END =
{
0x06, 0xFF, 0x00, // USAGE_PAGE (Vendor Page: 0xFF00) 
0x09, 0x01, // USAGE (Demo Kit) 
0xa1, 0x01, // COLLECTION (Application) 
0x09, 0x02, // USAGE (DATA)
0x15, 0x00, // LOGICAL_MINIMUM (0)
0x27, 0xff,0xff,0x00, // LOGICAL_MAXIMUM (65535)
0x75, 0x20, // REPORT_SIZE (16)
0x95, 0x01, // REPORT_COUNT (1)
0x81, 0x02, // INPUT (Data,Var,Abs,Vol)
0xc0 // END_COLLECTION
};

Do you think that is necessary to modify theUSB HID device Configuration Descriptor

/******************** Descriptor of Mouse endpoint ********************/
/* 27 */
0x07, 
/*bLength: Endpoint Descriptor size*/
USB_DESC_TYPE_ENDPOINT, 
/*bDescriptorType:*/
HID_EPIN_ADDR, 
/*bEndpointAddress: Endpoint Address (IN)*/
0x03, 
/*bmAttributes: Interrupt endpoint*/
HID_EPIN_SIZE, 
/*wMaxPacketSize: 4 Byte max */
-----------------------> modify 
this
size ?
0x00,
HID_POLLING_INTERVAL, 
/*bInterval: Polling Interval (10 ms)*/
/* 34 */

Can you help me please !