Content originally posted in LPCWare by dipali on Tue Jun 03 00:09:21 MST 2014
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
<pre>
#define POWERDOWN_MODE_USB_WAKEUP0
#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
</pre>
changed size of in report buffer and out report buffer in demo.c
<pre>
demo.c.c
#defineOP_BUFFER_SIZE512
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
}
</pre>
<pre>
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 */
};
</pre>
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?