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
Hi Tsuneo,
I made the Report Descriptor in readable format now:-)
const U8 HID_ReportDescriptor[] = { HID_UsagePage(HID_USAGE_PAGE_GENERIC), HID_Usage(HID_USAGE_GENERIC_MOUSE), HID_Collection (HID_Application), HID_Usage (HID_USAGE_GENERIC_POINTER), HID_Collection (HID_Physical), HID_ReportCount (3), HID_ReportSize (1), HID_UsagePage (HID_USAGE_PAGE_BUTTON), HID_UsageMin (1), HID_UsageMax (3), HID_LogicalMin (0), HID_LogicalMax (1), HID_Input (HID_Data | HID_Variable | HID_Absolute), HID_ReportCount (1), HID_ReportSize (5), HID_Input (HID_Constant), HID_ReportSize (8), HID_ReportCount (2), HID_UsagePage(HID_USAGE_PAGE_GENERIC), HID_Usage(HID_USAGE_GENERIC_X), HID_Usage(HID_USAGE_GENERIC_Y), HID_LogicalMin(0x81), HID_LogicalMax (0x7F), HID_Input (HID_Data | HID_Variable | HID_Relative), HID_EndCollection, HID_EndCollection };
As the USB mouse protocol requires 3 bytes of Data (Button, X Displacement, Y Displacement), I declared U8 InReport as
U8 InReport[3] = {0};
void GetInReport (void) function does nothing (Code stubing will be done later)
I feel by doing so, it should work but....:-( It is still not working...
Are there any other changes i need to take care ?
Thanks & Regards, Kamal Joshi
Are you working on Keil HID example?
Then, you don't need to swap entire descriptors. Replace just the report descriptor.
I see some errors on the config descriptor set in above post, for example, wTotalLength field. But it's pain to examine the figures without any comment for the fields. I recomend you to recover the original descriptors from the example.
For other change,
demo.c BYTE InReport[3]; /* HID Input Report - 3 bytes for mouse */ /* * Get HID Input Report -> InReport */ void GetInReport (void) { // // Fill InReport[] // // InReport[0] mouse buttons, bit 0: left, bit 1: right, bit2: middle // InReport[1] X axis relative movement // InReport[2] Y axis relative movement // }
Hello guys,
I am a first timer with USB and like many others, VERY CONFUSED.
To start with, i have downloaded the example code for USBHID for LPC2368 and it is not working, leading to more confusion but most of them are conceptual and here are a few of them :
1. How will the code call the functions usbcore.c ?
2. How will the code initialize the descriptors and endpoints ?
Any help will be greatly appreciated.
Thanks. Nitin
Don't you think you should start with a new thread, instead of hijacking someone elses?
Yes, I should have.
Apologies for that.
Can you please tell me how to start a new one ?
Thanks.
Got it ..
Please Help Tsuneo !
Sorry for posting here again.
View all questions in Keil forum