Loading...
 
Skip to main content

System Workbench for STM32


Receiving data over USB com port

I have created a project using STMCubeMX which includes a usbd driver configured as a virtual com port. I have it working and can receive data via the CDC_Receive_FS callback function. My question is how is this callback called. Is it done at interrupt level, or is there some other mechanism. In particular, if I want to copy the data from the callback buffer into a queue which will be read by my main code, do I need some protection for concurrency (e.g. disable interrupts)?

Thanks.

i suppose USB VCP is interrupt driven. I'm using USB HID, this is definitely interrupt driven.
Yo do need concurrency protection. Are you using FreeRTOS? FreeRTOS provides message queues with are thread safe


Thanks for the reply. I have determined that it is interrupt driven and that I need to disable interrupts when removing elements from the queue. (I am not using FreeRTOS).