Hi all,
Thanks for your contineous support from this site.
I want to detect my board as HID mouse when plugged to USB port of PC. For that I guess I need to write HID mouse driver.
I am using LPC2148 controller. Can i gett some reference code for it?
Thanks & Regards, Kamal
> Can i gett some reference code for it?
Implementation of keyboard and mouse is a good exercise for USB starters to learn Class implementation, because HID spec documents on keyboard and mouse well.
HID spec v1.11 www.usb.org/.../HID1_11.pdf - Appendix E: Example USB Descriptors for HID Class Devices (p66) - Appendix B.2 Protocol 2 (Mouse) (p61)
Starting with a HID example which fits to your compiler,
- LPC2148 USB HID (Human Interface Device) Example - MDK-ARM http://www.keil.com/download/docs/306.asp
- LPCUSB - GNU ARM (YAGARTO, etc) sourceforge.net/.../
Modification of 40-50 lines of its source code (including 26 lines of report descriptor) makes your board a mouse.
If you want to learn on USB, I'll guide you.
Tsuneo
Tsuneo,
I'm soon going to be looking at USB on ARM.
Thank you so much for those links - Some very good bedtime reading :)
Hi Tsuneo,
Thanks for those documents.
I tried both the ways...
1. Changed all the descriptor tables as mentioned in the HID1_1.pdf like:
const U8 HID_ReportDescriptor[] = { 0x05,0x01, 0x09,0x02, 0xA1,0x01, 0x09,0x01, 0xA1,0x00, 0x05,0x09, 0x19,0x01, 0x29,0x03, 0x15,0x00, 0x25,0x01, 0x95,0x03, 0x75,0x01, 0x81,0x02, 0x95,0x01, 0x75,0x05, 0x81,0x01, 0x05,0x01, 0x09,0x30, 0x09,0x31, 0x15,0x81, 0x25,0x7F, 0x75,0x08, 0x95,0x02, 0x81,0x06, 0xC0, 0xC0 }; const U16 HID_ReportDescSize = sizeof(HID_ReportDescriptor); /* USB Standard Device Descriptor */ const U8 USB_DeviceDescriptor[] = { 0x12, 0x01, WBVAL(0x100), 0x00, 0x00, 0x00, 0x08, WBVAL(0xFFFF), WBVAL(0x0001), WBVAL(0x0100), 0x04, 0x0E, 0x30, 0x01 }; /* USB Configuration Descriptor */ /* All Descriptors (Configuration, Interface, Endpoint, Class, Vendor) */ const U8 USB_ConfigDescriptor[] = { /* Configuration 1 */ 0x09, 0x02, WBVAL(0x003), 0x02, 0x01, 0x00, 0xA0, 0x32, /* Interface 0, Alternate Setting 0, HID Class */ 0x09, 0x04, 0x01, 0x00, 0x01, 0x03, 0x01, 0x02, 0x00, /* HID Class Descriptor */ /* HID_DESC_OFFSET = 0x0012 */ 0x09, 0x21, WBVAL(0x101), 0x00, 0x01, 0x22, 0x32, /* Endpoint, HID Interrupt In */ 0x07, 0x05, 0x82, 0x03, WBVAL(0x0008), 0x0A, /* Terminator */ 0 /* bLength */ };
2. I kept the the other descriptor as it is and changed only Report, Interface, HID, Endpoint descriptor. String Descriptor remains the same. Both the ways windows could not detect the board as HID Mouse.
Am I missing something?
One more question, How should i send the mouse data to pc ? What should be its format?
View all questions in Keil forum