Ok I have not looked at everything so probably missing some things.
You have the USB controller hardware which has endpoints and you have all the USB documentation saying what happens on the wire.
Note also that USB is packet based and the order of packets can be important.
A big part of the problem is stating what you are trying to setup as a USB Device.
Comes down to you have a choice of doing things the way defined in the USB documents and hope that the pc end has support for that way of doing things or using the information in the USB documents to say I am doing my own thing an having to supply host side software as well.
So here you have the USB controler that could be different or the same for different mpu's.
I think all the examples are using ST's software on the pc side so what is happening needs to match up to what this software expects if it is used at pc side.
From what I have read so far
From UM1021 User manual
http://www.st.com/st-web-ui/static/active/en/resource/technical/document/user_manual/CD00289278.pdfPage 56 is start of
Communication device class(CDC)
Class Subclass Specification for PSTN Devices
This driver implements the following aspects of the specification
so this area might be worth a read
also later in section 6.10.5
UM0424 VirtualComport_Loopback Doc ID 13465 Rev 12 53/85
http://www.st.com/st-web-ui/static/active/en/resource/technical/document/user_manual/CD00158241.pdfpage 49
7 Virtual COM port demo
This is usb to serial port
8 VirtualComport_Loopback
this is USB to software with the software in this case echo receive to transmit
so echo what the pc sends back to pc
Think this might be a better starting point for a program on the STM32 to talk with a pc.
I have read that circular buffers are used someplace but I have not seen any hints of this yet in the code I have looked at.
A FIFO could be one or more linear buffers or a circular buffer.
I do not remember if DMA can do circular buffers, but I do remember DMA being able to bounce between to linear buffers.
You could have data being received with DMA or interrupts bouncing between two linear buffers when a buffer is full. Then dump the full buffer in a larger circular buffer. And then go from circular buffer to two linear buffers to transmit out other interface.
As crazy as this sounds, it could give the main program more time.
And what you may want in the end is many of the examples all working at the same time.
c