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

USB HID problem when inreport size is more than 64 bytes

I am using lpc1768 as usb hid device and have my own java code at pc side for user interface.I want to send/receive data to pc more than 64 bytes.I have changed keil sample program and I am able to out 512 bytes from HOST(pc) to HID(my LPC 1768 board).Also my HID (LPC 1768 can transmit) upto 64 bytes to HOST successfully. I have changed original code as follows
usb_cfg.h

#define POWERDOWN_MODE_USB_WAKEUP                       0

#define USB_POWER           0
#define USB_IF_NUM          1
#define USB_EP_NUM          32
#define USB_MAX_PACKET0     64                        <----------------
#define USB_DMA             0
#define USB_DMA_EP          0x00000000

changed size of in report buffer and out report buffer in demo.c

demo.c.c
#define OP_BUFFER_SIZE  512
uint8_t InReport[OP_BUFFER_SIZE];                /* HID Input Report    */
                                            /*   Bit0   : Buttons  */
                                            /*   Bit1..7: Reserved */

uint8_t OutReport[OP_BUFFER_SIZE];                             /* HID Out Report      */

void SetOutReport (void) {
unsigned char ch;
  static unsigned long led_mask[] = { 1<<28, 1<<29, 1UL<<31, 1<<2, 1<<3, 1<<4, 1<<5, 1<<6 };
  if (OutReport[15] < 'A')
        LPC_GPIO1->FIOPIN |= led_mask[1];
else
        LPC_GPIO1->FIOPIN &= ~led_mask[1];
memcpy(InReport,OutReport,sizeof(InReport));
for(ch = 0; ch < 64; ch++)
        InReport[ch] = OutReport[ch + 248];     <--------------- for debugging only
}

usbdesc.c


#define HID_INPUT_REPORT_BYTES 64 /* size of report in Bytes */ #define HID_OUTPUT_REPORT_BYTES 64 /* size of report in Bytes */ #define HID_FEATURE_REPORT_BYTES 64 /* size of report in Bytes */
const uint8_t HID_ReportDescriptor[] = { HID_UsagePageVendor(0x00), HID_Usage(0x01), HID_Collection(HID_Application),
HID_UsagePage(HID_USAGE_PAGE_KEYBOARD), <------------ HID_UsageMin(1), HID_UsageMax(200), HID_LogicalMin(1), HID_LogicalMax(200), <---------------I wnat values between 1 to 200 HID_ReportCount(USB_MAX_PACKET0), <-----------If i change this value to more than 64 bytes device not detected HID_ReportSize(8), <-----------data of 8 bytes HID_Input(HID_Data | HID_Variable | HID_Absolute),
//host output and controller input working HID_UsagePage(HID_USAGE_PAGE_LED), HID_Usage(HID_USAGE_LED_GENERIC_INDICATOR), HID_LogicalMin(0), HID_LogicalMax(255), <-------------------- HID_ReportCountS(OP_BUFFER_SIZE), //output data from host more than 255 bytes HID_ReportSize(8), //field size 8 bits HID_Output(HID_Data | HID_Variable | HID_Absolute), HID_EndCollection, };
const uint8_t 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 + 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 */ 0x01, /* bNumEndpoints */ USB_DEVICE_CLASS_HUMAN_INTERFACE, /* bInterfaceClass */ HID_SUBCLASS_NONE, /* bInterfaceSubClass */ HID_PROTOCOL_NONE, /* bInterfaceProtocol */ 0x04, /* 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(USB_MAX_PACKET0),//+USB_MAX_PACKET0+USB_MAX_PACKET0+USB_MAX_PACKET0+USB_MAX_PACKET0+USB_MAX_PACKET0+USB_MAX_PACKET0+USB_MAX_PACKET0), /* wMaxPacketSize */ 0x1, /* 32ms */ /* bInterval */ /* Terminator */ 0 /* bLength */ };

I want to go further and want to IN more than 64 bytes can anyone help me.
I have referred some forum but changing my code according to that cause problems like
1.If i change report descriptor sometimes HOST cannot detect the device
2.My java code goes goes for timeout while reading more than 64 bytes.

does Anyone know an application at PC side to verify my HID code?

Parents
  • > still I am confused where to call hid_send_in_report()

    You may call hid_send_in_report() anywhere your input report is prepared on a buffer.
    The code works as follows,

    1) hid_send_in_report() fills the global variables, which is passed to the endpoint (EP) ISR. And then, it invokes the EP ISR.

    2) On the EP ISR, the first packet is copied from the buffer to the IN endpoint using USB_WriteEP().

    3) When an IN transaction comes from host, the IN endpoint send the packet to the host. The completion of the transaction generates hardware interrupt, and the EP ISR is called again.

    4) In this way, chained interrupts on the IN endpoint send the data on the buffer, packet by packet, of endpoint MPS (MaxPacketSize) or less.

    5) At the last call of the ISR, the ISR drops the busy flag (hid_in_busy), instead of sending another packet. Now that you may send another input report using hid_send_in_report() again.

    Tsuneo

Reply
  • > still I am confused where to call hid_send_in_report()

    You may call hid_send_in_report() anywhere your input report is prepared on a buffer.
    The code works as follows,

    1) hid_send_in_report() fills the global variables, which is passed to the endpoint (EP) ISR. And then, it invokes the EP ISR.

    2) On the EP ISR, the first packet is copied from the buffer to the IN endpoint using USB_WriteEP().

    3) When an IN transaction comes from host, the IN endpoint send the packet to the host. The completion of the transaction generates hardware interrupt, and the EP ISR is called again.

    4) In this way, chained interrupts on the IN endpoint send the data on the buffer, packet by packet, of endpoint MPS (MaxPacketSize) or less.

    5) At the last call of the ISR, the ISR drops the busy flag (hid_in_busy), instead of sending another packet. Now that you may send another input report using hid_send_in_report() again.

    Tsuneo

Children
No data