cancel
Showing results for 
Search instead for 
Did you mean: 

Using USB device Virtual comm questions

Alexander Gornik
Associate II

Hello,

Using CubeMX, I have created USB CDC device for FS and started using the CDC.

By modifying CDC_Receive_FS() I am able to receive all data sent form the PC over USB and put the data in my buffer

Also (while the USB cable is connected and PC terminal is opened, I am able to send rarely data to the PC using CDC_Transmit_FS().

The next stage is sending many data via USB (e.g., my trace messages).

For this purpose I need to know when the USB cable is connected or disconnected and when PC is ready to accept my data (at least the PC port is opened) . So I will be able stop and resume my data sending

For USB connection/disconnection I use USER code sections of HAL_PCD_ResumeCallback() and HAL_PCD_SuspendCallback(). Is it OK? (HAL_PCD_DisconnectCallback has no USER CODE section)

My main questions are:

  1. How I can know (via what user modifiable callback) that The PC port was opened - closed)
  2. When I send data via CDC_Transmit_FS(), what modifiable callback/s inform about the status of the transmission (success or failed)

When I write "modifiable" I means that the code will not be lost every time when the Cube Mx recreates the project

Thanks, Alex Gornik

Now I need to detect when the trabsmiittion

0 REPLIES 0