AnsweredAssumed Answered

USB Host HID Detach Error

Question asked by mo_tron on Jul 1, 2013

I'm using the following:

MQX 4.0

Custom board based on TWR-K60F120M

Keil uV 4.60

 

I am trying to talk to an XBOX Controller (not my choice) using the TWR-K60F120M as a HOST HID Device.  I took the example hid_mouse project and modified it by changing the USB_HOST_DRIVER_INFO class/subclass/protocol to 0xFF.  In the main loop under case USB_DEVICE_INUSE I added:

 

tx_pipe = _usb_hostdev_find_pipe_handle(hid_device.DEV_HANDLE, hid_device.INTF_HANDLE, USB_INTERRUPT_PIPE, USB_SEND);

 

to get a pipe handle to send data to the XBOX controller.  In the process_mouse_buffer function, I added:

 

tr.G.TX_BUFFER = VIBRATE_ON;

tr.G.TX_LENGTH = 0x08;                    

_usb_host_send_data(host_handle, tx_pipe, &tr);

 

to send data to respond to XBOX controller button inputs.

 

This works fine.  I can send packets that control the leds and rumble motors no problem.  The problem arises when I detach the controller from the micro.  The micro seems to get stuck.  I plug it back in and it doesn't responds.  So I rebuild the USB library with the debug output turned on and I get the following output on the serial port when I detach the controller before the crash:

 

usb_host_driver_info_nonzero

usb_host_driver_info_nonzero FAILURE

usb_host_driver_info_scan SUCCESSFUL

usb_hostdev_attach_detach SUCCESSFUL

usb_dev_list_close_pipe

_usb_host_close_pipe

_usb_host_close_pipe SUCCESSFUL

usb_dev_list_close_pipe SUCCESSFUL

usb_dev_list_free_memlist

usb_hostdev_validate

usb_hostdev_validate SUCCESSFUL

usb_hostdev_delete_interface

usb_dev_list_close_pipe_bundle

usb_dev_list_close_pipe

_usb_host_close_pipeGoing to idle state

 

It looks like with it tries to execute the function _usb_host_close_pipe in host_close.c but it never makes it out.

 

Does anyone have any idea what is wrong?  Are there any examples of an usb hosting a HID device like a joystick showing IN/OUT comms on two interrupt endpoints?

 

Any info would be greatly appreciated.

 

Mike

 

 

 

Outcomes