Skip to main content
hisham23
Associate III
June 1, 2012
Question

VCP with STM32

Posted on June 01, 2012 at 15:43

Hello,

I am working on virtual serial port to communicate between computer and device through usb.

So i downloaded ''STM32F105/7,STM32F2 and STM32F4 USB on-the-go Host and device library.''  from http://www.st.com/stonline/stappl/resourceSelector/app?page=resourceSelector&doctype=FIRMWARE&ClassID=1734

And i selected vcp from project lists, and start reading the code.

I found that the main application only contains initialization of the hardware and the interrupts.

So the code that is sending data is working in the interrupt, but i cannot find the portion that is responsible to send data... Please if any one can explain me the flow of the program.

Note that i read the manuals from ST concerning this project but i didn't get the point, because they wrote 2 papers only about this application.

Regards,

Hisham
    This topic has been closed for replies.

    12 replies

    cordonnier
    Associate
    September 16, 2013
    Posted on September 16, 2013 at 21:23

    I know the thread is old but I just wanted to document what I found by working with the library on this thread, because the example code is very misleading. Even though the DCD_EP_Tx() function is putting only one packet in the FIFO in the VCP example, this is an incorrect behaviour, because the function DCD_EP_Tx() can handle transfers bigger than one packet and is splitting the buffer given as parameter in several packets if the buffer size is greater than the max packet size.

    The function DCD_EP_Tx() is used in this example code only with messages smaller than the packet size, and this has therefore no incidence in this example, but should not be used to develop other USB classes.

    The ''DataIn'' callback is called by the OTG library at the end of a full transfer(several packets), and not at the end of each packet transmission. Unfortunately, in the code provided in the ST example the code in ''DataIn'' is checking the value of the ''in'' pointer set by the application, and some packets are therefore sent from the DataIn callback if the application initiated another bulk-in transfer during the current bulk-in transfer, and some others from DCD_EP_Tx(), which works but is clearly not logical.