Dear friends/Sir
I Am working for Card Reader Using USB. My Card reading Progarm is comleted. Now Data cllected from the Card. I want to send this data to PC. I Have Modified to HIDUSB example from Keil .
My modified report Descriptor is as
usbdesc.c /* HID Report Descriptor */ const BYTE HID_ReportDescriptor[] = { HID_UsagePageVendor(0x00), HID_Usage(0x01), HID_Collection(HID_Application), HID_Usage(0x01), HID_LogicalMin(0), HID_LogicalMax(1), HID_ReportCount(50), HID_ReportSize(8), HID_Input(HID_Data | HID_Variable | HID_Absolute), HID_EndCollection, };
max Packet size i have changed to
WBVAL(0x000A), /* wMaxPacketSize */ 0x0A, /* 16ms */ /* bInterval */
Now for data Transfer test i have modified USB_EndPoint1() like this
declared in
usbuser.c
void USB_EndPoint1 (DWORD event) { BYTE tmp[10]={'C','A','R','D','T','A','1','2','3','4'} switch (event) { case USB_EVT_IN: USB_WriteEP(0x81,tmp, sizeof(tmp)); break; } }
but on reading i am not getting data in PC. but if it is single byte transfer i getting it properly.
This data transaction i am monitoring using a software
Device Monitoring Studio
so i want to know wheather i have done correct modifications or any other modification is required in microcontroller Program.
Thanks SCP
HID Report Descriptor
HID_LogicalMin(0), HID_LogicalMax(1),
This declaration means each byte of your report has just one of two values, 0 or 1. Is it what you want? If you use full extent of byte, 0x00 - 0xFF, modify above code as follows.
HID_LogicalMin(0), HID_LogicalMaxS( 0x00FF ),
Please note, Instead of HID_LogicalMax(), HID_LogicalMaxS() macro is applied, because the parameter of these macro is signed integer. HID_LogicalMax() - single byte, signed integer HID_LogicalMaxS() - two bytes, signed integer Endpoint descriptor The problem is here, wMaxPacketSize on the endpoint descriptor.
WBVAL(0x000A), /* wMaxPacketSize */
You've set it to 10 bytes. It means your device splits 50 bytes report into 5 transactions of 10 bytes.
WBVAL(0x0040), /* wMaxPacketSize */
Set it to 64 bytes. I recommend you to set it always to 64 for full-speed device. On the spec, any number will do, but it doesn't mean the programer of the PC device driver has debugged it in all numbers. 64 is the certain number absolutely, because it is the full size for interrupt (HID) and bulk endpoints on full-speed.
Maybe, you aren't sure how wMaxPacketSize works. I wrote a short article about the relation of "Transfer - transaction - packet" in this post. It describes how wMaxPacketSize works on the USB protocol. It is applied to bulk and interrupt (HID) transfer.
"C8051F340 USB_Bulk example question" on SiLabs Forum www.cygnal.org/.../001627.html Endpoint handler - USB_EndPoint1 If you want to send 10 bytes report, set HID_ReportCount to 10 on the report descriptor. HID_ReportCount() determines the transfer size. The HID device driver on PC drops all transfer, whose size doesn't match to the report descriptor. Then, your host application sees just the report whose size is defined in the report descriptor.
Also, this USB_EndPoint1() implementation means that your firmware sends the report repeatedly at the rate of bInterval (10 ms, but actually 8 ms) on the endpoint descriptor. If you send the report just when you want, see this implementation.
"HID Mouse keeps sending unneeded data!" http://www.keil.com/forum/docs/thread11531.asp
For report of greater size, see this topic. "USB HID reports longer than 64 bytes on lpc2141" http://www.keil.com/forum/docs/thread12679.asp
Tsuneo