Using STM32F4 Discovery and CDC to create a USB-UART bridge

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: RoccoMarco, lbednarz, tfAteba

Post Reply
Abhishek
Posts: 266
Joined: Wed May 23, 2012 3:15 pm

Using STM32F4 Discovery and CDC to create a USB-UART bridge

Post by Abhishek »

Hi all,

I would like to use my STM32F4Discovery board as a USB-UART bridge, using the USB port onboard (the USB-CDC driver) and connecting it to a physical UART port. But I'm not sure how to connect them together, I would need to know the baud rate and other params which the host software on Windows uses to open the port, and then configure the UART peripheral at that baudrate, and also how to couple them both.

I would be obliged if anyone could help me how to start and proceed in this regard.

Best Regards
Abhishek
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: Using STM32F4 Discovery and CDC to create a USB-UART bri

Post by Giovanni »

Hi,

The CDC driver already decodes messages for baud rate and other settings, you have to modify it to do the physical setup of a serial driver.

In order to connect them you need a thread that read/write USB<->Serial, you can use events from the two drivers in order to wake up it when there is data do move.

Giovanni
Abhishek
Posts: 266
Joined: Wed May 23, 2012 3:15 pm

Re: Using STM32F4 Discovery and CDC to create a USB-UART bri

Post by Abhishek »

Does this mean I have to modify the serial_usb.c file in the os/hal folder or make my own copy and do the modifications?

What I infer is:

-> sduRequestHook will get me the baud rate information in the linecoding structure
-> sduDataTransmitted and sduDataReceived will get me the data, and then I will have to adjust in these functions the transmit and receive functions.
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: Using STM32F4 Discovery and CDC to create a USB-UART bri

Post by Giovanni »

You have to customize the request hook but you can use everything else as-is and read/write directly the queues.

Giovanni
Post Reply