cancel
Showing results for 
Search instead for 
Did you mean: 

Strange CUBE USB device driver behaviour

0x4e71
Associate II
Posted on December 04, 2015 at 13:27

Hello,

I work with STM32F429-Disco. I have problem understanding how USB class device driver should be implemented.

From MSC class driver implementation I see:

- DataOut is called for ep out where Receive() is called, and Prepare_Receive() - so next data can be received, this makes URB complete to appear on the bus (at least this is what I expect).

- DataIn is called for ep in urb submit, and this is where Transmit() is called - so e.g. response to some command sent over ep out can be transmitted - this makes urb complete on ep in to appear.

But this does not work for me this way. When I call only Prepare_Receive() in DataOut then DataIn is never called. Only if I call both Transmit() and Prepare_Receive() in DataOut then DataIn is activated (anyway this is too late as I already transmitted the response). But this way I can communicate with PC host (I have some python script writing and reading to/from the device which correctly sends receives data). I based my implementation on CDC device code, could this be any reason for the driver to behave this way? Am I missing some configuration to have DataOut, DataIn activated the way it is expected? Or my understanding of control flow for DataIn, DataOut is not correct?

Thanks for any suggestions on how this should be understood/implemented.
1 REPLY 1
0x4e71
Associate II
Posted on December 11, 2015 at 09:46

Hello everyone,

I did some more testing of the device driver, but was not able to get it working any other way that I described. Still have to do both Transmit() and Prepare_Receive() in DataOut() to get transmission done. Also for transfer of large files I have to ''start'' transfer by doing the first Transmit() in DataOut(), only then DataIn  is activated and I can handle the transmission with subsequent Transmit() in DataIn.

Even if this looks strange to me, this works. I implemented PTP device which works correctly in both Linux with gphoto2 and standard Windows drivers. So standard drivers are handling my device I can read/write files and communication flow is OK.

But still the question is: why do I have to do initial Transmit in DataOut to have DataIn activated?

Regards,

P.S. For clarity: Transmit, Receive, Prepare_Receive, DataIn, DataOut are functions from Cube USB driver implementation.