cancel
Showing results for 
Search instead for 
Did you mean: 

How to properly use the CDC library without UART, how to properly receive data with USBD_CDC_ReceivePacket()

RAnde.2
Associate

I am using the CDC library as a quick way to get USB communication with a linux machine. I understand that to use the USBD_CDC_TransmitPacket() function you first check the TxState variable in the CDC handle struct then set the buffer with USBD_CDC_SetTxBuffer() and then call transmit. The TxState will tell you when its done. Great. What to do on the receive side? The Itf defines a callback function that should be called when there is data available at the lower level and needs to be pulled out into another buffer. What exactly is the callback (*Receive) in the CDC handle supposed to do? I'm not using a connection to UART, I'm just trying to get the data from USB and store it into a variable for further processing, but the example code just calls a UART DMA transfer function. Does this mean the data in buf is already there? What is the purpose of the UBDC_CDC_ReceivePacket? When is that used? If I'm supposed to call SetRXBuffer and ReceivePacket in the receive callback, when do I know the receive is completed? When receivePacket returns?

Very confused by the CDC documentation and could use some help.

Thanks!

Ryan

0 REPLIES 0