Hi Dino
In case you don't 'need' Freescale code you can also get USB-HID-RAW in the uTasker project.
This can be built with most IDEs, including KDS and CodeWarrior (CooCox, IAR, Keil, Greenhills etc.) and also combined with other classes as composite devices (eg. USB-MSD, USB-CDC etc.).
The code is processor independent and so builds and runs on any Kinetis part with USB and can be simulated in the uTasker Kinetis simulator for highest development efficiency.
As an example I just configured for the TWR-K24F120M and attached the binary - this enumerates as HID RAW device and can be tested with the application at the link. The PC program uses endpoint 2 to send 64 byte HID output reports and I set the IN report on endpoint 1 with a size of 32 (to be different) and just send back each report received to the PC host (just the first 32 bytes).
HID raw is very simple, whereby I have attached the required descriptors as header file. The following is the application layer implementation showing this example, although there are several choices for operation - with buffering or interrupt callbacks. I just set up the IN/OUT as a virtual bidirectional pair with a bit of rx buffering. I set a callback on successful IN frame delivery (non-buffered) which is useful for controlling the application sending fast data (to ensure that the PC polls it before the next is prepared) but don't actually use it in this example.
Initialisation:
USBTABLE tInterfaceParameters; // table for passing information to driver
QUEUE_HANDLE endpointNumber = 1;
tInterfaceParameters.owner_task = TASK_USB; // USB task is woken on receptions
tInterfaceParameters.usConfig = 0;
tInterfaceParameters.usEndpointSize = HID_RAW_RX_SIZE; // endpoint queue size (2 buffers of this size will be created for reception)
tInterfaceParameters.Endpoint = endpointNumber++; // the endpoint used by HID raw device for reception
tInterfaceParameters.usb_callback = 0;
tInterfaceParameters.queue_sizes.TxQueueSize = 0;
tInterfaceParameters.queue_sizes.RxQueueSize = (2 * HID_RAW_RX_SIZE);// reception buffer with space for two complete HID raw messages
tInterfaceParameters.Paired_RxEndpoint = endpointNumber++;
tInterfaceParameters.INcallback = fnRawHIDPolled;
USBPortID_HID_raw = fnOpen(TYPE_USB, 0, &tInterfaceParameters); // open the endpoints with defined configurations (initially inactive)
USB task:
if (fnRead(USBPortID_HID_raw, ucRawData, HID_RAW_RX_SIZE) == HID_RAW_RX_SIZE) { // HID raw OUT reception
fnWrite(USBPortID_HID_raw, ucRawData, HID_RAW_TX_SIZE); // send back on IN pipe
}
Optional callback on IN polling completion:
static void fnRawHIDPolled(unsigned char ucEndpoint)
{ // dummy
}
That is about all the code needed to perform the configuration and echo, and the application can do its own other things by simply reading/writing the handle USBPortID_HID_raw.
Regards
Mark
Kinetis: µTasker Kinetis support
K24: µTasker Kinetis TWR-K24F120M support
USB User's Guide: http://www.utasker.com/docs/uTasker/USB_User_Guide.PDF
For the complete "out-of-the-box" Kinetis experience and faster time to market