Servicing CLASS Requests in custom USB Class driver

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Servicing CLASS Requests in custom USB Class driver

358 Views
VictorLorenzo
Contributor IV

Hi,

I'm implementing one USB device class driver for one device class which is not supported in the MQX USB stack and I need some advise on how I could service one class request that should eventually return a large data block.

I'll explain myself, this is the situation:

  • The response for the class request (in this case GET_CLOCK_FREQUENCIES, CCID class) must return one buffer (lets say 120 bytes) which is larger than the control endpoint's buffer (64 bytes).
  • I have one local buffer (let's say 64 bytes) for rendering the class requests responses, but in some cases the buffer is not big enough for accommodating the whole response, so I should generate it by fractions (no problem in doing that, it's easy and I did it before with kind of a states machine in another microcontroller).
  • The platform is a custom design with one MK20DN512VLK10. The IDE is CW 10.4, USB Stack 4.0.2, and MQX 4.0.2.

When looking with one USB analyzer at how the drivers return the response for the standard GET_DESCRIPTOR( CONFIGURATION ) request, It can be seen that the response is automatically divided. The total length for the CONFIGURATION descriptor is 93 bytes (for my application) and is divided in two consecutive IN transactions (see the picture below, the four transactions involved in the request execution are boxed, NAKed transactions were filtered out).

kinetis-usb-getdesc-01.png

The question is, How/where could I link my USB class driver into the USB framework so I can get notified of the IN transactions to generate the response to be sent in the DATA packets? My intention is being able to prepare the first part of the response in my local buffer and send it as part of the work in the class's OtherRequests event handler, then, in the processing of subsequent IN transactions, continue preparing/sending the rest of the response. I need to avoid using malloc() and free().

Thanks a lot in advance,

--Victor

Labels (1)
Tags (3)
0 Kudos
0 Replies