/var/www/restricted/ssh/stm32/www/stm32circle/ STM CircleOS forum / USB

Username:     
Password:     
             

Forum

# 1   2010-07-12 17:53:34 USB

brothe_r
Member
Registered: 2010-04-08
Posts: 10

USB

Hi everyone,

I'm on trouble with the USB file descriptor... It is weird, since it works in windows XP, but in vista or win 7 it is not installed correctly. I used the library and the HID example from ST. First I show the report which only works on XP:

const BYTE HID_ReportDescriptor[] = {

  HID_UsagePageVendor(0x00),
  HID_Usage(HID_USAGE_PAGE_GENERIC),
  HID_Collection(HID_Application),

    HID_Usage(HID_USAGE_PAGE_VR),   // Usage (vendor-defined)
    HID_UsageMin(1),
    HID_UsageMax(1),
    HID_LogicalMin(0),
    HID_LogicalMax(0xFF),
    HID_ReportSize(16),                        //report Size (16 bits)
    HID_ReportCount(250),                          // 250 * 2 bytes (16bits) = 500 bytes
    HID_Input(HID_Data | HID_Variable | HID_Absolute),

    HID_UsagePage(HID_USAGE_PAGE_LED),
    HID_Usage(HID_USAGE_LED_GENERIC_INDICATOR),
    HID_LogicalMin(0),
    HID_LogicalMax(1),
    HID_ReportCount(8),
    HID_ReportSize(1),
    HID_Output(HID_Data | HID_Variable | HID_Absolute),
  HID_EndCollection,
};


const BYTE USB_ConfigDescriptor[] = {
// Configuration 1
  USB_CONFIGUARTION_DESC_SIZE,
  USB_CONFIGURATION_DESCRIPTOR_TYPE,
  WBVAL(
    USB_CONFIGUARTION_DESC_SIZE +
    USB_INTERFACE_DESC_SIZE     +
    HID_DESC_SIZE               +
    USB_ENDPOINT_DESC_SIZE
  ),
  0x01,
  0x01,
  0x00,
  USB_CONFIG_BUS_POWERED,
  USB_CONFIG_POWER_MA(100),
  USB_INTERFACE_DESC_SIZE,
  USB_INTERFACE_DESCRIPTOR_TYPE,
  0x00,
  0x00,
  0x01,
  USB_DEVICE_CLASS_HUMAN_INTERFACE,
  HID_SUBCLASS_NONE,
  HID_PROTOCOL_NONE,
  0x5E,

  HID_DESC_SIZE,
  HID_HID_DESCRIPTOR_TYPE,
  WBVAL(0x0110),
  0x00,
  0x01,
  HID_REPORT_DESCRIPTOR_TYPE,
  WBVAL(HID_REPORT_DESC_SIZE),

  USB_ENDPOINT_DESC_SIZE,
  USB_ENDPOINT_DESCRIPTOR_TYPE,
  USB_ENDPOINT_IN(1),
  USB_ENDPOINT_TYPE_INTERRUPT,
  WBVAL(500),                                   // wMaxPacketSize:500 bytes.
  0x40,
  0
};

What I did was that wMaxPacketSize (6 lines upwards from here, equal to 500 bytes) was equal to the HID_ReportCount*HID_ReportSize/8. Following the same logics, and just changing these variables:

[...]
    HID_ReportCount(32),         // 32 * 2 byte (16bits) = 64 bytes
[...]
  WBVAL(64),                     // wMaxPacketSize: 64 bytes.
[...]


it gets correctly installed on vista and 7. If then I increase 2 bytes:

[...]
    HID_ReportCount(33),         // 33 * 2 byte (16bits) = 66 bytes
[...]
  WBVAL(66),                     // wMaxPacketSize: 66 bytes.
[...]

It stop working again... Someone knows why it happens? Are vista or win 7 limited to 64 bytes? With windows XP I could transfer 500 bytes without problem, and that was amazing, since I need to transfer some ammount of data by polling (with a VC++ 2008 program) using a timer, and I need more than 64 bytes per USB transaction, since the timer in a OS is not fast enough...

I also tried to use HID_ReportCount(64) and WBVAL(128), to try if it was that the OS needs a value of 2^n, but it neither worked...

Thank you! :-)

Offline

 

# 2   2010-07-13 07:39:22 USB

domen
Member
Registered: 2008-10-27
Posts: 10

Re: USB

HID packets are limited to 64 bytes, so wMaxPacketSize shouldn't be larger. (But reports can be, and can be made of multiple packets, if I'm reading this HID document correctly)

Offline

 

# 3   2010-07-13 10:16:56 USB

brothe_r
Member
Registered: 2010-04-08
Posts: 10

Re: USB

Hi domen,

Thank you for your response. What you say has sense, since it doesn't work for length > 64 bytes, but in the stm32circle project (the ECG), he uses 120bytes for data transfer...

Is there any way to send more than 64 bytes or I should change from HID to bulk or another type of transfer? What it is odd is that it works under win XP...

Anyway, in my VC++ 2008 project I use the standard windows function:
ok = ReadFile(DevHandle, buf, sz, cnt, NULL);

If I try to read another size (sz) than the used in the report descriptor + 1, the ReadFile returns False (if lower), or it hangs (if higher)...

Thank you!

Offline

 

Board footer