This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

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:
sourceforge.net/.../

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

Parents
  • 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

Reply
  • 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

Children
  • > 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.
    www.microchip.com/.../tm.aspx

    Tsuneo

  • 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

  • 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

  • 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