USB Generic HID

cancel
Showing results for 
Search instead for 
Did you mean: 

USB Generic HID

Jump to solution
4,162 Views
gaminn
Contributor IV

Hello,

I adapted USB hid mouse example project from Freescale USB Stack v4.0.2 to Generic HID. My PC program to test HID device succesfully sends first report, but MCU (TWR-K70) never receives it. Then I'm unable to send next reports to MCU. Like the first report blocks the endpoint. I registered callbacks when initializing HID class:

USB_Class_HID_Init(CONTROLLER_ID, USB_App_Callback, VendorCallback, USB_App_Param_Callback);

On first report sent from PC to MCU, USB_App_Callback() is called with event_type = USB_APP_SEND_COMPLETE (why send complete ???). Then nothing. Sending reports from MCU to PC works.

I configured HID generic device to use 2 endpoints IN and OUT, report size is 64 bytes.

Thanks for any advice.

Labels (2)
Tags (3)
1 Solution
516 Views
gaminn
Contributor IV

Thanks, during weeked I managed to make generic HID device. The main problem was, that the usb_hid class provided in Freescale USB stack supports only IN transactions. In other words, it is not a general implementation of HID class. I added support of OUT transactions (USB_Class_HID_Recv_Data() function calling _usb_device_recv_data()) and second endpoint (OUT). It seems to be working well, I'm testing the generic HID now.

View solution in original post

0 Kudos
11 Replies
516 Views
csjc
Contributor II

Martin,

Is the Generic HID yellow-banged in Device Manger (Windows)?

Thanks,

Chris.

0 Kudos
516 Views
CarlosCasillas
NXP Employee
NXP Employee

Hello Martin,

   

I have attached a generic HID project for CodeWarrior v10.2. It is a SCI to HID bridge application, using the MC9S08JS16 MCU. It is based on Mouse example Freescale USB Stack v3.2.0, but generating a stand-alone project that doesn’t require installing any USB Stack version or placing the project on a specific location. Besides, it adds the implementation of the optional OUT endpoint, which is not included on any of the HID examples of USB Stack.

   

On this project, the SCI module is configured by default to 8N1, 115200 bps. These configurations are declared on file “sci.h” and on the call of function “u8SCI_init”. Then, on interrupt function “SCI_rx_srvc”, the SCI data is received and stored on the circular buffer “g_sci_rx_buf”, and the proper flags are set. Finally, on “Serial2HID_Task” function (on “Serial2HID.c” file), the SCI’s buffer is sent by HID’s IN endpoint, and the data received from HID´s OUT endpoint is sent by the SCI module.

The time interval between transaction is configured to 1mS, and this time base is generated by the TPM module, which is configured inside function “TestApp_Init” of “Serial2HID.c” file. On TPM´s interrupt function “TPM_OVF_ISR”, the circular buffer (used for transactions) is managed.

I hope you could use it as reference.

Best regards!

/Carlos

0 Kudos
517 Views
gaminn
Contributor IV

Thanks, during weeked I managed to make generic HID device. The main problem was, that the usb_hid class provided in Freescale USB stack supports only IN transactions. In other words, it is not a general implementation of HID class. I added support of OUT transactions (USB_Class_HID_Recv_Data() function calling _usb_device_recv_data()) and second endpoint (OUT). It seems to be working well, I'm testing the generic HID now.

View solution in original post

0 Kudos
516 Views
xavi2804
Contributor II

hello, did you make it works? i'm trying to do this also.

0 Kudos
516 Views
allanrobinson
Contributor II

Javier,

Yes, I was able to get it working. When I get a second from my job, I will send you my code. You have to make changes to the usb_descriptor.c, usb_descriptor.h, USB_Config.h, usb_hid.c, and then some changes to the actual callback function in the particular application code (in our case we called it IntersilDAQ.c).

We are using an MKL25Z128xxx4 microcontroller so we used the USBHIDKBD-Flash demo for our template code. I followed Carlos generic HID project code for the SCI to HID bridge application to write my code and the reading chapter 5 in the Freescale USB Device Stack Users Guide. His code is up on the Freescale community. His microcontroller was different than the one we are using.

Allan

0 Kudos
516 Views
xavi2804
Contributor II

Thank you Allan, i'm going to check the code and try to get it work for my MK60F.

Javier

0 Kudos
516 Views
allanrobinson
Contributor II

Javier,

Were you able to get your HID communication working?  Do you still need me to try and send you my code pertaining to HID communication?

Allan

0 Kudos
516 Views
xavi2804
Contributor II

well, still i haven't got time to make it work, i just see a little the code from CarlosCasillas, and i tryed to modified form my microcrontroler but got any lucky, no i cant get the computer to reconize the usb device, but if you could sen me your code to check it and compare it would be very helpul.

Thank you

0 Kudos
516 Views
allanrobinson
Contributor II

Javier,

Attached is my code.

Allan

516 Views
PedroBecerra
Contributor III

Hi Allan.

I'm trying to make working your code.

I've started from the HID_MOUSE_DEVICE_MKL25Z128_PEx and applied all of your code, but it doesn't work.

I've modified the descriptors and I've got to comunicate from my board to PC. But I cannot comunicate from PC to board.

Could you give me any help?  Please.

0 Kudos
516 Views
joseali
Contributor I

Hello, could you explain me, in what part of code the MCU is receiving data?

what is the function for doing that?

regards

Jose

0 Kudos