Hi, We make a custom board work the same as MCB2300 and try to run the USBHID example for LPC 2364 chip. I cannot read the endpoint 1 from libusb command usb_interrupt_read(device, 0x81, buffer, sizeof(buffer), 500). I can make another endpoint 2 and can write to the endpoint 2 OK but I cannot read any endpoint. It gives me a timeout error with error code -110.
Can anyone show me how to fix it?
More detailed code modification along with above topic is requested by another thread
> Gudjon > Can anyone please show me the code changes needed for USBHID to work with lpc2148? http://www.keil.com/forum/docs/thread16347.asp
This modification is applied to this KEIL example.
LPC2148 USB HID (Human Interface Device) Example http://www.keil.com/download/docs/306.asp
usbcfg.c #define USB_POWER_EVENT 0 #define USB_RESET_EVENT 1 #define USB_SUSPEND_EVENT 0 #define USB_RESUME_EVENT 0 #define USB_WAKEUP_EVENT 0 #define USB_SOF_EVENT 0 #define USB_ERROR_EVENT 0 #define USB_EP_EVENT 0x0003 #define USB_CONFIGURE_EVENT 1 #define USB_INTERFACE_EVENT 1 // <----- enable USB_INTERFACE_EVENT #define USB_FEATURE_EVENT 0 usbuser.c /* * USB Set Configuration Event Callback * Called automatically on USB Set Configuration Request */ #if USB_CONFIGURE_EVENT void USB_Configure_Event (void) { if (USB_Configuration) { /* Check if USB is configured */ GetInReport(); USB_WriteEP(0x81, &InReport, sizeof(InReport)); } } #endif /* * USB Set Interface Event Callback * Called automatically on USB Set Interface Request */ #if USB_INTERFACE_EVENT void USB_Interface_Event (void) { // <-------- copy the contents of USB_Configure_Event(), // or just call USB_Configure_Event() USB_Configure_Event(); } #endif
Tsuneo
Hi Tsuneo,
I have a question about the reset button. When I hit the reset button:
For NXP LPC23XX USB Bootloader example, I can see the usb reset message on the linux kernel log and have usb back.
For USBHID keil example, I don't see any message on linux kernel log and the usb never come back until I power off the board and turn on the power again to get the usb.
I check the files and see they have the same usbhw.c and usbcore.c, most of other files are the same except one use hid and another use msc.
> For NXP LPC23XX USB Bootloader example, I can see the usb reset message on the linux kernel log and have usb back. ... I check the files and see they have the same usbhw.c and usbcore.c, most of other files are the same except one use hid and another use msc.
Sound like the difference of the length of start up initialization of the firmware. When the reset button is pushed down longer, for 2-3 sec, what occurs ?
1) When the LPC23XX goes to reset, port pins turn to input. 2) The D+ pull-up resistor on the USB line, which is controlled by CONNECT pin, is detached. 3) Host PC (or hub) detects USB disconnection by the voltage change on D+ line, which is pulled down on the host side. 4) The firmware on the LPC23XX starts initialization 5) When the firmware initializes USB engine, it enables D+ pull-up, too. 6) Host detects connection by the D+ line voltage change. 7) Host starts enumeration again, which start with bus reset.
If the length of disconnected period is too short, host misses to detect the disconnection.