cancel
Showing results for 
Search instead for 
Did you mean: 

STM32cubeF4 USB Virtual COM port example

gordon2399
Associate II
Posted on April 27, 2015 at 21:04

Can someone show me a working example program of STM32F4 USB virtual com port using the STM32cubeF4 library?

2 REPLIES 2
l239955_stm1
Associate II
Posted on April 28, 2015 at 10:44

USBD_HandleTypeDef hUSBDDevice;

int main(void) {

    HAL_Init();

    SystemClock_Config();

    /* Init Device Library */

    while(USBD_Init(&hUSBDDevice, &VCP_Desc, 0) != 0)

    {}

    /* Add Supported Class */

    USBD_RegisterClass(&hUSBDDevice, &USBD_CDC);

    /* Add CDC Interface Class */

    USBD_CDC_RegisterInterface(&hUSBDDevice, &USBD_CDC_fops);

    /* Start Device Process */

    USBD_Start(&hUSBDDevice);

   

    data =  .....

    while(1) {

        USBD_CDC_SetTxBuffer(&hUSBDDevice, &data[0], 8);

        USBD_CDC_TransmitPacket(&hUSBDDevice);

    }

}

Amel NASRI
ST Employee
Posted on April 30, 2015 at 11:24

Hi Lee,

Look at ''STM32Cube_FW_F4_V1.5.0\Projects\STM324x9I_EVAL\Applications\USB_Device\CDC_Standalone'' for example.

-Mayla-

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.