AnsweredAssumed Answered

STM32F3 discovery board - unable to receive USB HID data

Question asked by aizenshtark.boaz on Dec 16, 2014
Latest reply on Dec 18, 2014 by aizenshtark.boaz
I'm trying to get the USB HID demo project to work with the STM32F3 discovery board.
So far I manage to enumerate the device and send data, but I'm unable to receive data.

In the device side, I've created the single-interface, single-endpoint IN/OUT descriptor (see below). On the host side, on Windows 7, I use the C++ 'CreateFile/WriteFile' routines as below.

Using a USB sniffer, I see that 64 bytes are sent to the device, but the operation is cancelled after a timeout.
I do not get any interrupt in the device itself.

Any idea where to look?
 

Device USB descriptors:
const uint8_t CustomHID_DeviceDescriptor[CUSTOMHID_SIZ_DEVICE_DESC] =
  {
    0x12,                       /*bLength */
    USB_DEVICE_DESCRIPTOR_TYPE, /*bDescriptorType*/
    0x00,                       /*bcdUSB */
    0x02,
    0x00,                       /*bDeviceClass*/
    0x00,                       /*bDeviceSubClass*/
    0x00,                       /*bDeviceProtocol*/
    0x40,                       /*bMaxPacketSize40*/
    0x83,                       /*idVendor (0x0483)*/
    0x04,
    0x50,                       /*idProduct = 0x5750*/
    0x57,
    0x01,                       /*bcdDevice rel. 1.00*/
    0x00,
    1,                          /*Index of string descriptor describing
                                              manufacturer */
    2,                          /*Index of string descriptor describing
                                             product*/
    3,                          /*Index of string descriptor describing the
                                             device serial number */
    0x01                        /*bNumConfigurations*/
  }; /* CustomHID_DeviceDescriptor */




/* USB Configuration Descriptor */
/*   All Descriptors (Configuration, Interface, Endpoint, Class, Vendor */
const uint8_t CustomHID_ConfigDescriptor[CUSTOMHID_SIZ_CONFIG_DESC] =
  {
    0x09, /* bLength: Configuration Descriptor size */
    USB_CONFIGURATION_DESCRIPTOR_TYPE, /* bDescriptorType: Configuration */
    CUSTOMHID_SIZ_CONFIG_DESC,
    /* wTotalLength: Bytes returned */
    0x00,
    0x01,         /* bNumInterfaces: 1 interface */
    0x01,         /* bConfigurationValue: Configuration value */
    0x00,         /* iConfiguration: Index of string descriptor describing
                                 the configuration*/
    0xC0,         /* bmAttributes: Self powered */
    0x64,         /* MaxPower 200 mA: this current is used for detecting Vbus */


    /************** Descriptor of Custom HID interface ****************/
    /* 09 */
    0x09,         /* bLength: Interface Descriptor size */
    USB_INTERFACE_DESCRIPTOR_TYPE,/* bDescriptorType: Interface descriptor type */
    0x00,         /* bInterfaceNumber: Number of Interface */
    0x00,         /* bAlternateSetting: Alternate setting */
    0x02,         /* bNumEndpoints */
    0x03,         /* bInterfaceClass: HID */
    0x00,         /* bInterfaceSubClass : 1=BOOT, 0=no boot */
    0x00,         /* nInterfaceProtocol : 0=none, 1=keyboard, 2=mouse */
    0,            /* iInterface: Index of string descriptor */
    /******************** Descriptor of Custom HID HID ********************/
    /* 18 */
    0x09,         /* bLength: HID Descriptor size */
    HID_DESCRIPTOR_TYPE, /* bDescriptorType: HID */
    0x10,         /* bcdHID: HID Class Spec release number */
    0x01,
    0x00,         /* bCountryCode: Hardware target country */
    0x01,         /* bNumDescriptors: Number of HID class descriptors to follow */
    0x22,         /* bDescriptorType */
    CUSTOMHID_SIZ_REPORT_DESC,/* wItemLength: Total length of Report descriptor */
    0x00,
    /******************** Descriptor of Custom HID endpoints ******************/
    /* 27 */
    0x07,          /* bLength: Endpoint Descriptor size */
    USB_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType: */


    0x81,          /* bEndpointAddress: Endpoint Address (IN) */
    0x03,          /* bmAttributes: Interrupt endpoint */
    0x40,          /* wMaxPacketSize: 64 Bytes max */
    0x00,
    0x01,          /* bInterval: Polling Interval (1 ms) */
    /* 34 */
         
    0x07,     /* bLength: Endpoint Descriptor size */
    USB_ENDPOINT_DESCRIPTOR_TYPE,     /* bDescriptorType: */
               /*     Endpoint descriptor type */
    0x01,     /* bEndpointAddress: */
               /*     Endpoint Address (OUT) */
    0x03,     /* bmAttributes: Interrupt endpoint */
    0x40,     /* wMaxPacketSize: 64 Bytes max  */
    0x00,
    0x20,     /* bInterval: Polling Interval (32 ms) */
    /* 41 */
  }; /* CustomHID_ConfigDescriptor */




const uint8_t CustomHID_ReportDescriptor[CUSTOMHID_SIZ_REPORT_DESC] =
  {
    0x06, 0x00, 0xFF,       // Usage Page = 0xFF00 (Vendor Defined Page 1)
    0x09, 0x01,             // Usage (Vendor Usage 1)


    0xA1, 0x01,             // Collection (Application)


    /* Input Usage */
    0x09, 0x02,             // Usage (Vendor Usage 2)
//    0x19, 0x00,             //      Usage Minimum
//    0x29, 0x3F,             //      Usage Maximum  //app commands are 0 to 3F
    0x15, 0x00,             //      Logical Minimum (data bytes in the report may have minimum value = 0x00)
    0x26, 0xFF, 0x00,       //      Logical Maximum (data bytes in the report may have maximum value = 0x00FF = unsigned 255)
    0x75, 0x08,             //      Report Size: 8-bit field size
    0x95, 0x40,             //      Report Count: Make sixty-four 8-bit fields (the next time the parser hits an "Input", "Output", or "Feature" item)
    0x81, 0x00,             //      Input (Data, Array, Abs): Instantiates input packet fields based on the above report size, count, logical min/max, and usage.


    /* Output Usage */
    0x09, 0x03,             // Usage (Vendor Usage 3)
     0x15, 0x00,             //      Logical Minimum (data bytes in the report may have minimum value = 0x00)
     0x26, 0xFF, 0x00,       //      Logical Maximum (data bytes in the report may have maximum value = 0x00FF = unsigned 255)
     0x75, 0x08,             //      Report Size: 8-bit field size
     0x95, 0x40,             //      Report Count: 64 bytes
     0x91, 0x22,             //      Output (Data, Array, Abs): Instantiates output packet fields based on the above report size, count, logical min/max, and usage.


    0xC0                    // End Collection
  }; /* CustomHID_ReportDescriptor */


Windows routines:
...h = CreateFile(details->DevicePath, GENERIC_READ | GENERIC_WRITEFILE_SHARE_READ | FILE_SHARE_WRITENULL,OPEN_EXISTINGFILE_FLAG_OVERLAPPEDNULL);
OVERLAPPED ov;if(!WriteFile(hid->handle, tmpbuf, len + 1, NULL, &ov)) {...}

Outcomes