cancel
Showing results for 
Search instead for 
Did you mean: 

CubeMx USB CDC asynchronous API?

taraben
Senior
Posted on May 24, 2015 at 18:38

Hello All,

1) how can I have an asynchonous Transmit command ?

2) what is the largest amount of data I can put into CDC_Transmit_FS ?

I am implementing CDC on my firmware based on CubeMx. So far it works (I have to increase the heap)

when I quickly want to transmit severel chunks of data:

     CDC_Transmit_FS(buffer1, strlen((char *)buffer1));

     CDC_Transmit_FS(buffer2, strlen((char *)buffer2));

     CDC_Transmit_FS(buffer3, strlen((char *)buffer3));

only the first one is sent.

What I do not understand is how buffer handling is done.

in CDC_Transmit_FS it

a) USBD_CDC_SetTxBuffer

b) USBD_CDC_TransmitPacket

Function a) copies the buffer pointer to the HAL and function b) sends the data via USB.

Why does a second call of CDC_Transmit_FS does not overwrite data of the ongoing CDC_Transmit_FS?

What is a safe time to call CDC_Transmit_FS? Do I have to check before?

Is there a callback that tells me when CDC is ready for next call CDC_Transmit_FS?

How does CDC_Transmit_FS large amount of data?

Does it sent all data or only the first part that fits into USB CDC packet?

Regards, Adib.

#cdc #stm32f4 #usb #cubemx
3 REPLIES 3
dmitry1
Associate II
Posted on November 22, 2015 at 11:41

Same question.

How to catch ''sent'' event?

And for what is UserTxBufferFS when CDC_Transmit_FS never use it?
Posted on November 25, 2015 at 19:00

You need to check the status returned by the call to CDC_Transmit_FS().  It will return a status of HAL_OK if the transmitter is ready to accept the next message, but it will return not OK if it is still busy with the last message.  So if you put your statement in a while loop that keeps retrying until it gets back HAL_OK, the subsequent messages will block until they can be sent, and then they will go out in the order you send them.