cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L4Q5 I am using the USB interface in Device mode (CDC Virtual Comms Port) and the My_CDC_Receive_FS() interrupt callback. How can exercise flow-control on the incoming USB data to give me time to process it?

AJohn.10
Associate

In the callback I buffer the input read by the USBD_CDC_ReceivePacket() call and exit My_CDC_Receive_FS() asap, processing the incoming data in the background

Sometimes, my input buffer fills, & I can't easily make it any larger or empty it any quicker

How can I hold-off the incoming data without upsetting the USB driving code?

(i.e. simply not calling the USBD_CDC_ReceivePacket() fn if my buffer is full is not an option as it seems to close the USB connection / upset the USB driver)?

1 REPLY 1
gbm
Lead III

That's exactly how you are supposed to do it. By not calling CDC_ReceivePacket() you may safely delay the incoming data. If there is a problem with your application, it's probably somewhere else.

Be warned, however, that all USB-related routines, like Transmit and ReceivePacket, must be called from an interrupt service routine of the same priority as USB interrupt or, alternatively, with interrupts being disabled.

My STM32 stuff on github - compact USB device stack and more: https://github.com/gbm-ii/gbmUSBdevice