size prob in USBHID

I need help with the USBHID example which is part of the the Keil MCB2300 Evaluation Board (using the Philips LPC2300 ARM processor).

I want to re-use this source code in my project, but this example sends only one byte at a time. I need to send and receive up to 64 bytes. It looks like the source code is prepared to handle more than one byte, however during the identification of the USB to the host computer, the length is fixed to one byte. How do I change the packet length for this example?

yes there is a one solution on forum,but still i can not understand properly.so if any one have sol. plz reply me.

Parents
  • Hello, you gotta change report desriptor to be similar to this (source comes from other project, but should help, this HID sends 64B and receives 64B):

    const char pxReportDescriptor[] =
    {
            0x06, 0x00, 0xFF,       // Usage Page Vendor defined page 1
            0x09, 0x00,             // Usage something (other than 0 is required if using undefined page)
            0xA1, 0x01,             // Collection App (seem to need a collection?)
    // Input Report
            0x09, 0x00,             // Usage Undefined
            0x75, 0x08,             // REPORT_SIZE      Data received is 8 Bits in Size
            0x95, REPORT_SIZE_IN,   // REPORT_COUNT     Report Count
            0x26, 0xFF, 0x00,       // LOGICAL_MAXIMUM  Max 255 // MIREK musi byt dvojbajtove aby to nepovazoval za zaporne cislo
            0x15, 0x00,             // LOGICAL_MINIMUM  Min 0
            0x81, 0x02,             // Input // MIREK: data, var, abs
    // Output Report
            0x09, 0x00,             // Usage Undefined
            0x91, 0x02,             // MIREK Output: data, var, abs
            0xC0
    };
    

    config descriptor should be similat to this:

    const char pxConfigDescriptor[] = {
            /* Configuration 1 descriptor */
            0x09,                   /* CbLength                                                                     */
            0x02,                   /* CbDescriptorType                                                     */
            0x22+7-0, 0x00,         /* CwTotalLength 2 EP + Control                         */
            0x01,                   /* CbNumInterfaces                                                      */
            0x01,                   /* CbConfigurationValue                                         */
            usbCONFIGURATION_STRING,/* CiConfiguration                                      */
            usbBUS_POWERED, /* CbmAttributes Bus powered + Remote Wakeup*/
            0x32,                   /* CMaxPower: 100mA                                                     */
    
            /* Joystick Interface Descriptor Requirement */
            0x09,                   /* bLength                                                                      */
            0x04,                   /* bDescriptorType                                                      */
            0x00,                   /* bInterfaceNumber                                                     */
            0x00,                   /* bAlternateSetting                                            */
            0x01+1-0,                       /* bNumEndpoints                                                        */
            0x03,                   /* bInterfaceClass: HID code                            */
            0x00,                   /* bInterfaceSubclass                                           */
            0x00,                   /* bInterfaceProtocol                                           */
            usbINTERFACE_STRING,    /* iInterface                                                   */
    
            /* HID Descriptor */
            0x09,                   /* bLength                                                                      */
            0x21,                   /* bDescriptor type: HID Descriptor Type        */
            0x11, 0x01,             /* bcdHID                                                                       */
            0x00,                   /* bCountryCode                                                         */
            0x01,                   /* bNumDescriptors                                                      */
            usbHID_REPORT_DESCRIPTOR,         /* bDescriptorType                    */
            sizeof( pxReportDescriptor), 0x00, /* wItemLength                       */
    
            // Endpoint 1 descriptor PIPE 1 -----------------------------------------------------------------------
            0x07,                   // bLength
            0x05,                   // bDescriptorType
            0x81,                   // bEndpointAddress, Endpoint 01 - IN
            0x03,                   // bmAttributes      Interrupt
            REPORT_SIZE_IN, 0x00,   // wMaxPacketSize: 3 bytes (x, y, z) // 08
            0x01,                   // bInterval
    
            // Endpoint 2 descriptor PIPE 2 -----------------------------------------------------------------------
            0x07,                   // bLength
            0x05,                   // bDescriptorType
            0x03,                   // bEndpointAddress, Endpoint 03 - OUT
            0x03,                   // bmAttributes      - Interrupt
            REPORT_SIZE_OUT, 0x00,          // wMaxPacketSize: 3 bytes (x, y, z)
            0x01    /**/            // bInterval
    };
    

    REPORT_SIZE_IN has to be set to 64
    REPORT_SIZE_OUT has to be set to 64

    BTW: You could probably use HHD USB monitor, download it's trial at: www.hhdsoftware.com/.../usb-monitor.html , it will show you sizes of enpoints.

    Have a nice day, Mirek

Reply
  • Hello, you gotta change report desriptor to be similar to this (source comes from other project, but should help, this HID sends 64B and receives 64B):

    const char pxReportDescriptor[] =
    {
            0x06, 0x00, 0xFF,       // Usage Page Vendor defined page 1
            0x09, 0x00,             // Usage something (other than 0 is required if using undefined page)
            0xA1, 0x01,             // Collection App (seem to need a collection?)
    // Input Report
            0x09, 0x00,             // Usage Undefined
            0x75, 0x08,             // REPORT_SIZE      Data received is 8 Bits in Size
            0x95, REPORT_SIZE_IN,   // REPORT_COUNT     Report Count
            0x26, 0xFF, 0x00,       // LOGICAL_MAXIMUM  Max 255 // MIREK musi byt dvojbajtove aby to nepovazoval za zaporne cislo
            0x15, 0x00,             // LOGICAL_MINIMUM  Min 0
            0x81, 0x02,             // Input // MIREK: data, var, abs
    // Output Report
            0x09, 0x00,             // Usage Undefined
            0x91, 0x02,             // MIREK Output: data, var, abs
            0xC0
    };
    

    config descriptor should be similat to this:

    const char pxConfigDescriptor[] = {
            /* Configuration 1 descriptor */
            0x09,                   /* CbLength                                                                     */
            0x02,                   /* CbDescriptorType                                                     */
            0x22+7-0, 0x00,         /* CwTotalLength 2 EP + Control                         */
            0x01,                   /* CbNumInterfaces                                                      */
            0x01,                   /* CbConfigurationValue                                         */
            usbCONFIGURATION_STRING,/* CiConfiguration                                      */
            usbBUS_POWERED, /* CbmAttributes Bus powered + Remote Wakeup*/
            0x32,                   /* CMaxPower: 100mA                                                     */
    
            /* Joystick Interface Descriptor Requirement */
            0x09,                   /* bLength                                                                      */
            0x04,                   /* bDescriptorType                                                      */
            0x00,                   /* bInterfaceNumber                                                     */
            0x00,                   /* bAlternateSetting                                            */
            0x01+1-0,                       /* bNumEndpoints                                                        */
            0x03,                   /* bInterfaceClass: HID code                            */
            0x00,                   /* bInterfaceSubclass                                           */
            0x00,                   /* bInterfaceProtocol                                           */
            usbINTERFACE_STRING,    /* iInterface                                                   */
    
            /* HID Descriptor */
            0x09,                   /* bLength                                                                      */
            0x21,                   /* bDescriptor type: HID Descriptor Type        */
            0x11, 0x01,             /* bcdHID                                                                       */
            0x00,                   /* bCountryCode                                                         */
            0x01,                   /* bNumDescriptors                                                      */
            usbHID_REPORT_DESCRIPTOR,         /* bDescriptorType                    */
            sizeof( pxReportDescriptor), 0x00, /* wItemLength                       */
    
            // Endpoint 1 descriptor PIPE 1 -----------------------------------------------------------------------
            0x07,                   // bLength
            0x05,                   // bDescriptorType
            0x81,                   // bEndpointAddress, Endpoint 01 - IN
            0x03,                   // bmAttributes      Interrupt
            REPORT_SIZE_IN, 0x00,   // wMaxPacketSize: 3 bytes (x, y, z) // 08
            0x01,                   // bInterval
    
            // Endpoint 2 descriptor PIPE 2 -----------------------------------------------------------------------
            0x07,                   // bLength
            0x05,                   // bDescriptorType
            0x03,                   // bEndpointAddress, Endpoint 03 - OUT
            0x03,                   // bmAttributes      - Interrupt
            REPORT_SIZE_OUT, 0x00,          // wMaxPacketSize: 3 bytes (x, y, z)
            0x01    /**/            // bInterval
    };
    

    REPORT_SIZE_IN has to be set to 64
    REPORT_SIZE_OUT has to be set to 64

    BTW: You could probably use HHD USB monitor, download it's trial at: www.hhdsoftware.com/.../usb-monitor.html , it will show you sizes of enpoints.

    Have a nice day, Mirek

Children
More questions in this forum