This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

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
  • Hi,
    I use USBHID example for MCBSTR9 ARM9 Board, I want to make 1 more endpoint to write and change the packet size to 32. I can send the data at 32 byte but I can't read the data back.

    code in usbcfg.h

    #define USB_POWER           0
    #define USB_IF_NUM          4
    #define USB_EP_NUM          3
    //#define USB_MAX_PACKET0     8
    #define USB_MAX_PACKET0     32
    #define USB_DBL_BUF_EP      0x0000
    
    #define USB_POWER_EVENT     0
    #define USB_RESET_EVENT     1
    #define USB_SUSPEND_EVENT   0
    #define USB_RESUME_EVENT    0
    #define USB_WAKEUP_EVENT    0
    #define USB_SOF_EVENT       0
    #define USB_ERROR_EVENT     0
    //#define USB_EP_EVENT        0x0003
    #define USB_EP_EVENT        0x0007
    #define USB_CONFIGURE_EVENT 1
    #define USB_INTERFACE_EVENT 0
    #define USB_FEATURE_EVENT   0
    

    code in usbdesc.c


    /* USB Configuration Descriptor */
    /* All Descriptors (Configuration, Interface, Endpoint, Class, Vendor */
    const BYTE USB_ConfigDescriptor[] = {
    /* Configuration 1 */ USB_CONFIGUARTION_DESC_SIZE, /* bLength */ USB_CONFIGURATION_DESCRIPTOR_TYPE, /* bDescriptorType */ WBVAL( /* wTotalLength */ USB_CONFIGUARTION_DESC_SIZE + USB_INTERFACE_DESC_SIZE + HID_DESC_SIZE + 2*USB_ENDPOINT_DESC_SIZE ), 0x01, /* bNumInterfaces */ 0x01, /* bConfigurationValue */ 0x00, /* iConfiguration */ USB_CONFIG_BUS_POWERED /*|*/ /* bmAttributes */
    /*USB_CONFIG_REMOTE_WAKEUP*/, USB_CONFIG_POWER_MA(100), /* bMaxPower */
    /* Interface 0, Alternate Setting 0, HID Class */ USB_INTERFACE_DESC_SIZE, /* bLength */ USB_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType */ 0x00, /* bInterfaceNumber */ 0x00, /* bAlternateSetting */ 0x02, /* bNumEndpoints */ USB_DEVICE_CLASS_HUMAN_INTERFACE, /* bInterfaceClass */ HID_SUBCLASS_NONE, /* bInterfaceSubClass */ HID_PROTOCOL_NONE, /* bInterfaceProtocol */ 0x5C, /* iInterface */
    /* HID Class Descriptor */
    /* HID_DESC_OFFSET = 0x0012 */ HID_DESC_SIZE, /* bLength */ HID_HID_DESCRIPTOR_TYPE, /* bDescriptorType */ WBVAL(0x0100), /* 1.00 */ /* bcdHID */ 0x00, /* bCountryCode */ 0x01, /* bNumDescriptors */ HID_REPORT_DESCRIPTOR_TYPE, /* bDescriptorType */ WBVAL(HID_REPORT_DESC_SIZE), /* wDescriptorLength */
    /* Endpoint, HID Interrupt In */ USB_ENDPOINT_DESC_SIZE, /* bLength */ USB_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType */ USB_ENDPOINT_IN(1), /* bEndpointAddress */ USB_ENDPOINT_TYPE_INTERRUPT, /* bmAttributes */ WBVAL(0x0020), /* wMaxPacketSize */ 0x20, /* 32ms */ /* bInterval */ /* Endpoint, HID Interrupt Out */ USB_ENDPOINT_DESC_SIZE, /* bLength */ USB_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType */ USB_ENDPOINT_OUT(2), /* bEndpointAddress */ USB_ENDPOINT_TYPE_INTERRUPT, /* bmAttributes */ WBVAL(0x0020), /* wMaxPacketSize */ 0x20, /* 32ms */ /* bInterval */
    /* Terminator */ 0 /* bLength */
    };

    and code in usbuser.c to use to read endpoint

    void USB_EndPoint1 (DWORD event) {
      USB_ReadEP(0x02, buffer1);
      USB_WriteEP(0x81, buffer1, sizeof(buffer1));
    }
    
    
    /*
     *  USB Endpoint 2 Event Callback
     *   Called automatically on USB Endpoint 2 Event
     *    Parameter:       event
     */
    
    void USB_EndPoint2 (DWORD event) {
      USB_ReadEP(0x02, buffer2);
      msg2 = buffer2;
      SetOutReport();
    }
    

    when I read the data back, I alway got 4 byte junk stuff before the real data.
    So can anyone help me?

    Thank you,

    John

Reply
  • Hi,
    I use USBHID example for MCBSTR9 ARM9 Board, I want to make 1 more endpoint to write and change the packet size to 32. I can send the data at 32 byte but I can't read the data back.

    code in usbcfg.h

    #define USB_POWER           0
    #define USB_IF_NUM          4
    #define USB_EP_NUM          3
    //#define USB_MAX_PACKET0     8
    #define USB_MAX_PACKET0     32
    #define USB_DBL_BUF_EP      0x0000
    
    #define USB_POWER_EVENT     0
    #define USB_RESET_EVENT     1
    #define USB_SUSPEND_EVENT   0
    #define USB_RESUME_EVENT    0
    #define USB_WAKEUP_EVENT    0
    #define USB_SOF_EVENT       0
    #define USB_ERROR_EVENT     0
    //#define USB_EP_EVENT        0x0003
    #define USB_EP_EVENT        0x0007
    #define USB_CONFIGURE_EVENT 1
    #define USB_INTERFACE_EVENT 0
    #define USB_FEATURE_EVENT   0
    

    code in usbdesc.c


    /* USB Configuration Descriptor */
    /* All Descriptors (Configuration, Interface, Endpoint, Class, Vendor */
    const BYTE USB_ConfigDescriptor[] = {
    /* Configuration 1 */ USB_CONFIGUARTION_DESC_SIZE, /* bLength */ USB_CONFIGURATION_DESCRIPTOR_TYPE, /* bDescriptorType */ WBVAL( /* wTotalLength */ USB_CONFIGUARTION_DESC_SIZE + USB_INTERFACE_DESC_SIZE + HID_DESC_SIZE + 2*USB_ENDPOINT_DESC_SIZE ), 0x01, /* bNumInterfaces */ 0x01, /* bConfigurationValue */ 0x00, /* iConfiguration */ USB_CONFIG_BUS_POWERED /*|*/ /* bmAttributes */
    /*USB_CONFIG_REMOTE_WAKEUP*/, USB_CONFIG_POWER_MA(100), /* bMaxPower */
    /* Interface 0, Alternate Setting 0, HID Class */ USB_INTERFACE_DESC_SIZE, /* bLength */ USB_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType */ 0x00, /* bInterfaceNumber */ 0x00, /* bAlternateSetting */ 0x02, /* bNumEndpoints */ USB_DEVICE_CLASS_HUMAN_INTERFACE, /* bInterfaceClass */ HID_SUBCLASS_NONE, /* bInterfaceSubClass */ HID_PROTOCOL_NONE, /* bInterfaceProtocol */ 0x5C, /* iInterface */
    /* HID Class Descriptor */
    /* HID_DESC_OFFSET = 0x0012 */ HID_DESC_SIZE, /* bLength */ HID_HID_DESCRIPTOR_TYPE, /* bDescriptorType */ WBVAL(0x0100), /* 1.00 */ /* bcdHID */ 0x00, /* bCountryCode */ 0x01, /* bNumDescriptors */ HID_REPORT_DESCRIPTOR_TYPE, /* bDescriptorType */ WBVAL(HID_REPORT_DESC_SIZE), /* wDescriptorLength */
    /* Endpoint, HID Interrupt In */ USB_ENDPOINT_DESC_SIZE, /* bLength */ USB_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType */ USB_ENDPOINT_IN(1), /* bEndpointAddress */ USB_ENDPOINT_TYPE_INTERRUPT, /* bmAttributes */ WBVAL(0x0020), /* wMaxPacketSize */ 0x20, /* 32ms */ /* bInterval */ /* Endpoint, HID Interrupt Out */ USB_ENDPOINT_DESC_SIZE, /* bLength */ USB_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType */ USB_ENDPOINT_OUT(2), /* bEndpointAddress */ USB_ENDPOINT_TYPE_INTERRUPT, /* bmAttributes */ WBVAL(0x0020), /* wMaxPacketSize */ 0x20, /* 32ms */ /* bInterval */
    /* Terminator */ 0 /* bLength */
    };

    and code in usbuser.c to use to read endpoint

    void USB_EndPoint1 (DWORD event) {
      USB_ReadEP(0x02, buffer1);
      USB_WriteEP(0x81, buffer1, sizeof(buffer1));
    }
    
    
    /*
     *  USB Endpoint 2 Event Callback
     *   Called automatically on USB Endpoint 2 Event
     *    Parameter:       event
     */
    
    void USB_EndPoint2 (DWORD event) {
      USB_ReadEP(0x02, buffer2);
      msg2 = buffer2;
      SetOutReport();
    }
    

    when I read the data back, I alway got 4 byte junk stuff before the real data.
    So can anyone help me?

    Thank you,

    John

Children
No data