Page 1 of 1

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

Posted: Thu Nov 29, 2012 7:48 am
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

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

Posted: Thu Nov 29, 2012 8:51 am
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

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

Posted: Thu Nov 29, 2012 8:59 am
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.

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

Posted: Thu Nov 29, 2012 9:02 am
by Giovanni
You have to customize the request hook but you can use everything else as-is and read/write directly the queues.

Giovanni