Keil™, An ARM® Company

Discussion Forum

USBHID example and usblib on lpc214x

Next Thread | Thread List | Previous Thread Start a Thread | Settings

DetailsMessage
Author
Gudjon Gudjonsson
Posted
8-Feb-2010 09:24 GMT
Toolset
ARM
New! USBHID example and usblib on lpc214x

Hi
I have been trying to use the USBHID example with the libusb library but without success. I get the following error:

libusb:debug [libusb_set_configuration] configuration 1
Set configuration failed, error -6
The libusb library works perfectly when I use the following firmware:
http://sourceforge.net/projects/lpcusb/

I found this thread:
http://www.keil.com/forum/docs/thread16287.asp

that seems to solve the same problem for the LPC2364 chip but unfortunately I couldn't use the solution for my lpc2148 chip.

Can anyone please show me the code changes needed for USBHID to work with lpc2148?

Regards
Gudjon

Author
Tsuneo Chinzei
Posted
8-Feb-2010 10:59 GMT
Toolset
ARM
New! RE: USBHID example and usblib on lpc214x

> Can anyone please show me the code changes needed for USBHID to work with lpc2148?

Posted the code changes to the original thread
http://www.keil.com/forum/docs/thread16287.asp

Tsuneo

Author
Gudjon Gudjonsson
Posted
8-Feb-2010 15:00 GMT
Toolset
ARM
New! RE: USBHID example and usblib on lpc214x

Hi Tsuneo
Thanks for the answer. I did the changes you mentioned but it doesn't seem to work. The program still works with the Windows HID.lib but not my libusb application.

The host code below works with the usbstack firmware from sourceforge on my lpc2148 but not with the Keil USBHID firmware.

libusb_init (NULL);
//libusb_set_debug ( 0, 3);
handle = libusb_open_device_with_vid_pid (NULL, 0xc251, 0x1301);
libusb_set_configuration (handle, 1);
libusb_claim_interface (handle, 0);


The libusb_set_configuration command fails (and then libusb_claim_interface)

Thanks again
Gudjon

Author
Tsuneo Chinzei
Posted
8-Feb-2010 17:40 GMT
Toolset
ARM
New! RE: USBHID example and usblib on lpc214x

> The libusb_set_configuration command fails (and then libusb_claim_interface)

Ah, then it is a different problem from above post.

As the default, HID device is attached to HID kernel device driver.
If it is the case, you have to detach it from the default driver, using usb_detach_kernel_driver_np()

libusb_init (NULL);
//libusb_set_debug ( 0, 3);
handle = libusb_open_device_with_vid_pid (NULL, 0xc251, 0x1301);
<-------- usb_detach_kernel_driver_np()
libusb_set_configuration (handle, 1);
libusb_claim_interface (handle, 0);

In this post on Microchip forum, xiaofan shows libusb code for HID which works successfully.
http://www.microchip.com/forums/tm.aspx?m=340898

Tsuneo

Author
Gudjon Gudjonsson
Posted
9-Feb-2010 19:23 GMT
Toolset
ARM
New! RE: USBHID example and usblib on lpc214x

Thanks Tsuneo Your solution worked perfectly. My host application can read successfully from the target. I still don't know how to write bytes (with libusb) to the USBHID target as is done in the HID_Client program but that is only a minor problem.

Regards
Gudjon

Author
Gudjon Gudjonsson
Posted
9-Feb-2010 19:24 GMT
Toolset
ARM
New! RE: USBHID example and usblib on lpc214x

Thanks Tsuneo Your solution worked perfectly. My host application can read successfully from the target. I still don't know how to write bytes (with libusb) to the USBHID target as is done in the HID_Client program but that is only a minor problem.

Regards
Gudjon

Author
Gudjon Gudjonsson
Posted
9-Feb-2010 21:35 GMT
Toolset
ARM
New! RE: USBHID example and usblib on lpc214x

Thanks Tsuneo
Your solution worked perfectly. My host application can read successfully from the target. I still don't know how to write bytes (with libusb) to the USBHID target as is done in the HID_Client program but that is only a minor problem.

Regards
Gudjon

Next Thread | Thread List | Previous Thread Start a Thread | Settings