AnsweredAssumed Answered

Kinetis USB stack question

Question asked by Ismail Bari on Jan 14, 2014
Latest reply on Jan 16, 2014 by Ismail Bari

Hi,

 

I am using the Freescale USB stack v4.1.1 with K60DN256Z processor. I could get the USB hid device emumerated properly. However, when I do SET REPORT, the (proper) data reaches the controller only if I send the SET REPORT again. I other words, it is like the data is double buffered internally and it gets flushed only on the next SET REPORT command.

 

I browsed through the usb code and found the following code an usb_dci.c, function: USB_DCI_OnDeviceSetupPacket

 

           if((pSDP.bmRequestType == USB_DCI_SET_REQUEST_ITF)||

               (pSDP.bmRequestType == USB_DCI_SET_REQUEST_EP))

            {

                    event.setup = TRUE;

                (void)USB_Device_Call_Service(EpNum, &event);

                if(pSDP.wLength > 0)

                {

                        event.setup = FALSE;

                        (void)USB_Device_Call_Service(EpNum, &event);

                }

            }

 

This piece of code is executed when there is a SET REPORT command. As you see, the first time USB_Device_Call_Service is called with event.setup = TRUE. This will process the setup packet from the host. Then the services schedules the next OUT transaction to be processed and it returns back. Once the service returns, it is called again with event.setup = FALSE..(since pSDP.wLength will be more than 0). Here is where I am lost... why is the service called again without waiting for the OUT transaction to be processed? 

 

I think the behaviour I see seems to be happening because of this. Is there something I am missing to make the USB stack working properly? Any pointer would be of great help.

 

BTW, my report size is 64 bytes long and I have to change the size of ext_req_to_host buffer (in usb_framework.c) to 64+8 bytes long..

 

Thanks,

-Ismail

Outcomes